Translate

Arduino RFID Door Lock System using RC522 Module

 1. Introduction

Prototype

This project explains how to build an Arduino RFID door lock system using the RC522 module. The door unlocks only when an authorized RFID card is detected.


2. Components

  • Arduino Nano / Uno
  • RFID Module (RC522)
  • RFID Card / Tag
  • Servo Motor (SG90)
  • Jumper wires
  • Breadboard
Note: instead of servo motor you can use relay and solenoid lock, can use display for seeing the status of lock

3. Circuit and Connections

Arduino Nano Pinout Diagram

PInout Diagram RC522 RFID Module


Pinout Diagram of SG90 Servo Motor

RFID RC522 Connections (SPI):
SDA → D10
SCK → D13
MOSI → D11
MISO → D12
IRQ → Not connected
GND → GND
RST → D9
3.3V → 3.3V

⚠️ Do NOT connect to 5V

Servo Motor:
VCC → 5V
GND → GND
Signal → D6


4. Circuit Working

When an RFID card is brought near the sensor, the module reads its unique ID (UID).

  • If UID matches stored ID → Servo unlocks
  • If not → No action

After a delay, the door locks again.


5. Code

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

#define SS_PIN 10
#define RST_PIN 9

MFRC522 mfrc522(SS_PIN, RST_PIN);
Servo myServo;

String tagUID = "A1 B2 C3 D4"; // Change this

void setup() {
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();

myServo.attach(6);
myServo.write(0);
}

void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) return;
if ( ! mfrc522.PICC_ReadCardSerial()) return;

String content = "";

for (byte i = 0; i < mfrc522.uid.size; i++) {
content += String(mfrc522.uid.uidByte[i], HEX);
content += " ";
}

content.toUpperCase();

if (content.substring(1) == tagUID) {
myServo.write(90);
delay(3000);
myServo.write(0);
}
}

6. Code Working

  • RFID module scans card UID
  • UID is converted to string
  • Compared with stored UID
  • If matched → Servo rotates
  • Else → Access denied

7. Tips

  • Use 3.3V only for RC522 ⚠️
  • Print UID using Serial Monitor before coding
  • Use external power for servo if unstable
  • Keep RFID wires short

8. Uses

  • RFID door lock systems
  • Attendance systems
  • Access control
  • Smart security systems

9. Conclusion

This project demonstrates a simple RFID-based security system using Arduino. It is widely used in real-world access control applications. 

തുടക്കക്കാർക്കായി ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.