Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » RFID Based Door Lock Security System using Arduino
Arduino Projects

RFID Based Door Lock Security System using Arduino

Mamtaz AlamBy Mamtaz AlamUpdated:December 12, 20248 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
RFID Based Door Lock Security System using Arduino
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview:

In this project, we will design an RFID Based Door Lock Security System utilizing the RC5222 Module and Arduino. As the world advances towards more sophisticated security measures, RFID (Radio Frequency Identification) technology has emerged as a preferred choice for many security applications. Unlike conventional lock and key systems, RFID security systems employ electromagnetic fields to identify and track tags attached to objects, making them more efficient and less susceptible to duplication.

RFID Security System Arduino

By coupling the versatile Arduino microcontroller with the RC5222 RFID module, we can develop a robust and responsive door lock system. When an RFID tag comes in proximity to the reader, the Arduino evaluates the tag’s information against the stored data to ascertain if access should be permitted or restricted. This project provides a practical insight into the workings of RFID technology, demonstrating the synergy between Arduino and the RC5222 module in crafting security solutions.

Earlier, we build Security system projects like Password Based Security System and also Fingerprint Biometric Security System using Arduino. You may check that as well.


Bill of Materials

Following are the components required for building this RFID Based Door Lock Security System Project using Arduino. You can purchase all these components from the given links.

S.N.Components NameQuantityPurchase Links
1Arduino Nano Board1Amazon | AliExpress | SunFounder
2RFID Module RC5221Amazon | AliExpress | SunFounder
316x2 I2C LCD Display1Amazon | AliExpress | SunFounder
412V Solenoid Lock1Amazon | AliExpress
5LED 5mm Any Color2Amazon | AliExpress | SunFounder
6Buzzer 5V1Amazon | AliExpress | SunFounder
71 Channel Relay Module1Amazon | AliExpress | SunFounder
8Resistor 1K2Amazon | AliExpress | SunFounder
97805 Voltage Regulator IC1Amazon | AliExpress
10Capacitor 100uF/35V1Amazon | AliExpress | SunFounder
1112V Power Supply1Amazon | AliExpress | SunFounder
12Connecting Wires20Amazon | AliExpress | SunFounder
13Breadboard1Amazon | AliExpress | SunFounder




Block Diagram & System Operations

Here’s the block diagram of the RFID Based Door Lock Security System using Arduino:

Block Diagram RFID Based Door Lock Security System

Components Used

The system employs an Arduino Microcontroller, an RFID Reader, and several other components which are detailed below:

  • Arduino: This acts as the brain of the system. It receives signals from the RFID reader, processes them, and subsequently sends commands to either grant or deny access.
  • LCD Display: This display module offers feedback to the user. It can showcase messages such as “Access Granted”, “Access Denied”, or “Scan your RFID card”.
  • RFID Reader: This component reads the RFID card or tag presented by the user. If the RFID data aligns with the stored information, it sends a signal to the Arduino for further action. The RC522 SPI Module is the most popular module in the market which has been used in this project.
  • LED Indicator: This provides visual feedback about the system’s status. For instance, a green LED might indicate successful access, while a red LED could signify denied access.
  • Buzzer: An auditory component that can sound alerts or notifications based on the system’s status or user interactions.
  • Relay: This electrically operated switch is activated when the Arduino sends a command to grant access.
  • Solenoid Lock: An electronic lock mechanism that can be locked or unlocked when powered. The relay, when activated, supplies power to this lock, causing it to unlock.


System Operation

The RFID Based Door Lock Security System is engineered to offer secure access control through RFID card verification. Central to the system are an RFID reader, an Arduino microcontroller, a relay, a solenoid lock, an LCD display, an LED indicator, and a buzzer. Users mainly interact with the system by presenting their RFID cards to the reader and receiving feedback via the LCD display and LED indicator.

Circuit RFID Based Door Lock Security System Arduino

