Project Overview
Arduino MFRC522 RFID Access Control: Build a simple RFID-based security access system with an Arduino Uno and the MFRC522 (RC522) RFID reader module that reads tag UIDs and grants or denies access.
RFID (Radio-Frequency Identification) uses electromagnetic fields to wirelessly identify tagged objects over short distances, making it useful for door locks, access control, and authentication projects.
- Time: 30 minutes to 1 hour
- Skill level: Beginner
- What you will build: An RFID access control system that reads tag UIDs and grants or denies access based on a pre-programmed card.
Parts List
From ShillehTek
- RC522 RFID Reader Writer Module 13.56MHz SPI Kit for Arduino, Raspberry Pi & ESP32 - the RFID reader module used in this project (includes tags)
- 120pcs 20cm Dupont Jumper Wires - for connecting the RFID module to the Arduino
- 400-Point Small Solderless Breadboard - optional, for prototyping the circuit
External
- Arduino Uno R3 (or compatible Uno-form-factor board) - ShillehTek does not sell Arduino boards; use any standard Uno for this tutorial
- USB cable - to program the Arduino and provide power
- Computer with Arduino IDE installed
Note: The MFRC522 module operates at 3.3V. Make sure you connect it to the Arduino's 3.3V pin, not the 5V pin, to avoid damaging the module.
Step-by-Step Guide
Step 1 - Understanding RFID technology
Goal: Learn the basics of how RFID works and what components make up an RFID system.
What to do: An RFID system consists of two main parts: tags (transponders) and a reader (transceiver). Each tag contains a tiny chip with a unique identification number called a UID. When you bring a tag close to the reader, the reader emits a radio signal that powers the tag and reads its UID, with no batteries required in the tag.
Common applications include building access cards, inventory tracking, contactless payments, and pet identification microchips. In this project, you will use the MFRC522 reader module which operates at 13.56MHz and communicates with the Arduino over SPI.
Key specifications of the MFRC522 module:
- Operating voltage: 3.3V
- Frequency: 13.56MHz
- Interface: SPI
- Read range: approximately 5cm
Expected result: You understand how RFID works and what the MFRC522 module does.
Step 2 - Wire the MFRC522 to the Arduino
Goal: Connect the RFID reader to your Arduino Uno using the correct SPI pins.
What to do: Wire the MFRC522 module to your Arduino Uno using this pin mapping:
- SDA - Digital Pin 10
- SCK - Digital Pin 13
- MOSI - Digital Pin 11
- MISO - Digital Pin 12
- IRQ - Not connected
- GND - GND
- RST - Digital Pin 9
- 3.3V - 3.3V
Expected result: The MFRC522 module is wired to your Arduino and ready for programming.
Step 3 - Install the MFRC522 library and read tag data
Goal: Install the required library and use the DumpInfo example to read your RFID tag's UID and stored data.
What to do: Download and install the MFRC522 library by miguelbalboa. You can find it in the Arduino Library Manager by searching for "MFRC522", or download it from GitHub. After installation, restart your Arduino IDE.
Open the built-in example sketch: File > Examples > MFRC522 > DumpInfo. Upload it to your Arduino and open the Serial Monitor at 9600 baud. Hold your RFID tag near the reader and keep it close until all the data is displayed.
The output displays the card's UID and its full memory contents divided into 16 sectors, each protected by two keys (A and B). Write down the UID; you will need it in the next step to program the access control logic.
Expected result: You can see your RFID tag's UID and memory contents in the Serial Monitor.
Step 4 - Build the access control sketch
Goal: Write and upload a sketch that grants or denies access based on the scanned tag's UID.
What to do: Create a new sketch in the Arduino IDE and paste the code below. It reads the UID from a presented tag and compares it against a pre-authorized UID. If it matches, access is granted. Otherwise, access is denied.
Code:
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup()
{
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
Serial.println("Approximate your card to the reader...");
Serial.println();
}
void loop()
{
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
Serial.print("UID tag :");
String content = "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "BD 31 15 2B") // Replace with YOUR tag UID
{
Serial.println("Authorized access");
Serial.println();
delay(3000);
}
else
{
Serial.println("Access denied");
delay(3000);
}
}
Before uploading, replace the UID string "BD 31 15 2B" with the UID you recorded from your tag in Step 3. Keep the format with spaces between each hex byte pair and use uppercase letters.
Expected result: The sketch compiles and uploads successfully to your Arduino.
Step 5 - Test the access control system
Goal: Verify that your system correctly identifies authorized and unauthorized tags.
What to do: Open the Serial Monitor at 9600 baud after uploading the sketch. Present the authorized RFID tag (the one whose UID you programmed in the code) to the reader. You should see the "Authorized access" message.
Now scan a different tag that does not match the UID in your code. The system should display the "Access denied" message.
Expected result: Your authorized tag triggers "Authorized access", and any other tag shows "Access denied".
Conclusion
You built an RFID-based access control system using an Arduino Uno and the MFRC522 (RC522) reader module. You wired the module over SPI, read tag data using the DumpInfo example, and wrote a sketch that grants or denies access based on a tag UID.
Photo credit: Images in this tutorial are credited to Random Nerd Tutorials.
Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.


