0% found this document useful (0 votes)
16 views16 pages

Lab 4 Vault

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views16 pages

Lab 4 Vault

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

CPEN 130 - Embedded Systems

Laboratory Activity 3

Arduino-Controlled RFID-Based Smart Door Lock with LED and Buzzer Feedback

Submitted by:
Miro G. Angeles
Deen Reiner B. Crusem
Julius Caezar R. Eugenio
BS CPE 4-1

Submitted to:
Prof. Aileen V. Rocillo

November 2024
Laboratory Activity 3
Arduino-Controlled RFID-Based Smart Door Lock with LED and Buzzer Feedback

OBJECTIVES
At the end of the experiment, the students should be able to:
1. Implement an RFID-based security system for access control.
2. Understand the process of configuring RFID tags for secure access.
3. Control the behavior of a servo motor, LED indicators, and a buzzer based on RFID
tag authorization status.

Introduction

Radio Frequency Identification, or RFID, technology is now a major factor in improving


access control system security. According to Costa et al. (2021), RFID sensors provide a
dependable and convenient way to identify people without establishing physical touch, which
makes them appropriate for a variety of security applications. Using unique identifiers
embedded in RFID tags, smart door lock systems that use RFID technology are frequently
seen in home and commercial settings, helping to safeguard entry. Upon scanning an RFID
tag, a microcontroller receives a unique code from the reader and uses it to confirm the
authorized status of the tag. In addition to enhancing security, this procedure provides users
with a smooth, touchless entry approach (Shanthini et al., 2020). In recent years, RFID-
based smart door lock systems have improved dramatically, combining automated access
controls that enhance both security and convenience. According to Aswini et al. (2021),
these systems simplify access by automatically verifying RFID tags, eliminating the need for
traditional keys or manual input—both of which are vulnerable to theft and illegal replication.
RFID-based solutions are perfect for high-security settings because they efficiently enhance
access control while reducing human intervention by allowing only pre-authorized entry. The
benefits of RFID-based automatic door lock systems in protecting critical business locations,
private houses, and offices are further highlighted by Hasan et al. (2020). These systems
provide a dependable layer of security that satisfies contemporary expectations for
automated, real-time access management in addition to preventing unwanted access. They
also provide an effective, long-lasting solution for managing entrance. As a result, this
technology is now a priceless resource for anyone looking to increase security without
sacrificing usability.

Together, the elements of this RFID-based security system provide a smooth and effective
access control system. The RFID reader serves as the main sensor in this configuration,
continuously searching for RFID tags placed close to the door and sending the Arduino
microcontroller the unique tag data. The Arduino serves as the processing center and is
configured to compare the received tag data with a list of pre-authorized tags that is kept in
its memory. The Arduino signals a servo motor to turn, unlocking the door and permitting
admission if a match is detected, signaling an approved tag. Additionally, a green LED
illuminates to verify access, giving the user unambiguous visual confirmation. To notify those
in the vicinity of a restricted access attempt, the system instantly turns on a siren and a red
LED if an unauthorized tag is found. By quickly alerting unwanted access attempts, this dual-
response technology improves overall security while simultaneously expediting entrance for
authorized users. Real-time feedback and automation are combined in this system to offer a
reliable, approachable method of safe access control.

Materials and Components


 Arduino Uno Board
 Breadboard
 RFID Reader (MFRC522)
 RFID Tags
 Servo Motor (for lock mechanism simulation)
 Buzzer (for unauthorized access alert)
 Green LED (for access granted indication)
 RED LED (for access denied indication)
 Resistors
 Jumper Wires

CIRCUIT DIAGRAM
Figure 1. Wiring Diagram of the Security Door Lock System

Figure 2. Schematic Diagram of the Security Door Lock System

