ESP32 and RFID-RC522 module example

In this example we will connect an RFID-RC522 module and connect to an ESP32 Wemos LOLIN32

The microcontroller and card reader uses SPI for communication . The card reader and the tags communicate using a 13.56MHz electromagnetic field. (ISO 14443A standart tags)


  • MFRC522 chip based board
  • Operating frequency: 13.56MHz
  • Supply Voltage: 3.3V
  • Current: 13-26mA
  • Read Range: Approx 3cm with supplied card and fob
  • SPI Interface
  • Max Data Transfer Rate: 10Mbit / s
  • Dimensions: 60mm × 39mm

Datasheet for the chip that used in modules can be found at:


esp32 and rfid
esp32 and rfid


Install the RFID522 library –

This is the DumpInfo example modified

#include <SPI.h>
#include <MFRC522.h>

//#define RST_PIN 9 // Configurable, see typical pin layout above
//#define SS_PIN 10 // Configurable, see typical pin layout above
const int RST_PIN = 22; // Reset pin
const int SS_PIN = 21; // Slave select pin

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));

void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {

// Dump debug info about the card; PICC_HaltA() is automatically called



This is the output in the serial monitor

serial monitor info mfrc522
serial monitor info mfrc522

There are many other good examples in the library



1 set RFID module RC522 Kits S50 13.56 Mhz 6cm With Tags SPI Write & Read for arduino uno 2560

Previous articleESP32 and Soil Moisture Sensor example
Next articleESP32 and AM2301 sensor example