A smart door lock with RFID is one of the most practical security projects you can build with Arduino. Instead of fumbling with keys, you simply tap your RFID card or keychain tag on the reader, and the door unlocks automatically. This guide shows you how to build a complete RFID-based access control system with Arduino, supporting multiple authorised cards, an audit log, and a solenoid or servo-based lock mechanism — all for under ₹1,500.
Whether you want to secure your bedroom door, office cabin, or workshop, this project is perfect for Indian homes and small businesses.
How RFID Access Control Works
RFID (Radio Frequency Identification) uses electromagnetic fields to identify objects carrying RFID tags. In our door lock system:
- The RFID reader (RC522) continuously emits a low-power radio signal
- When an RFID card or keychain tag comes within 3–5 cm, the tag’s antenna picks up energy from the reader’s signal
- The tag transmits its unique ID number back to the reader
- The Arduino compares this ID against a list of authorised IDs
- If the ID matches, the Arduino activates the solenoid lock for a few seconds, allowing the door to be opened
The entire process takes less than half a second — faster than pulling out a key from your pocket.
Components Required
| Component | Qty | Price (₹) |
|---|---|---|
| Arduino Uno / Nano | 1 | 250–400 |
| RC522 RFID Module + cards | 1 | 120–180 |
| 12V Solenoid Lock | 1 | 200–350 |
| 1-Channel 5V Relay | 1 | 35–60 |
| 12V Power Supply | 1 | 100–200 |
| Buzzer + LED | 1 each | 20–30 |
| Wires, breadboard | – | 50–80 |
| Total | – | ₹775–₹1,300 |
Wiring Diagram
RC522 RFID Module to Arduino
RC522 SDA → Arduino Pin 10
RC522 SCK → Arduino Pin 13
RC522 MOSI → Arduino Pin 11
RC522 MISO → Arduino Pin 12
RC522 IRQ → Not connected
RC522 GND → Arduino GND
RC522 RST → Arduino Pin 9
RC522 3.3V → Arduino 3.3V (NOT 5V!)
Solenoid Lock Circuit
Arduino Pin 7 → Relay IN
Arduino 5V → Relay VCC
Arduino GND → Relay GND
12V Supply (+) → Relay COM
Relay NO → Solenoid (+)
Solenoid (-) → 12V Supply (-)
Indicators
Arduino Pin 6 → Green LED (via 220Ω resistor) → GND [Access Granted]
Arduino Pin 5 → Red LED (via 220Ω resistor) → GND [Access Denied]
Arduino Pin 4 → Buzzer (+), Buzzer (-) → GND
Arduino Code with Multiple Card Support
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
#define RELAY_PIN 7
#define GREEN_LED 6
#define RED_LED 5
#define BUZZER 4
#define LOCK_TIME 5000 // Door stays unlocked for 5 seconds
MFRC522 rfid(SS_PIN, RST_PIN);
// Authorised card UIDs (add your card UIDs here)
// To find your card UID, upload this code first with an empty array,
// open Serial Monitor, and scan your card
byte authorisedCards[][4] = {
{0xA1, 0xB2, 0xC3, 0xD4}, // Card 1 - Jayesh
{0xE5, 0xF6, 0x07, 0x18}, // Card 2 - Family Member
{0x29, 0x3A, 0x4B, 0x5C}, // Card 3 - Guest
};
int numCards = sizeof(authorisedCards) / sizeof(authorisedCards[0]);
void setup() {
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
pinMode(RELAY_PIN, OUTPUT);
pinMode(GREEN_LED, OUTPUT);
pinMode(RED_LED, OUTPUT);
pinMode(BUZZER, OUTPUT);
digitalWrite(RELAY_PIN, HIGH); // Lock engaged
digitalWrite(RED_LED, HIGH); // Red LED on = locked
Serial.println("=== RFID Door Lock System ===");
Serial.println("Scan your card...");
}
void loop() {
// Check for new card
if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
return;
}
// Print card UID
Serial.print("Card UID: ");
for (byte i = 0; i < rfid.uid.size; i++) {
Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(rfid.uid.uidByte[i], HEX);
}
Serial.println();
// Check if card is authorised
if (isAuthorised(rfid.uid.uidByte, rfid.uid.size)) {
grantAccess();
} else {
denyAccess();
}
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
}
bool isAuthorised(byte *uid, byte uidSize) {
for (int i = 0; i < numCards; i++) {
bool match = true;
for (byte j = 0; j < uidSize && 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(GREEN_LED, HIGH);
digitalWrite(RED_LED, LOW);
// Two short beeps for access granted
tone(BUZZER, 2000, 100);
delay(150);
tone(BUZZER, 2500, 100);
// Unlock door
digitalWrite(RELAY_PIN, LOW);
delay(LOCK_TIME);
// Re-lock door
digitalWrite(RELAY_PIN, HIGH);
digitalWrite(GREEN_LED, LOW);
digitalWrite(RED_LED, HIGH);
Serial.println("Door locked again");
}
void denyAccess() {
Serial.println("ACCESS DENIED");
// Three long beeps for access denied
for (int i = 0; i < 3; i++) {
tone(BUZZER, 500, 300);
digitalWrite(RED_LED, LOW);
delay(200);
digitalWrite(RED_LED, HIGH);
delay(200);
}
}
Adding an LCD Display
Adding a 16×2 LCD display makes the system more user-friendly by showing messages like “Scan Card”, “Access Granted”, or “Access Denied” along with the card holder’s name.
LCD Code Addition
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// Add names for each card
String cardNames[] = {"Jayesh", "Priya", "Guest"};
void showMessage(String line1, String line2) {
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 10);
display.println(line1);
display.setTextSize(1);
display.setCursor(0, 40);
display.println(line2);
display.display();
}
// In grantAccess(), add:
// showMessage("Welcome!", cardNames[cardIndex]);
// In denyAccess(), add:
// showMessage("DENIED!", "Unknown card");
Solenoid Lock vs Servo Lock
You have two options for the physical locking mechanism:
Solenoid Lock (Recommended for Doors)
- Pros: Strong holding force, fail-secure (locks when power is off), professional look
- Cons: Requires 12V power supply, draws 0.5–1.7A when activated
- Best for: Main doors, office doors, cabinets
- Price: ₹200–₹500
Servo Motor Lock (Good for Cabinets)
- Pros: Runs on 5V (no extra power supply), quiet operation, low cost
- Cons: Lower holding force, requires mechanical adaptation
- Best for: Drawers, small cabinets, letter boxes
- Price: ₹80–₹150 for SG90 servo
Adding Security Features
A basic RFID lock is functional, but adding these security features makes it robust enough for real-world use:
1. Brute-Force Protection
After 5 consecutive failed attempts, lock the system for 5 minutes:
int failedAttempts = 0;
unsigned long lockoutUntil = 0;
// In loop():
if (millis() = 5) {
lockoutUntil = millis() + 300000; // 5 minutes
failedAttempts = 0;
// Sound alarm
}
2. Access Logging
Log every access attempt (successful and failed) with timestamps to an SD card or EEPROM for audit purposes.
3. Master Card
Designate one card as the “master card” that can add or remove other cards from the authorised list without reprogramming the Arduino.
4. Emergency Override
Add a hidden push button inside the room for emergency exit even if the system malfunctions.
Frequently Asked Questions
Can someone clone my RFID card?
Basic 13.56MHz MIFARE Classic cards (used with RC522) can be cloned with specialised equipment. For higher security, use MIFARE DESFire or NFC-based cards that have encryption. For home use, the basic MIFARE cards are generally sufficient.
What happens during a power cut?
With a solenoid lock, the door remains locked during power cuts (fail-secure). Add a backup battery (12V lead-acid or lithium) with a charging circuit for uninterrupted operation. Alternatively, install a manual key lock as backup.
Can I use this with a wooden door?
Yes. Mount the solenoid lock on the door frame, and the latch mechanism on the door. Most 12V solenoid locks come with mounting screws suitable for both wooden and metal frames.
How far away can the card be read?
The RC522 module reads cards at 3–5 cm distance. This is intentional for security — it prevents accidental or unauthorised reads from a distance.
Can I add a keypad as backup?
Yes. Add a 4×4 matrix keypad and implement a PIN code alongside RFID. This gives dual authentication or a fallback when you forget your card.
Conclusion
An RFID-based smart door lock is a practical, affordable security upgrade for any Indian home or office. At under ₹1,500 in total component cost, it offers keyless convenience with features that rival commercial smart locks costing ₹5,000–₹15,000. The Arduino platform makes it endlessly customisable — add WiFi logging, fingerprint sensors, or integrate it with your smart home system as your needs grow.
Start building your RFID access control system today with components from Zbotic.in. Browse our RFID modules, Arduino boards, and solenoid locks — all with fast delivery across India.
Add comment