An RFID module (R1), a servo motor (M1), a buzzer (B1), and two LEDs (LED1 for green
and LED2 for red) are all controlled by an Arduino Uno (U2) in this circuit schematic design.
The servo motor is attached to pin 5 (SERVO_PIN) to control the locking mechanism, and
the RFID module connects to the Arduino via the SDA (10) and RST (9) pins. The LEDs are
attached to pins 4 (LED_PIN) and 3 (RED_LED_PIN) to offer visual feedback for access
being allowed or denied, and the buzzer is connected to pin 6 (BUZZER_PIN) to sound an
alert. The Arduino serves as the main controller, processing the RFID tag data and
controlling the door mechanism in accordance with it. All of the components are powered by
a 5V supply.

Procedure

Step 1. Connection of Components


1.1. Setting up the Breadboard
a. Connect the 5V pin of the Arduino to the positive (red) rail of the breadboard
using a jumper wire
b. Connect the GND pin of the Arduino to the negative (blue) rail of the breadboard
using a jumper wire.
c. Link the power and ground rails on both sides of the breadboard to ensure
consistent power distribution.

1.2. Connect the RFID Reader (MFRC522)


a. Place the RFID module on the breadboard.
b. Connect the SDA pin of the RFID reader to digital pin 10 on the Arduino.
c. Connect the RST pin of the RFID reader to digital pin 9 on the Arduino.
d. Connect the VCC pin of the RFID reader to the positive (5V) rail on the
breadboard.
e. Connect the GND pin of the RFID reader to the negative (GND) rail on the
breadboard.
f. Connect the SCK, MOSI, and MISO pins of the RFID module to pins 13, 11, and
12 on the Arduino, respectively, following the SPI protocol.

1.3: Connect the Servo Motor


a. Attach the servo motor to the breadboard.
b. Connect the signal wire of the servo motor to digital pin 5 on the Arduino.
c. Connect the power wire of the servo motor to the positive (5V) rail on the
breadboard.
d. Connect the ground wire of the servo motor to the negative (GND) rail on the
breadboard.

1.4: Connect the Buzzer


a. Place the buzzer on the breadboard.
b. Connect the positive pin of the buzzer to digital pin 6 on the Arduino.
c. Connect the negative pin of the buzzer to the negative (GND) rail on the
breadboard.Connect the VCC pin of the I2C module to the positive rail (5V) on the
breadboard.

1.5: Connect the LEDs


a. Place the green LED on the breadboard:
 Connect the positive (long) leg to digital pin 4 on the Arduino.
 Connect the negative (short) leg to a 220Ω resistor, and then connect the
resistor to the negative rail (GND).
b. Place the red LED on the breadboard:
 Connect the positive (long) leg to digital pin 3 on the Arduino.
 Connect the negative (short) leg to a 220Ω resistor, and then connect the
resistor to the negative rail (GND).
The table below provides a summary of the pin assignments for the various components
connected to the Arduino Uno board:
Component Pins Arduino Pin Description
SDA Digital Pin 10 SPI Slave Select
for RFID
communication.
RFID Reader RST Digital Pin 9 Resets the RFID
(MFRC522) module.
SCK Digital Pin 13 SPI clock line for
synchronization.
MOSI Digital Pin 11 SPI data line for
sending data.
MISO Digital Pin 12 SPI data line for
receiving data.
VCC 5V Supplies power to
the RFID module.
GND GND Ground connection
for stable
operation.
Servo Motor Signal Digital Pin 5 Controls the servo
motor's movement.
Positive Pin Digital Pin 6 Drives the buzzer
to produce sound.
Buzzer Negative Pin GND Connects to ground
for sound
stabilization.
Positive Digiral Pin 4 Lights up to
indicate granted
access.
Green LED Negative GND via 220Ω Connects to ground
resistor via a current-
limiting resistor.
Positive Digital Pin 3 Lights up to
indicate denied
access.
Red LED Negative GND via 220Ω Connects to ground
resistor via a current-
limiting resistor.
Table 1. Pin Assignments

Step 2. Code Development or Algorithm Design


a. To design the control system for the RFID-based door lock mechanism, begin
creating the Arduino code. To ensure systematic and effective component
management, the code starts by specifying the pins that are attached to the
Arduino UNO for the buzzer, LEDs, servo motor, and RFID reader. Each
component is given a function to help with efficient communication, especially
between the output devices for user feedback and the RFID reader for
authentication. With this configuration, the system may detect RFID tags, check
access credentials, and react properly by either unlocking the door, preventing
entrance, or using LEDs and sound alarms to indicate the present situation.

