Library for Unit-NFC series using M5UnitUnified.
M5UnitUnified has a unified API and can control multiple units via PaHub, etc.
Unit NFC is a near-field communication read/write unit operating at 13.56 MHz. The module features the ST25R3916 high-performance NFC front-end IC, supporting mainstream protocols including ISO 14443A, ISO 14443B, FeliCa™, and ISO 15693, enabling reliable read/write operations and data exchange with a wide variety of NFC/RFID tags and cards. The IC supports reader/writer mode, card emulation mode, and custom protocol mode, with automatic antenna tuning, high-sensitivity reception, and comprehensive protocol handling capabilities.
Cap CC1101 is a wireless expansion module for Cardputer-Adv that combines a CC1101 Sub-1 GHz transceiver (315/433/868/915 MHz) and an ST25R3916 NFC front-end, both accessed over SPI. This library supports the NFC part (ST25R3916) only.
Raw R/W includes FileSystem via ISO-DEP when applicable.
Support may be expanded in future updates to cover PICCs not listed here.
| PICC Type | NFC Forum Tag (NDEF) | Detect | Identify | Raw R/W | Notes |
|---|---|---|---|---|---|
| MIFARE Classic Mini | None | Yes | Yes | Yes | Auth required |
| MIFARE Classic 1K | None | Yes | Yes | Yes | Auth required |
| MIFARE Classic 2K | None | Yes | Yes | Yes | Auth required |
| MIFARE Classic 4K | None | Yes | Yes | Yes | Auth required |
| MIFARE Ultralight | Type2 | Yes | Yes | Yes | |
| MIFARE Ultralight EV1 MF0UL11 | Type2 | Yes | Yes | Yes | |
| MIFARE Ultralight EV1 MF0UL21 | Type2 | Yes | Yes | Yes | |
| MIFARE Ultralight Nano | Type2 | Yes | Yes | Yes | |
| MIFARE Ultralight C | Type2 | Yes | Yes | Yes | |
| NTAG 203 | Type2 | Yes | Yes | Yes | |
| NTAG 210u | Type2 | Yes | Yes | Yes | |
| NTAG 210 | Type2 | Yes | Yes | Yes | |
| NTAG 212 | Type2 | Yes | Yes | Yes | |
| NTAG 213 | Type2 | Yes | Yes | Yes | |
| NTAG 215 | Type2 | Yes | Yes | Yes | |
| NTAG 216 | Type2 | Yes | Yes | Yes | |
| ST25TA512B | Type4 | Yes | Yes | Yes | ISO-DEP |
| ST25TA02K | Type4 | Yes | Yes | Yes | ISO-DEP |
| ST25TA16K | Type4 | Yes | Yes | Yes | ISO-DEP |
| ST25TA64K | Type4 | Yes | Yes | Yes | ISO-DEP |
| MIFARE Plus 2K (S/X/EV1/EV2) | None | Yes | Yes | Yes | SL0/SL1/SL3(*1) |
| MIFARE Plus 4K (S/X/EV1/EV2) | None | Yes | Yes | Yes | SL0/SL1/SL3(*1) |
| MIFARE Plus SE 1K | None | Yes | Yes | Yes | SL0/SL1/SL3(*1) |
| MIFARE DESFire 2K (EV1/EV2/EV3) | Type4 | Yes | Yes | Yes | ISO-DEP |
| MIFARE DESFire 4K (EV1/EV2/EV3) | Type4 | Yes | Yes | Yes | ISO-DEP |
| MIFARE DESFire 8K (EV1/EV2/EV3) | Type4 | Yes | Yes | Yes | ISO-DEP |
| MIFARE DESFire Light | Type4 | Yes | Yes | Yes | NDEF is not supported yet |
- *1 I2C version: MIFARE Plus SL3 operation has issues, SL2 can not R/W.
| PICC Type | NFC Forum Tag (NDEF) | Detect | Identify | Raw R/W | Notes |
|---|---|---|---|---|---|
| Unclassified | None | Yes | Partial | Yes | ISO-DEP transport only |
| PICC Type | NFC Forum Tag (NDEF) | Detect | Identify | Raw R/W | Notes |
|---|---|---|---|---|---|
| FeliCa Standard | Type3 | Yes | Yes | Yes | |
| FeliCa Lite | Type3 | Yes | Yes | Yes | |
| FeliCa Lite-S | Type3 | Yes | Yes | Yes |
| PICC Type | NFC Forum Tag (NDEF) | Detect | Identify | Raw R/W | Notes |
|---|---|---|---|---|---|
| ICODE SLI | Type5 | Yes | Yes | Yes | |
| ICODE SLIX | Type5 | Yes | Yes | Yes | |
| ICODE SLIX2 | Type5 | Yes | Yes | Yes | |
| Tag-it 2048 | Type5 | Yes | Yes | Yes | |
| Tag-it HF-I Standard | Type5 | Yes | Yes | Yes | |
| Tag-it HF-I Plus | Type5 | Yes | Yes | Yes | |
| Tag-it HF-I Pro | Type5 | Yes | Yes | Yes | |
| ST25DV | Type5 | Yes | Yes | Yes |
Emulation is supported for NFC-A and NFC-F only.
See examples: NFCA Emulation and NFCF Emulation
- I2C version: MIFARE Plus SL3 operation has issues.
GROVE port (port_b) on NessoN1 uses SoftwareI2C (M5HAL Bus), which causes I2C register polling latency too high for ST25R3916 RF timing requirements.
Use QWIIC port (port_a) with a QWIIC-GROVE conversion cable instead.
Note: GROVE port support may be added in a future update if SoftwareI2C performance improves.
Each layer takes a chip adapter, so a reader IC this library does not know about can be driven without editing the library. Implement the nested Adapter of the layer you need (NFCLayerA, NFCLayerB, NFCLayerF, NFCLayerV, EmulationLayerA or EmulationLayerF) and hand it to the constructor that takes a std::unique_ptr<Adapter>. See the Doxygen pages for the methods each one requires.
See also examples/UnitUnified
Each example contains the following block to select the unit (ViaPaHub offers only two of these):
// For UnitNFC (U216)
// #define USING_UNIT_NFC
// For CapCC1101 (U219)
// #define USING_CAP_CC1101
// For UnitRFID2 (U031-B)
// #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (K130)
// #define USING_M5DIAL_BUILTIN_WS1850SUncomment one of USING_UNIT_NFC, USING_CAP_CC1101 (or USING_UNIT_RFID2 / USING_M5DIAL_BUILTIN_WS1850S, which do NFC-A/B Detect only):
// For UnitNFC (U216)
#define USING_UNIT_NFC
// For CapCC1101 (U219)
// #define USING_CAP_CC1101
// For UnitRFID2 (U031-B)
// #define USING_UNIT_RFID2
// For M5Dial Builtin WS1850S (K130)
// #define USING_M5DIAL_BUILTIN_WS1850SSome NFC-A examples are shared with M5Unit-RFID, which is why other unit definitions may exist.
NOTE: The ESP-IDF native build (
idf.py) targets ESP-IDF 5.1 or later (5.x and 6.x). ESP32-P4 requires 5.3 or later, and ESP32-C5 requires 5.5 or later.
On ESP-IDF native builds (idf.py), the unit/board is selected via Kconfig instead of editing the source #define. Each example exposes the same choice through main/Kconfig.projbuild, which sources one of the family-specific Kconfig files in examples/UnitUnified/common/:
| Kconfig file | Variants offered | Used by |
|---|---|---|
Kconfig.variant.full |
UnitNFC / CapCC1101NFC / UnitRFID2 / M5Dial built-in WS1850S | NFC-A Detect / Dump / NDEF / PolicyOverride / ReadWrite / ValueBlock |
Kconfig.variant.no_dial |
UnitNFC / CapCC1101NFC / UnitRFID2 | NFC-B Detect / JapanIDCard (M5Dial built-in cannot do NFC-B) |
Kconfig.variant.basic |
UnitNFC / CapCC1101NFC | NFC-A Emulation / all NFC-F / all NFC-V (only ST25R3916-based units supported) |
Kconfig.variant.i2c_hub |
UnitNFC / UnitRFID2 | ViaPaHub (CapCC1101NFC is SPI and the M5Dial built-in sits on the internal I2C bus, so a PaHub can reach neither) |
examples/UnitUnified/common/variant.cmake then maps the chosen CONFIG_EXAMPLE_USING_* to the source-level USING_* macro shared with the Arduino build, so the example source itself does not need to be edited.
Pick the variant with menuconfig:
cd examples/UnitUnified/NFCA/Detect # or any example
idf.py set-target esp32s3 # or esp32 / esp32c6 / esp32p4 / ...
idf.py menuconfig
# -> M5Unit-NFC example -> Target unit / board -> choose ONE of the options offered
idf.py build flash monitorSupport via PaHub
| Unit | Support | Note |
|---|---|---|
| UnitNFC | OK |
See also the ViaPaHub example (UnitNFC, every NFC family) and M5Unit-HUB
If you want to generate documents on your local machine, execute the following command
bash docs/doxy.sh
It will output it under docs/html
If you want to output Git commit hashes to html, do it for the git cloned folder.