Reading and Writing NFC Tags
ELECHOUSE NFC modules support all major NFC tag types used in consumer and industrial applications. This guide covers tag type selection, protocol compatibility, and code examples for reading and writing NFC tags with Arduino, ESP32, and Raspberry Pi / Linux.
Supported NFC Tag Types
| Tag Type | Standard | Common Products | Read | Write |
|---|---|---|---|---|
| MIFARE Classic 1K / 4K | ISO 14443A | Key fobs, transit cards | ✓ | ✓ |
| MIFARE Ultralight / NTAG | ISO 14443A | NTAG213, 215, 216 stickers | ✓ | ✓ |
| MIFARE DESFire EV1 / EV2 | ISO 14443A | Secure access credentials | ✓ | ✓* |
| ISO 14443B | ISO 14443B | Bank cards, ID cards | UID only | No |
| FeliCa | ISO 18092 / JIS 6319 | Suica, Octopus, WAON | ✓ | ✓ |
| ISO 15693 / NFC-V | ISO 15693 | Industrial labels, ICODE | PN7160/ST25R3916 | PN7160/ST25R3916 |
| NDEF (any tag) | NFC Forum | NFC stickers with URL/text | ✓ | ✓ |
* DESFire write requires authentication keys
Module Selection for Tag Reading / Writing
- MIFARE Classic / NTAG / DESFire / FeliCa: PN532 V4 — widest library support
- ISO 15693 / NFC-V tags: PN7160 or ST25R3916
- Desktop / PC tag reading: PN532 USB Type-C with libnfc or nfcpy
- High-performance / multi-tag: ST25R3916
Arduino / ESP32 — Read NTAG UID
#include <PN532.h>
#include <PN532_SPI.h>
PN532_SPI pn532spi(SPI, 10); // SS = pin 10
PN532 nfc(pn532spi);
void setup() {
Serial.begin(115200);
nfc.begin();
nfc.SAMConfig();
}
void loop() {
uint8_t uid[7]; uint8_t uidLen;
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLen)) {
Serial.print("UID: ");
for (int i=0; i<uidLen; i++) { Serial.print(uid[i], HEX); Serial.print(" "); }
Serial.println();
}
delay(500);
}
Raspberry Pi / Linux — Read NFC Tag (nfcpy)
import nfc
def on_connect(tag):
print("Tag found:", tag.identifier.hex())
return True
with nfc.ContactlessFrontend('usb') as clf:
clf.connect(rdwr={'on-connect': on_connect})
Writing NDEF Data to an NTAG
// Arduino: write URL to NTAG213
nfc.ntag2xx_WritePage(4, (uint8_t[]){0x03, 0x0F, 0xD1, 0x01});
nfc.ntag2xx_WritePage(5, (uint8_t[]){0x0B, 0x55, 0x04, 'e'});
// ... etc