When a user scans their RFID card, the reader captures the card’s data and forwards it to the Arduino for validation. The Arduino then compares this data with the stored RFID information. If there’s a match, the Arduino triggers the relay, which subsequently powers the solenoid lock, unlocking it. Throughout this procedure, the LCD display and LED indicator provide real-time feedback to the user, indicating actions required or the outcome of the verification, such as “Access Granted” or “Access Denied”.


Circuit Diagram of RFID Door Lock Security System using Arduino

Here’s the circuit diagram of the RFID Based Door Lock Security System:

Circuit Diagram RFID Based Door Lock Security System Arduino

Let us take a closer look at the connection between various components in this project.

Arduino – LCD Connection:

  • SDA (Serial Data): Connected to the A4 pin of the Arduino.
  • SCL (Serial Clock): Connected to the A5 pin of the Arduino.
  • VCC: Connected to the 5V pin of the Arduino, providing power to the LCD.
  • GND (Ground): This is connected to the GND pin of the Arduino

LED Indicators:

  • Led1: Indicates the Lock Status and is connected to the D2 pin of the Arduino.
  • Led2: Another indicator for the Unlock status is connected to the D3 pin of the Arduino.


RFID MFRC522 Module

  • SDA: Connected to D10 of Arduino
  • SCK: Connected to D13 of Arduino
  • MOSI:  Connected to the D11 pin of Arduino
  • MISO:  Connected to the D12 pin of Arduino
  • GND: Connected to GND of Arduino
  • RST:  Connected to the D9 pin of Arduino
  • 3.3V:  Connected to the 3.3V pin of Arduino

Relay Module

  • VCC: Connected to 5V of Arduino
  • GND: Connected to GND Pin
  • IN: Connected to D6 of Arduino
  • COM: Connected to Solenoid Lock
  • NC: Connected to 12V

For the Power Supply unit, the entire device is powered using a 12V DC Power Adapter. The 7805 Voltage regulator IC power the Relay and relay using the 5V output of the 7805 regulator. The 12V Supply is also connected to the Vin Pin of Arduino Nano. The 100uF/35V Electrolytic Capacitor is used for Voltage Stability at Power Supply Pins.

All the connection can be done in breadboard as per circuit diagram.




Source Code/Program

Let us move to the programming part of “RFID Based Door Lock Security System” using Arduino IDE. The code requires few libraries for compilation. You need to install the libraries first.

Download the following libraries and add it to the Arduino Library folder.

  • RFID Library: Download
  • I2C LCD Library: Download

Apart from above two librarries, we need a header file “pitches.h“. This header file has a definitions for musical note frequencies in Hertz, which can be used to play melodies using a piezo buzzer or other sound-producing device.

Copy the code from the following link: pitches.h and save it to the sketch folder with the name pitches.h.

Here is the completed code for the RFID RFID Based Door Lock Security System using Arduino. Copy the code and paste it to the Arduino IDE.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// Include necessary libraries for RFID, SPI, pitches, and LCD
#include <RFID.h>                
#include <SPI.h>
#include "pitches.h"            
#include <LiquidCrystal_I2C.h>    
 
// Define pins for RFID, Relay, LEDs, and Buzzer
#define SS_PIN 10
#define RST_PIN 9
#define RELAY_PIN 6
#define Red_LED 2
#define Green_LED 3
#define Buzzer 4
 
// Initialize LCD with I2C address
LiquidCrystal_I2C lcd(0x27, 16, 2);
 
// Initialize RFID with SS and RST pins
RFID rfid(SS_PIN, RST_PIN);
 
// Define authorized RFID tag
int My_RFID_Tag[5] = {0x8A, 0x30, 0x03, 0x80, 0x39};
boolean My_Card = false;
 
// Define melodies and note durations for buzzer
int melody[] = {NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4};
int noteDurations[] = {4, 8, 8, 4, 4, 4, 4, 4};
int welcomeMelody[] = {NOTE_C4, NOTE_D4, NOTE_E4};
int welcomeDurations[] = {4, 4, 4};
 