b. The algorithm is designed to:


 Continuously monitor for an RFID tag and read its unique identifier.
 Compare the scanned RFID UID with the authorized tag stored in the system.
 Unlock the door and activate the green LED when the authorized tag is
scanned.
 Lock the door and activate the red LED when an unauthorized tag is scanned.
 Control the servo motor to switch between locked and unlocked positions.

Step 3. Explanation of Logic Used


a. Loop: The loop function searches for an RFID tag and processes the results
constantly. Following tag detection, the approved tag is compared to the scanned
tag, which determines whether access is permitted or refused.
b. Conditional Logic: The program uses conditional statements to decide what
action to take based on the scanned RFID tag:
 Authorized Tag: If the scanned tag matches the authorized tag, the system
either unlocks or locks the door depending on its current state. The green LED
blinks twice, and the servo motor moves to unlock the door.
 Unauthorized Tag: If the scanned tag does not match the authorized tag,
access is denied. The red LED blinks twice, and the buzzer emits a denial
sound.
 Unlocking/Locking Process: The servo motor moves the door either to the
locked or unlocked position, and the corresponding LED (green for granted
access, red for denied access) lights up.
 Feedback Using Buzzer and LEDs: The buzzer provides auditory feedback
—either a sound indicating access granted (unlocking) or access denied
(locking)—while the LEDs visually indicate the access status.

Step 4. Uploading the Code and Testing the System


Once the Arduino code has been carefully examined, use the Arduino IDE to
upload it to the Arduino board and run a number of tests to make sure everything
works as it should. To make sure the door unlocks for the right tag and stays locked
or locked again for others, test the system using a variety of RFID tags, both
permitted and illegitimate. For feedback, watch the buzzer and LED answers; red
indicates access prohibited, while green indicates access allowed. Make sure the
door is precisely moved to the locked or unlocked position by the servo motor. If
problems occur, check the RFID reader's functionality, confirm the wire connections,
and go over the code logic to make any necessary corrections. To ensure
dependable and consistent system functioning, repeat testing under various
conditions.

Code
#include <Servo.h> // Initialize Servo, Buzzer, and LEDs

#include <SPI.h> doorServo.attach(SERVO_PIN);

#include <MFRC522.h> pinMode(BUZZER_PIN, OUTPUT);


pinMode(LED_PIN, OUTPUT); // Green LED

#define SDA_PIN 10 pin

#define RST_PIN 9 pinMode(RED_LED_PIN, OUTPUT); // Red LED

#define BUZZER_PIN 6 pin

#define SERVO_PIN 5
#define LED_PIN 4 // Green LED for // Set the initial state to locked (specific

granted access angle)

#define RED_LED_PIN 3 // Red LED for denied doorServo.write(180); // Start in

access locked position (adjust angle as needed)


