KrïtikaDr. Umesh DuttaVikas SharmaVaishnavi
Published

RFID-Based Door Lock with Arduino

Secure your door with an RFID system using Arduino, granting access only to authorized users with simple serial communication.

BeginnerFull instructions provided292
RFID-Based Door Lock with Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
Processes the RFID data and controls the relay based on tag verification.
×1
EM-18 Reader Module
Scans RFID tags for access control.
×1
1-Channel Signal Relay 1A SPDT I²C Mini Module
ControlEverything.com 1-Channel Signal Relay 1A SPDT I²C Mini Module
Switches the lock on or off based on the RFID tag's validity.
×1
Solenoid lock
Secures the door and is activated by the relay.
×1
PSD3304 Power Source
Provides power to the system components.
×1
Jumper wires (generic)
Jumper wires (generic)
For making necessary connections between components.
×1

Software apps and online services

Arduino IDE
Arduino IDE
Used to write, upload, and run the code on the Arduino Uno.

Story

Read more

Schematics

Smart and Secure: RFID Door Lock System

In this circuit, the EM-18 RFID reader identifies authorized tags, triggering the Arduino to activate the relay, which controls the door lock. The power supply ensures consistent operation, while the relay provides isolation between the lock and control system, enhancing safety and reliability.

Code

Code Implementation: RFID Door Lock System

C/C++
Reads RFID tag via software serial.
Compares the scanned ID with a predefined authorized ID.
Unlocks the door for 3 seconds if the tag matches.
Stays locked and denies access for unmatched tags.
Uses Arduino and basic serial communication to control a lock.
#include <SoftwareSerial.h>  // Include the SoftwareSerial library for serial communication with RFID reader

// Define RX and TX pins for SoftwareSerial communication
SoftwareSerial rfSerial(10, 11);

// Define the pin connected to the door lock (relay or motor)
int lock = 12;

// Create character arrays for storing RFID tag ID
char id[13];        // Stores the scanned RFID tag ID
char id1[13] = "6F0087C991B0";  // Predefined authorized RFID tag ID

void setup() {
  Serial.begin(9600);       // Initialize hardware serial communication at 9600 baud rate
  rfSerial.begin(9600);     // Initialize software serial communication for RFID reader
  pinMode(lock, OUTPUT);    // Set lock pin as output
  digitalWrite(lock, 1);    // Keep the door locked initially (HIGH signal to lock pin)
}

void loop() {
  rfid();  // Continuously check for RFID tags
}

void rfid() {
  // Check if data is available from the RFID reader
  if (rfSerial.available() > 0) {
    rfSerial.readBytesUntil('\0', id, 12);  // Read the RFID tag ID
    id[12] = '\0';                          // Terminate the string with null character
    
    // Compare the scanned RFID ID with the predefined authorized ID
    if (strcmp(id, id1) == 0) {
      Serial.println("HELLO ACCESS GRANTED");  // Print success message
      digitalWrite(lock, 0);                   // Unlock the door (LOW signal to lock pin)
      delay(3000);                             // Keep the door unlocked for 3 seconds
      digitalWrite(lock, 1);                   // Lock the door again (HIGH signal)
    } else {
      digitalWrite(lock, 1);  // Keep the door locked if the RFID ID does not match
      Serial.println("PLEASE PROVIDE RIGHT DETAILS ACCESS DENIED");  // Print error message
    }
  }
}

Credits

Krïtika

Krïtika

4 projects • 2 followers
:)
Dr. Umesh Dutta

Dr. Umesh Dutta

42 projects • 60 followers
Working as Director of Innovation Centre at Manav Rachna, India. I am into development for the last 12 years.
Vikas Sharma

Vikas Sharma

4 projects • 5 followers
Vaishnavi

Vaishnavi

3 projects • 1 follower
Beginner

Comments