void setup()
{
  // Set pin modes for LEDs, Buzzer, and Relay
  pinMode(Red_LED, OUTPUT);
  pinMode(Green_LED, OUTPUT);
  pinMode(Buzzer, OUTPUT);
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, HIGH);  // Set relay to normally closed state
 
  // Initialize serial communication for debugging and LCD for display
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
 
  // Initialize SPI bus and RFID module
  SPI.begin();
  rfid.init();
}
 
void loop()
{
  // Assume card is authorized initially
  My_Card = true;
  digitalWrite(RELAY_PIN, HIGH);  // Lock the door by default
  lcd.clear();
  lcd.print(" Put Your Card  ");
 
  // Check for the presence of an RFID card and read its serial number
  if (rfid.isCard() && rfid.readCardSerial())
  {
    playWelcomeMelody();  // Play a welcoming tune
    displayCardInfo();    // Display card's unique ID
    checkCardAuthorization();  // Check if the card is authorized
  }
  rfid.halt();  // Stop reading the card
}
 
// Function to display the RFID card's unique ID on LCD and Serial monitor
void displayCardInfo()
{
  lcd.clear();
  lcd.print("UNIQUE ID is:- ");
  delay(500);
  lcd.setCursor(0, 1);
  for (int i = 0; i < 5; i++)
  {
    Serial.print(rfid.serNum[i], HEX);
    Serial.print(" ");
    lcd.print(rfid.serNum[i], HEX);
    lcd.print(" ");
  }
  delay(500);
}
 
// Function to check if the read RFID card is authorized
void checkCardAuthorization()
{
  for (int i = 0; i < 5; i++)
  {
    if (My_RFID_Tag[i] != rfid.serNum[i])
    {
      My_Card = false;
      break;
    }
  }
  Serial.println();
  delay(1000);
  My_Card ? grantAccess() : denyAccess();  // Grant or deny access based on card authorization
}
 
// Function to grant access if the card is authorized
void grantAccess()
{
  Serial.println("\nWelcome To Your Room");
  lcd.clear();
  lcd.print("Welcome to Your");
  lcd.setCursor(0, 1);
  lcd.print("Room!");
  delay(2000);
  digitalWrite(Green_LED, HIGH);  // Turn on green LED
  playMelody();  // Play a melody
  openDoor();  // Unlock the door
}
 
// Function to play a melody when access is granted
void playMelody()
{
  for (int i = 0; i < 2; i++)
  {
    for (int thisNote = 0; thisNote < 12; thisNote++)
    {
      int noteDuration = 1000 / noteDurations[thisNote];
      tone(Buzzer, melody[thisNote], noteDuration);
      delay(noteDuration * 1.30);
      noTone(Buzzer);
    }
    delay(500);
  }
}
 
// Function to unlock the door and start a countdown before locking it again
void openDoor()
{
  digitalWrite(RELAY_PIN, LOW);  // Unlock the door
  delay(200);
  lcd.clear();
  for (int i = 10; i > 0; i--)
  {
    lcd.print("Door will close");
    lcd.setCursor(0, 1);
    lcd.print("in ");
    lcd.print(i);
    lcd.print(" Sec HurryUp!");
    delay(1000);
    lcd.clear();
  }
  digitalWrite(RELAY_PIN, HIGH);  // Lock the door again
  digitalWrite(Green_LED, LOW);  // Turn off green LED
  delay(200);
  lcd.clear();
  lcd.print("Door is Close");
  lcd.setCursor(0, 1);
  lcd.print("Now!");
  delay(2000);
}
 
// Function to deny access if the card is unauthorized
void denyAccess()
{
  Serial.println("\nGet Out of Here !");
  lcd.clear();
  lcd.print("Card NOT FOUND!");
  lcd.setCursor(0, 1);
  lcd.print("Get Out of Here!");
  for (int i = 0; i < 7; i++)
  {
    digitalWrite(Buzzer, HIGH);  // Sound the buzzer
    digitalWrite(Red_LED, HIGH);  // Turn on red LED
    delay(500);
    digitalWrite(Buzzer, LOW);  // Turn off buzzer
    digitalWrite(Red_LED, LOW);  // Turn off red LED
    delay(500);
  }
  delay(1000);
}
 
