The RFID module RC522 Arduino combination is the starting point for thousands of access control, attendance, and inventory tracking projects across India. From college attendance systems in Chennai to warehouse inventory management in Ahmedabad, RFID technology offers contactless identification at affordable prices. This guide compares the RC522, PN532, and long-range UHF readers, and shows you how to build practical RFID applications with Arduino.
Table of Contents
- RFID Technology Basics
- RC522 vs PN532 vs UHF: Which to Choose
- Wiring RC522 to Arduino
- Reading RFID Cards and Tags
- Project: Door Access Control System
- Project: Automated Attendance System
- NFC Features with PN532
- Frequently Asked Questions
RFID Technology Basics
RFID (Radio-Frequency Identification) uses electromagnetic fields to automatically identify tagged objects. An RFID system has two components:
- Reader (Interrogator): Emits radio waves and reads data from tags. Connected to your Arduino.
- Tag (Transponder): A small chip with an antenna. Can be a card, keychain fob, sticker, or implanted in products.
RFID operates at different frequencies with different capabilities:
| Frequency | Band | Range | Use Cases |
|---|---|---|---|
| 125 kHz | LF (Low Frequency) | 1-10 cm | Simple access control, animal tagging |
| 13.56 MHz | HF (High Frequency) | 1-10 cm | Smart cards, NFC, payments, attendance |
| 860-960 MHz | UHF (Ultra High Frequency) | 1-12 m | Inventory, supply chain, vehicle toll |
RC522 vs PN532 vs UHF: Which to Choose
| Feature | RC522 (MFRC522) | PN532 | UHF Reader |
|---|---|---|---|
| Frequency | 13.56 MHz | 13.56 MHz | 860-960 MHz |
| Read Range | 2-5 cm | 3-7 cm | 1-12 metres |
| NFC Support | Partial (read UID only) | Full NFC (P2P, card emulation) | No |
| Interface | SPI | SPI, I2C, UART | UART, Wiegand |
| Card Types | MIFARE Classic, Ultralight | MIFARE, NTAG, FeliCa, ISO14443 | EPC Gen2 / ISO18000-6C |
| Price (approx) | ₹80-150 | ₹350-600 | ₹2,000-15,000 |
| Best For | Budget projects, learning | NFC, phone interaction | Inventory, long range |
Our recommendation: Start with the RC522 for access control and attendance projects. Upgrade to PN532 if you need to interact with NFC-enabled smartphones or support more card types. Use UHF readers for warehouse inventory or vehicle tracking where long range is essential.
Wiring RC522 to Arduino
| RC522 Pin | Arduino Uno | ESP32 |
|---|---|---|
| SDA (SS) | D10 | GPIO 5 |
| SCK | D13 | GPIO 18 |
| MOSI | D11 | GPIO 23 |
| MISO | D12 | GPIO 19 |
| IRQ | Not connected | Not connected |
| RST | D9 | GPIO 27 |
| 3.3V | 3.3V | 3.3V |
| GND | GND | GND |
Important: The RC522 operates at 3.3V. While most breakout boards tolerate 5V on the SPI lines, always power VCC from the 3.3V rail.
Reading RFID Cards and Tags
Install the MFRC522 library by GithubCommunity from the Arduino Library Manager. Here is the basic card reading code:
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 rfid(SS_PIN, RST_PIN);
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
Serial.println("RFID Reader Ready - Zbotic.in");
Serial.println("Place your card near the reader...");
}
void loop() {
// Check for new card
if (!rfid.PICC_IsNewCardPresent()) return;
if (!rfid.PICC_ReadCardSerial()) return;
// Print UID
Serial.print("Card UID: ");
for (byte i = 0; i < rfid.uid.size; i++) {
if (rfid.uid.uidByte[i] < 0x10) Serial.print("0");
Serial.print(rfid.uid.uidByte[i], HEX);
if (i < rfid.uid.size - 1) Serial.print(":");
}
Serial.println();
// Print card type
MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
Serial.print("Card type: ");
Serial.println(rfid.PICC_GetTypeName(piccType));
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
delay(1000);
}
Project: Door Access Control System
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
#define RELAY_PIN 7
#define BUZZER_PIN 6
#define LED_GREEN 5
#define LED_RED 4
MFRC522 rfid(SS_PIN, RST_PIN);
// Authorised card UIDs (add your card UIDs here)
byte authorisedCards[][4] = {
{0xA3, 0xB2, 0xC1, 0xD0}, // Card 1 - Jayesh
{0x12, 0x34, 0x56, 0x78}, // Card 2 - Visitor
{0xAB, 0xCD, 0xEF, 0x01}, // Card 3 - Staff
};
int numCards = 3;
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
pinMode(RELAY_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_RED, OUTPUT);
digitalWrite(RELAY_PIN, LOW);
digitalWrite(LED_RED, HIGH); // Red = locked
Serial.println("Door Access Control System Ready");
}
void loop() {
if (!rfid.PICC_IsNewCardPresent()) return;
if (!rfid.PICC_ReadCardSerial()) return;
if (isAuthorised(rfid.uid.uidByte)) {
grantAccess();
} else {
denyAccess();
}
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
}
bool isAuthorised(byte* uid) {
for (int i = 0; i < numCards; i++) {
bool match = true;
for (int j = 0; j < 4; j++) {
if (uid[j] != authorisedCards[i][j]) {
match = false;
break;
}
}
if (match) return true;
}
return false;
}
void grantAccess() {
Serial.println("ACCESS GRANTED");
digitalWrite(LED_GREEN, HIGH);
digitalWrite(LED_RED, LOW);
digitalWrite(RELAY_PIN, HIGH); // Unlock door
tone(BUZZER_PIN, 2000, 200); // Short beep
delay(3000); // Keep unlocked 3 seconds
digitalWrite(RELAY_PIN, LOW);
digitalWrite(LED_GREEN, LOW);
digitalWrite(LED_RED, HIGH);
}
void denyAccess() {
Serial.println("ACCESS DENIED");
for (int i = 0; i < 3; i++) { // 3 error beeps
tone(BUZZER_PIN, 500, 200);
delay(300);
}
}
Project: Automated Attendance System
Combine the RC522 with an RTC (Real Time Clock) module and SD card for a standalone attendance logger:
#include <SPI.h>
#include <MFRC522.h>
#include <SD.h>
#include <Wire.h>
#include <RTClib.h>
MFRC522 rfid(10, 9);
RTC_DS3231 rtc;
// Student database
struct Student {
byte uid[4];
const char* name;
const char* rollNo;
};
Student students[] = {
{{0xA3, 0xB2, 0xC1, 0xD0}, "Rahul Sharma", "CS101"},
{{0x12, 0x34, 0x56, 0x78}, "Priya Patel", "CS102"},
{{0xAB, 0xCD, 0xEF, 0x01}, "Amit Kumar", "CS103"},
};
int numStudents = 3;
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
rtc.begin();
SD.begin(4); // CS pin for SD card
Serial.println("Attendance System Ready");
}
void loop() {
if (!rfid.PICC_IsNewCardPresent()) return;
if (!rfid.PICC_ReadCardSerial()) return;
int studentIndex = findStudent(rfid.uid.uidByte);
if (studentIndex >= 0) {
DateTime now = rtc.now();
// Log to SD card
File logFile = SD.open("attend.csv", FILE_WRITE);
if (logFile) {
logFile.print(students[studentIndex].rollNo);
logFile.print(",");
logFile.print(students[studentIndex].name);
logFile.print(",");
logFile.printf("%02d/%02d/%04d", now.day(), now.month(), now.year());
logFile.print(",");
logFile.printf("%02d:%02d:%02d", now.hour(), now.minute(), now.second());
logFile.println();
logFile.close();
}
Serial.printf("%s (%s) marked present at %02d:%02dn",
students[studentIndex].name,
students[studentIndex].rollNo,
now.hour(), now.minute());
tone(6, 2000, 200); // Confirmation beep
} else {
Serial.println("Unknown card!");
tone(6, 500, 500); // Error beep
}
rfid.PICC_HaltA();
delay(2000); // Prevent double tap
}
int findStudent(byte* uid) {
for (int i = 0; i < numStudents; i++) {
bool match = true;
for (int j = 0; j < 4; j++) {
if (uid[j] != students[i].uid[j]) { match = false; break; }
}
if (match) return i;
}
return -1;
}
NFC Features with PN532
The PN532 goes beyond simple RFID reading — it supports full NFC functionality:
- Card emulation: The PN532 can emulate an NFC tag, allowing an Android phone to read data from your Arduino
- Peer-to-peer: Exchange data between the PN532 and an NFC-enabled smartphone
- Read/Write NTAG: Write custom data (URLs, contact info, WiFi credentials) to NFC stickers
- Multiple protocols: ISO14443A/B, FeliCa, and ISO18092 support
The PN532 module supports SPI, I2C, and UART interfaces. Use I2C for the simplest wiring (just SDA and SCL) or UART for the most reliable communication.
Frequently Asked Questions
Can RC522 read my metro card or credit card?
The RC522 can detect and read the UID of MIFARE-based metro cards (Delhi Metro, Mumbai Metro). However, it cannot read the encrypted data on these cards. Credit/debit cards use different protocols and security — the RC522 can detect them but cannot read payment data.
What is the maximum read range of RC522?
The RC522 reads cards at 2-5 cm distance. This is by design — short range prevents accidental reads. For longer range (1-12 metres), you need UHF RFID readers which are significantly more expensive.
Can I write data to RFID cards?
Yes. MIFARE Classic cards have 1K or 4K of writable memory divided into sectors. You can write names, IDs, balance values, or any data using the MFRC522 library’s write functions. Each sector is protected by a key (default: FFFFFFFFFFFF).
How many cards can I store in Arduino?
An Arduino Uno has 2K SRAM and 32K flash. You can store approximately 500 card UIDs (4 bytes each) in flash using PROGMEM. For larger databases, use an SD card or ESP32 with SPIFFS/LittleFS filesystem.
Is RC522 waterproof for outdoor use?
No. The RC522 module is not weatherproof. For outdoor access control in Indian weather conditions, mount the module inside a waterproof enclosure (IP65 or higher) with the card reading area behind a thin non-metallic window.
Conclusion
RFID technology with the RC522 module offers an incredibly affordable entry point into contactless identification projects. At under ₹150 per module, you can build access control systems, attendance trackers, and inventory management solutions that would cost tens of thousands of rupees commercially. For more advanced NFC features and smartphone interaction, upgrade to the PN532. For long-range inventory scanning, step up to UHF RFID.
Start your RFID project today. Browse our collection of RFID modules, cards, and tags at Zbotic.in for the best prices and fast delivery across India.
Add comment