sorry we are not native speakers, so the content may not be clear. We just want to share with you!
Currently, applications with RFID are no longer strange to us, with a huge open source code like Arduino, STM, … the approach to the RFID RC522 module becomes extremely easy. However, the library resources used on the ESP32 ESP-IDF are currently quite limited, so today I would like to introduce a library for the ESP32 to communicate with the RC522 RFID using the library I wrote on the ESP-IDF.
We are so familiar with the ESP8266 wifi module, not only for the environment of students, but also for commercial projects, such as: SONOFF .. the big names of the community. SMART DEVICE. So what is the next choice after ESP8266 ? The answer from the manufacturer of the ESP (espressif.com) is: “ESP32”.
Terrible configuration, increased functionality, increased number of I/O pins, more sensors, reasonable price… is what ESP32 brings.
- CPU: Xtensa Dual-Core LX6 microprocessor.
- Run 32 bit system
- Processing speed 160MHZ up to 240MHz
- Flash chip read clock speed 40mhz –> 80mhz (customizable when programming)
- RAM: 520 KByte SRAM
- 520 KB of on-chip SRAM –(of which 8 KB of high speed RTC RAM – 8 KB of low speed RTC RAM (used in DeepSleep mode).
- Wi-Fi: 802.11 b/g/n/e/i
- Bluetooth: v4.2 BR/EDR and BLE
- 8-bit DACs (digital to analog) 2 ports
- Analog(ADC) 12-bit 16 ports.
- I²C – 2 ports
- UART – 3 ports
- SPI – 3 ports (1 port for FLASH chip)
- I²S – 2 ports
- SD card /SDIO/MMC host
- Slave (SDIO/SPI)
- Ethernet MAC interface with dedicated DMA and IEEE 1588 support
- CAN bus 2.0
- IR (TX/RX)
- PWM hash (all pins)
- Ultra low power analog pre-amplifier
There are also built-in sensors on the CHIP
- 1 Hall sensor (magnetic field sensor)
- 1 temperature sensor
- Touch sensor (capacitive) with 10 different inputs.
- There are full security modes of wireless connection, hardware, software, …
ESP-IDF is the development framework for Espressif SoCs supported on Windows, Linux and macOS.
Introduction of the RC522 RFID Module
The RFID module RC522 uses Phillip’s MFRC522 IC to read and write data for 13.56MHz NFC tags, this module is the first choice for applications on reading and writing NFC tags.
- Voltage: 3.3V;
- Current :13-26mA
- Current in standby: 1013mA
- Current at rest: <80uA
- Carrier Frequency: 13.56MHz
- Operating distance: 0 ~ 60 mm (mifare1 card)
- Supported cards: mifare1 S50, mifare1 S70, mifare UltraLight, mifare Pro, mifare Desfire
- Communication port: SPI, maximum speed 10Мbps
- Size: 40mm 60mm
- Capable of reading and writing
Practical applications of RFID
- Car park
- Cards used in supermarkets
- Attendance cards for students and staff
- Check in/out
- Identifiers for devices
ESP32 MANUAL RFID COMMUNICATION RC522 ESP-IDF LIBRARY
Connect ESP32 with Module RC522
- NodeMCU (D18) <-> RC522 (SCK)
- NodeMCU (D5) <-> RC522 (SS)
- NodeMCU (D23) <-> RC522 (MOSI)
- NodeMCU (D19) <-> RC522 (MISO)
Steps to take
2. Download example from my repo on Github RC522-ESP-IDF
Click github link and clone or download project to get code
Note: the project directory should be equal to the installed esp-idf directory
- Open ESP-IDF Command Prompt (cmd.exe) and go to rc522-esp-idf
- Build example rc522-esp-idf
- Upload code to board ESP32
idf.py flash monitor
Place your NFC tag near the Module and observe the tag’s UID shown on the screen. Above is a tutorial on using RFID RC522 to communicate with ESP32 programmed on ESP-IDF environment.