Read RFID card Data using ESP32 board and RFID-RC522

ESP32 10-03-25
374 0

Tutorial plan

1- Purpose of the tutorial

2- RFID-RC522 module and RFID card

3- Connecting ESP32 board with RFID-RC522 module

4- Micropython code to Read RFID Card and Display on LCD

 

 

Purpose of the tutorial

This guide explains how to read RFID card data using an ESP32 board, an RFID-RC522 module, and display the results on an LCD I2C screen. This setup is useful for applications like access control, attendance tracking, and authentication systems.

How RFID Works with ESP32 ?

1- The RFID-RC522 module generates an electromagnetic field.

2- When an RFID tag/card comes close to the reader, it is activated and transmits its UID (Unique Identifier).

3- The ESP32 reads this UID through the SPI communication protocol.

4- The UID is displayed on LCDI2C screen.

 

RFID-RC522 module and RFID card

1) RFID-RC522 module

The RFID-RC522 module is a Radio Frequency Identification (RFID) reader based on the MFRC522 chip. It is commonly used for wireless identification, access control, attendance systems, and IoT applications.

a) How RFID Works?

1- The RC522 reader generates an electromagnetic field.

2- When an RFID tag or card enters the field, it gets powered wirelessly.

3- The tag/card sends back a Unique Identifier (UID).

4- The RC522 reads the UID and sends it to the microcontroller (ESP32, Arduino, etc.).

5- The microcontroller processes the UID for authentication, logging, or triggering actions.

b) Applications of RFID-RC522

- Access Control Systems (RFID-based door locks)

- Attendance & Time Tracking (Schools, offices, parking lots)

- IoT Authentication (Smart home & cloud-based security)

- Cashless Payment Systems (MIFARE cards in public transport)

- Inventory Management (Warehouse and asset tracking)

2) RFID card

The RFID-RC522 module operates at 13.56 MHz and supports ISO/IEC 14443A standard RFID cards. Below are the common types of RFID cards and tags that can be used with the RC522 module:

a- RFID badge :

An RFID badge is a wireless identification card embedded with an RFID chip and antenna, used for authentication, tracking, and security applications. These badges operate at different frequencies and come in various types, depending on security and storage requirements.

b- RFID white card

An RFID white card is a standard contactless smart card that contains an embedded RFID chip and antenna. It is often blank (white), meaning it has no printed design, making it ideal for customization (printing logos, barcodes, or user details).

c- How RFID Badges and cards Work ?

1- The RFID badge contains a unique ID (UID) stored in its embedded chip.

2- When placed near an RFID reader (e.g., RFID-RC522 module), the badge is wirelessly powered by the reader's electromagnetic field.

3- The badge transmits its UID (and possibly additional data) to the reader.

4- The reader sends this data to a microcontroller (ESP32, Arduino, etc.) for verification and processing.

5- If the badge is authorized, it can trigger an action, such as unlocking a door, logging attendance, or granting access to a system.

 

Connecting ESP32 board with RFID-RC522 module and LCD I2C display

RFID-RC522 to ESP32 Connections

RFID-RC522 Pin

ESP32 Pi

VCC

3V3

RST

GPIO 2

GND

GND

MISO

GPIO 19

MOSI

GPIO 23

SCK

GPIO 18

SDA (SS)

GPIO 5

I2C LCD to ESP32 Connections

LCD I2C Pin

ESP32 pin

VCC

5 volt

GND

GND

SDA

GPIO 21

SCL

GPIO 22

 

Micropython code to Read RFID Card and Display on LCD

Before running the code, install the necessary libraries:

- MFRC522 (for RFID module)

- i2c_lcd and lcd_api for I2C LCD screen

How the Micropython code works ?

SPI Communication: The ESP32 uses the SPI protocol to communicate with the RFID-RC522 module. We set up the SPI pins using the Pin class from the machine module.

I2C Communication: The LCD is connected to the ESP32 using the I2C protocol. The lcd_api library handles I2C communication for displaying text on the LCD.

Reading RFID Card:

- The rfid.request() method checks for the presence of an RFID card.

- The rfid.anticoll() method reads the UID of the card.

- The UID is displayed on both the Serial Monitor and the LCD screen.

Looping for Card Scans:

The program continuously checks for the presence of an RFID card. When a card is detected, it reads the UID and displays it on the LCD. It waits for 5 seconds before checking for another card.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info