Free Tutorial

RFID Based Door Access System

Beginner Difficulty
1 Est. Time
6 items Components Needed

About This Project

Traditional lock-and-key systems can be inconvenient due to lost keys, duplicate keys, and security concerns. An RFID-based access control system provides a secure, contactless, and user-friendly alternative.

This project uses an Arduino Uno, an MFRC522 RFID Reader, and a  Solenoid Lock to implement an automatic door locking system. When an RFID card is placed near the reader, the Arduino reads its UID and verifies it. I 

 

Component Quantity
Arduino Uno 1
MFRC522 RFID Reader 1
RFID Card/Tag 2
Selonoid Valve 1
Breadboard 1
Jumper Wires As Required
USB Cable 1
Power Supply 5V

 

 

Working Principle

  1. Power ON the system.
  2. RFID Reader waits for a card.
  3. User places RFID tag.
  4. RC522 reads UID.
  5. Arduino verifies UID.
  6. If valid:
    • Door Unlock
  7. After 5 seconds:
    • Door locks automatically.
  8. If invalid:
    • Access denied.

Components Required

  • Arduino Nano / Uno
  • MFRC522
  • Relay module
  • Selonoid Valve
  • 12V Adapter
  • Wires and breadboard

Circuit Diagram

Circuit diagram for RFID Based Door Access System

Step-by-Step Instructions

  1. Upload the DumpInfo or ReadNUID example from the MFRC522 Arduino library.
  2. Open Serial Monitor , Scan your RFID card., Note the ID
  3. Upload the main code below
  4. Connect the components as per circuit
  5. Power ON the system
  6. Show the RFID Tag to the reader, Valve will ON

Source Code

Arduino / ESP32 Sketch
/*
 * This Arduino Sketch interfaces with an RC522 RFID module and a relay module.
 * When an RFID tag is scanned, the relay is activated for 5 seconds, allowing
 * the connected solenoid to operate. The relay then turns off automatically.
 */

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

#define SS_PIN 10
#define RST_PIN 9
#define RELAY_PIN 3

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

void setup() {
  Serial.begin(9600);  // Initialize serial communications
  SPI.begin();         // Init SPI bus
  mfrc522.PCD_Init();  // Init MFRC522
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, LOW);  // Ensure relay is off
  Serial.println("Place your RFID card near the reader...");
}

void loop() {
  // Look for new cards
  if (!mfrc522.PICC_IsNewCardPresent() || 
      !mfrc522.PICC_ReadCardSerial()) {
    return;
  }

  Serial.print("Card UID:");
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
  }
  Serial.println();

  // Activate relay for 5 seconds
  digitalWrite(RELAY_PIN, HIGH);
  delay(5000);
  digitalWrite(RELAY_PIN, LOW);

  // Halt PICC
  mfrc522.PICC_HaltA();
  // Stop encryption on PCD
  mfrc522.PCD_StopCrypto1();
}

Completed this project?

Get an official Project Completion Certificate with a unique ID & QR verification — perfect for internships, resumes, and college submissions.

Get Certificate →
WhatsApp