doorUnlocked = false; // Door is
MFRC522 rfid(SDA_PIN, RST_PIN); locked initially
Servo doorServo;
digitalWrite(LED_PIN, LOW); // Green LED
String authorizedTag = "04e594a7"; // Replace off initially
with your RFID tag UID digitalWrite(RED_LED_PIN, LOW); // Red LED
bool doorUnlocked = false; // Track door off initially
state
Serial.println("Door locked. Waiting for RFID
void setup() { tag...");
Serial.begin(9600); }
Serial.println("System initializing...");
void loop() {
// Initialize SPI and RFID // Check if a new RFID card is present
SPI.begin(); if (!rfid.PICC_IsNewCardPresent() || !
rfid.PCD_Init(); rfid.PICC_ReadCardSerial()) {
// Read and format the UID // Check if UID matches the authorized tag
String tagUID = ""; if (tagUID == authorizedTag) {
for (byte i = 0; i < rfid.uid.size; i++) { if (doorUnlocked) {
if (rfid.uid.uidByte[i] < 0x10) tagUID += "0"; lockDoor();
// Add leading zero for consistency } else {
tagUID += String(rfid.uid.uidByte[i], HEX); unlockDoor();
} }
tagUID.toLowerCase(); // Ensure tagUID is } else {
lowercase for comparison denyAccess();
Serial.print("Scanned RFID Tag UID: "); }
Serial.println(tagUID);
rfid.PICC_HaltA(); // Stop reading the card
// Check if UID matches the authorized tag }
if (tagUID == authorizedTag) {
if (doorUnlocked) { void unlockDoor() {
lockDoor(); Serial.println("Unlocking door...");
} else { blinkLED(LED_PIN); // Blink the green LED twice
unlockDoor(); playUnlockLockSound(); // Play the sound for
} unlocking
} else { doorServo.write(120); // Move servo to unlock
denyAccess(); position
} doorUnlocked = true; // Set door state to
unlocked
rfid.PICC_HaltA(); // Stop reading the card Serial.println("Door is now unlocked.");
} }

void unlockDoor() {
Serial.println("Unlocking door...");
blinkLED(LED_PIN); // Blink the green LED twice
playUnlockLockSound(); // Play the sound for
unlocking
doorServo.write(120); // Move servo to unlock
position
doorUnlocked = true; // Set door state to
unlocked
Serial.println("Door is now unlocked.");
}

void loop() {
// Check if a new RFID card is present
if (!rfid.PICC_IsNewCardPresent() || !
rfid.PICC_ReadCardSerial()) {
return;
}
// Read and format the UID
String tagUID = "";
for (byte i = 0; i < rfid.uid.size; i++) {
if (rfid.uid.uidByte[i] < 0x10) tagUID += "0";
// Add leading zero for consistency
tagUID += String(rfid.uid.uidByte[i], HEX);
Results

The outcomes of the Arduino-Controlled RFID-Based Smart Door Lock with LED and
Buzzer Feedback successfully aligned with the desired objectives of the project. The RFID
module accurately detected RFID tags and differentiated between authorized and
unauthorized tags. Upon scanning an authorized tag, the servo motor rotated to unlock the
door, the green LED blinked twice, and the buzzer emitted a short confirmation sound,
signifying successful access. Conversely, when an unauthorized tag was scanned, the red
LED flashed twice, and the buzzer emitted a continuous denial sound, indicating restricted
access.

The system demonstrated smooth operation in managing access control, with real-
time feedback from both the LEDs and the buzzer. While minor issues, such as occasional
misreads of RFID tags, were observed, these were attributed to environmental factors or the
positioning of the RFID module. Nevertheless, the system's response mechanism efficiently
communicated access status, ensuring both functionality and reliability in line with the
project's intended design.

Test RFID Tag Door LED Status Buzzer Status Notes


No. Type Status
1 Authorized Tag Unlocked Green Short Confirmation Works as
Blinks Beep expected
2 Unauthorized Locked Red Blinks Continuous Denial Works as
Tag Sound expected
3 No Tag Locked Off Off Works as
Scanned expected
4 Authorized Tag Unlocked Green Short Confirmation Works as
Blinks Beep expected
5 Unauthorized Locked Red Blinks Continuous Denial Works as
Tag Sound expected
6 No Tag Locked Off Off Works as
Scanned expected

Table 2. Output During Testing

Fig 3. Output after Testing Authorized and Unauthorized RFID tags

Fig 4. Front View of the RFID-Based Security Door Lock System


Fig 5. Connections and Wire Management of the RFID-Based Security Door Lock System

Discussions

The results from testing the Arduino-Controlled RFID-Based Smart Door Lock
demonstrated that the system effectively differentiated between authorized and unauthorized
RFID tags, providing a reliable access control mechanism. The LED and buzzer feedback
system worked seamlessly, offering clear indicators of access status. Authorized tags
triggered the servo motor to unlock the door, accompanied by a blinking green LED and a
short confirmation beep, while unauthorized tags resulted in a locked door, a blinking red
LED, and a continuous denial sound. These responses ensured functional and intuitive
communication with users during operation.

However, during the testing phase, a few challenges and areas for improvement were
identified. One challenge encountered was occasional misreads of RFID tags, where the
system would momentarily fail to detect the tag or produce an inaccurate response. These
issues were likely due to the environmental conditions, such as interference or improper
positioning of the RFID reader relative to the tags. Ensuring optimal placement of the RFID
module and reducing potential interference sources could improve reliability.

Proposed Improvements:

1. Adding an Automatic Re-Lock Feature: Incorporating a timer-based re-locking


mechanism would enhance security by automatically locking the door after a set
period of time if no further authorized access is detected. This feature would ensure
that the door remains secured in case a user forgets to manually re-lock it.

2. Improved RFID Detection Range: Enhancing the RFID reader’s sensitivity to


expand its detection range would allow smoother and quicker tag recognition. This
improvement would be particularly useful in scenarios where users might approach
the system from varying angles or distances.
Conclusion

In conclusion, the objectives of the Arduino-Controlled RFID-Based Smart Door Lock


project were successfully achieved. The integration of the RFID module with the Arduino
allowed the system to effectively differentiate between authorized and unauthorized tags,
providing a secure and automated access control solution. The system reliably triggered the
servo motor to unlock the door upon detecting authorized tags and provided real-time
feedback through LEDs and a buzzer, ensuring intuitive user interaction.

Furthermore, a custom program was developed to automate the entire process,


ensuring that the door lock, LEDs, and buzzer operated seamlessly based on the RFID
input. This automation minimized the need for manual intervention, enhancing the overall
efficiency and usability of the system.

Lastly, the functionality of the system was successfully demonstrated through


practical testing, showcasing how the combination of RFID technology, Arduino components,
and programming can be utilized to create a secure and user-friendly door lock system. This
project highlights the potential of integrating automation and IoT technologies to enhance
access control, offering a robust and reliable solution for modern security applications.
References

Costa, F., Genovesi, S., Borgese, M., Michel, A., Dicandia, F. A., & Manara, G. (2021). A review
of RFID sensors, the new frontier of internet of things. Sensors, 21(9), 3138.

Shanthini, M., Vidya, G., & Arun, R. (2020, August). IoT enhanced smart door locking system.
In 2020 Third International Conference on Smart Systems and Inventive Technology
(ICSSIT) (pp. 92-96). IEEE.

Aswini, D., Rohindh, R., Ragavendhara, K. M., & Mridula, C. S. (2021, October). Smart Door
Locking System. In 2021 International Conference on Advancements in Electrical,
Electronics, Communication, Computing and Automation (ICAECA) (pp. 1-5). IEEE.

Hasan, Y., Wijanarko, Y., Muslimin, S., & Maulidda, R. (2020, April). The automatic door lock to
enhance security in RFID system. In Journal of Physics: Conference Series (Vol. 1500,
No. 1, p. 012132). IOP Publishing.
Appendices

Parameters Details/Value
Model MFRC522
Type RFID Reader/Writer
Operating Frequency 13.56 MHz
Interface SPI (Serial Peripheral Interface), I2C (optional with
additional hardware)
Operating Voltage 3.3V to 5V
Current Consumption 13-26 mA (typical)
Communication Speed Up to 10 Mbps (SPI)
Card Type Supported MIFARE, ISO/IEC 14443 Type A and Type B, NTAG,
ISO/IEC 18092, and other 13.56 MHz RFID cards
Data Transmission Rate 848 Kbps (max)
Antenna Type External (with integrated coil for
transmission/reception)
Communication Protocol SPI or I2C (with additional connection setup)
Dimensions 40mm x 60mm (approx.)
Mounting Type PCB Mountable (through-hole or surface mount)
Operating Temperature -20°C to 85°C
Operating Humidity 5% to 95% RH (non-condensing)
Detection Range Up to 5 cm (depends on the card and antenna size)
Features Anti-collision, Multi-card support, Low power
consumption, High-speed communication
Power Supply Typically powered via 3.3V or 5V rail (depending on
the logic level requirement)
Pin Configuration 8 Pins: SDA, SCK, MOSI, MISO, IRQ, GND, RST,
3.3V/5V
Table 3. MFRC522-RFID Reader Datasheet

You might also like