Skip to content

m5stack/M5Unit-RFID

Repository files navigation

M5Unit - RFID

Overview

Library for Unit-RFID using M5UnitUnified.
M5UnitUnified has a unified API and can control multiple units via PaHub, etc.

SKU:U031-B

Unit RFID2 is a radio frequency identification (RFID) read/write unit based on the 13.56MHz frequency band. It integrates the WS1850S chip and complies with the ISO/IEC 14443 Type A/B standard, supporting data read/write operations for RFID cards such as MIFARE and NTAG series. The unit communicates via the I2C interface and has a read/write distance of less than 20mm.

PICC Support

Raw R/W includes FileSystem via ISO-DEP when applicable.
Support may be expanded in future updates to cover PICCs not listed here.

NFC-A

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(*1)
MIFARE Plus 4K (S/X/EV1/EV2) None Yes Yes Yes SL0/SL1(*1)
MIFARE Plus SE 1K None Yes Yes Yes SL0/SL1/SL3
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 MIFARE Plus SL3 operation has issues.

NFC-B

Available on UnitRFID2 (WS1850S) only. UnitRFID (MFRC522) does NOT support NFC-B.

PICC Type NFC Forum Tag (NDEF) Detect Identify Raw R/W Notes
Unclassified None Yes Partial Yes ISO-DEP transport only

Note: NFC-B is not supported on the M5Dial builtin WS1850S. The builtin small loop antenna cannot generate sufficient RF field for Type B PICC activation (Type B uses 10% ASK + BPSK subcarrier which is more sensitive to field strength and SNR than Type A). NFC-B requires the external UnitRFID2 (with larger antenna).

Emulation

Emulation is NOT supported on UnitRFID and UnitRFID2.

Known Issues

  • MIFARE Plus SL3 operation has issues.

NessoN1 Connection

GROVE port (port_b) on NessoN1 uses SoftwareI2C (M5HAL Bus), which causes I2C register polling latency too high for MFRC522/WS1850S 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.

Related Link

Required Libraries:

License

Examples

See also examples/UnitUnified

Note: The examples in this library are imported from M5Unit-NFC and shared between both libraries. The same source file supports multiple units via #define switches.

For ArduinoIDE

Each example contains the following block to select the unit:

// For UnitNFC
// #define USING_UNIT_NFC
// For CapCC1101
// #define USING_CAP_CC1101
// For UnitRFID2 (external WS1850S)
// #define USING_UNIT_RFID2
// For M5Dial built-in WS1850S
// #define USING_M5DIAL_BUILTIN_WS1850S

The examples are shared with M5Unit-NFC, which is why other unit definitions exist.
For this library, uncomment USING_UNIT_RFID2 (external WS1850S), or USING_M5DIAL_BUILTIN_WS1850S for the M5Dial built-in WS1850S:

// #define USING_UNIT_NFC
// #define USING_CAP_CC1101
#define USING_UNIT_RFID2
// #define USING_M5DIAL_BUILTIN_WS1850S

For ESP-IDF settings

NOTE: Works with ESP-IDF 5.x (>=5.0), including the examples.
M5Unified / M5GFX (used by the examples for display output) do not yet support ESP-IDF 6.x; stay on the latest 5.x release until upstream support lands.

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 UnitRFID2 / M5Dial built-in WS1850S NFC-A Detect / Dump / NDEF / PolicyOverride / ReadWrite / ValueBlock
Kconfig.variant.no_dial UnitRFID2 NFC-B Detect / JapanIDCard (M5Dial built-in cannot do NFC-B)

For this library, choose UnitRFID2 (external WS1850S) or M5Dial built-in WS1850S. examples/UnitUnified/common/variant.cmake then maps the chosen CONFIG_EXAMPLE_USING_* to the source-level USING_* macro shared with the Arduino build.

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-RFID example -> Target unit / board -> choose ONE of the options offered
idf.py build flash monitor

The selected CONFIG_EXAMPLE_USING_* is translated into the Arduino-compatible USING_* macro at compile time, so the example source itself does not need to be edited.

Doxygen document

GitHub Pages

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.

Required

About

Library for UnitRFID using M5UnitUnified.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

Generated from m5stack/M5Template-C-CPP