// Function to play a welcome melody while the card is being identified
void playWelcomeMelody()
{
  for (int i = 0; i < 3; i++)
  {
    int noteDuration = 1000 / welcomeDurations[i];
    tone(Buzzer, welcomeMelody[i], noteDuration);
    delay(noteDuration * 1.30);
    noTone(Buzzer);
  }
}

Select the Arduino Nano Board from the Board list and also select the COM port. Then you can simply upload the code to the Arduino Nano Board.




Setting Up the Master RIFD Tag for Unlocking Door

After uploading the code, the first step would be to set the “Master RFID Tag”, which can only unlock the door. To do that scan the RFID Card as shown.

Place your card of RFID Reader.

The LCD screen will display the RFID Tag number as shown below.

The tag number here is in HEX format and need to be noted down as this would be used in the code.

1
2
// Define authorized RFID tag
int My_RFID_Tag[5] = {0x8A, 0x30, 0x03, 0x80, 0x39};

In the code part, replace the Tag ID in the above line. Then reupload the code.



Working of RFID Door Lock Security System using Arduino

To test the system’s functionality, position your card for scanning.

The LCD will display the RFID tag number.

If the scanned RFID tag number does not match the stored RFID tag, the door will remain locked.

Concurrently, the LCD will show a specific message, the red LED will illuminate, and the buzzer will play warning tones.

To begin, scan the designated RFID tag intended for unlocking the door.

Upon scanning, the LCD will display the RFID tag number.


If the tag matches the stored data, the LCD will greet you with a “Welcome to your Room” message. Simultaneously, the green LED will light up, and the buzzer will play a welcoming melody.

Following this, the relay activates, powering the solenoid lock and unlocking the door. The LCD will then showcase a 10-second countdown timer.

RFID Security System using Arduino

Once the 10 seconds elapse, the door will automatically lock again, as the solenoid will no longer receive power from the relay.

RFID Door Lock using Arduino

This process outlines the functionality of the RFID-based Door Lock Security System, which can be effortlessly assembled using an Arduino board.


Video Tutorial & Guide

RFID RC522 Based Door Lock Security System using Arduino & Solenoid Lock
Watch this video on YouTube.


Conclusion

In our exploration of modern security solutions, we successfully designed and implemented an RFID Based Door Lock Security System using the RC5222 Module and Arduino. The fusion of RFID technology, known for its efficiency and resistance to duplication, with the adaptability of the Arduino microcontroller, has paved the way for a reliable and advanced security measure. Our system efficiently evaluates the information from an RFID tag when placed near the reader, granting or denying access based on the stored data.

This project not only showcased the potential of RFID technology but also highlighted the seamless integration capabilities of the Arduino with the RC5222 module. Such innovations underscore the potential of combining traditional security measures with modern technology, offering a glimpse into the future of security systems.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleArduino UNO R4 Minima Board Overview & Getting Started Guide
Next Article 14-Bit ADC Usage Guide in Arduino UNO R4 Minima

Related Posts

DC Energy Meter using Arduino

Build a DC Energy Meter using Arduino – 32V/5A

Updated:August 26, 20252K
Interfacing ADXL375 Accelerometer with Arduino

Interfacing ADXL375 Accelerometer with Arduino (±200g)

Updated:June 28, 2025
PZEM-004T Arduino Energy Meter

DIY AC Energy Meter using PZEM-004T & Arduino

Updated:March 6, 20258K
Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Interfacing BMI160 Accelerometer & Gyroscope with Arduino

Updated:February 2, 20259K
Password Based Door Lock Security System Using Arduino & Keypad

Password Based Door Lock Security System Using Arduino & Keypad

Updated:February 2, 20252436K
Earthquake Detector Alarm with with Accelerometer & Arduino

Earthquake Detector Alarm with Accelerometer & Arduino

Updated:February 2, 2025661K
Add A Comment

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • Pulse Rate (BPM) Monitor using Arduino & Pulse Sensor
    Pulse Rate (BPM) Monitor using Arduino & Pulse Sensor
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.