Skip to main content

Arduino RFID Door Security System with Automatic Room Lighting

In this tutorial, you will learn how to build a smart door security system using RFID that also automatically controls room lighting when the door opens.

This project combines three important embedded-systems concepts:
  • RFID-based access control
  • Door status detection using a laser break sensor
  • Automatic lighting control using a relay
By the end of this guide, you will understand how multiple sensors can be integrated into a single Arduino automation system.

Watch Project Overview

How the System Works

The system operates using two RFID tags:
  • Card Tag - Arms the system (turns laser ON)
  • Key Tag - Disarms the system (turns laser OFF)
A laser beam and photoresistor pair is used to detect door movement.

Operating Logic

  1. User scans RFID card → system enters armed mode
  2. Door opens → laser beam breaks → room lights turn ON
  3. User scans RFID key tag → system enters disarmed mode
  4. Door opens → lights remain OFF and buzzer warning
This simulates a real smart-room security and automation system.

Required Components

Microcontroller & Modules

  • Arduino Uno or Arduino Nano
  • MFRC522 RFID Reader Module
  • RFID Card Tag
  • RFID Key Tag

Sensors

  • Laser transmitter module (KY-008)
  • Photoresistor module (KY-018)

Output Devices (Actuators)

  • 5V Relay Module (1 channel)
  • 12V LED Strip Lights
  • Active buzzer module (KY-012)

Power & Misc

  • 12V DC Adapter
  • Power bank (for Arduino)
  • Breadboard and jumper wires
  • Rocker switch

Understanding the Sensors

RFID Reader (MFRC522)

  • Reads the UID (Unique ID) stored inside RFID tags.
  • The UID acts as a digital key.

Laser + Photoresistor = Door Sensor

Instead of a magnetic reed switch, this project uses a laser break beam system:
Door State                    Laser Beam                    Photoresistor Output
Door Closed                    Beam hits sensor                    High light value
Door Open                    Beam broken                    Low light value
This technique is commonly used in security systems and burglar alarms.

Wiring

Laser Module (KY-008)

  • S - D5
  • (+) - 5V
  • (-) - GND

Photoresistor Module (KY-018)

  • S - A0
  • (+) - 5V
  • (-) - GND

RFID Reader (MFRC522)

  • RST - D9
  • SDA - D10
  • MOSI - D11
  • MISO - D12
  • SCK - D13
  • VCC - 3.3V
  • GND - GND

Active Buzzer Module (KY-012)

  • S - D6
  • (+) - 5V
  • (-) - GND

Relay Module

  • S - D7
  • (+) - 5V
  • (-) - GND

Step 01: Install Required Libraries

Install the following libraries:
  • SPI (built-in)
  • MFRC522 library (by GitHub community)
Arduino IDE →
Sketch → Include Library → Manage Libraries → Search “MFRC522”

Step 02: Read RFID Tag UID

Before writing the main program, you must obtain the UID of your tags.
  1. Open example sketch: File → Examples → MFRC522 → DumpInfo
  2. Upload to Arduino
  3. Open Serial Monitor
  4. Scan each tag and copy the UID
You will use these UIDs in the main code.

Step 03: Calibrate the Laser Door Sensor

This step is extremely important.
  1. Turn laser ON
  2. Record photoresistor analog value
  3. Break the beam (open door)
  4. Record new value

Example:

Condition                    Analog Value
Beam detected                    850
Beam broken                    200
Choose a threshold between them (e.g., 500).

Step 04: Program Logic

Global Definitions

  • Define RFID pins
  • Create MFRC522 object
  • Store UID for both tags
  • Define sensor threshold value

Setup()

Initialize:
  • Pin modes
  • SPI communication
  • RFID reader

Loop()

The main loop performs 3 tasks continuously:

1. Check RFID Tag

  • Card tag → Arm system → Turn laser ON
  • Key tag → Disarm system → Turn laser OFF

2. Monitor Door Status

If laser beam breaks → Door opened.

3. Trigger Outputs

Mode                    Door Open Action
Armed                    Turn lights ON
Disarmed                    Activate buzzer

Step 05: Buzzer Feedback Tones

Different tones indicate different RFID tags.
Tag                    Tone                    Duration
Key Tag                    100 Hz                    500 ms
Card Tag                    500 Hz                    700 ms
This provides audio confirmation for user actions.

System Flow Summary

  1. Scan RFID
  2. Set system mode
  3. Monitor door beam
  4. Control lights or buzzer
This is a multi-sensor event-driven Arduino system.

Testing the Project

Test the following scenarios:
Test Case                    Expected Result
Scan card → open door                    Lights turn ON
Scan key → open door                    Buzzer sounds
Door closed                    No action

Troubleshooting

RFID Not Reading

Check 3.3V power (NOT 5V)

Laser Not Detected

Recalibrate threshold

Relay Not Switching

Check external 12V supply

False door triggers

Align laser precisely

Conclusion

You have successfully built a smart RFID door security system with automated lighting.
This project demonstrates how Arduino can integrate:
  • Access control
  • Environmental sensing
  • Home automation
It is an excellent foundation for smart home and IoT security systems.

FAQ

Why use laser instead of magnetic sensor?

Laser sensors provide more precise break detection and longer range.

Can I use an electromagnetic lock?

Yes, connect it through the relay instead of LED lights.

Why does MFRC522 use 3.3V?

It is not 5V tolerant. Supplying 5V can damage the module.

Can multiple RFID cards be added?

Yes. Store multiple UIDs in an array and compare them.


Comments

Popular posts from this blog

Arduino Serial Communication Beginner Guide (UART Explained)

Serial communication is the backbone of most Arduino projects. It allows your Arduino to talk to your computer, Bluetooth modules, Wi-Fi modules, sensors, and even other Arduinos. If you have ever used the Serial Monitor, you have already used serial communication - now you will understand how it really works. By the end of this guide, you will learn: What serial communication is What UART means How Arduino communicates with devices How to send and receive data How baud rate works Common mistakes beginners make What is Serial Communication? Serial communication is a method of sending data one bit at a time over a single wire. Instead of sending many bits simultaneously (parallel communication), serial sends bits sequentially: Example: The letter A in binary = 01000001 These bits are sent one after another very quickly. This method is: Simple Reliable Perfect for microcontrollers What is UART? UART stands for: Universal Asynchronous Receiver Transmitter It is the hardware ins...

How to Connect HC-06 Bluetooth Module with Arduino (Step-by-Step Beginner Guide)

Bluetooth communication is one of the easiest ways to make Arduino projects wireless. Once you understand how to use a Bluetooth module, you can build robots, home automation systems, and smartphone-controlled devices. In this tutorial, you will learn how to interface the HC-06 Bluetooth module with Arduino and send data wirelessly using your phone.    By the end of this guide, you will be able to: Understand how the HC-06 Bluetooth module works Configure the module using AT commands Safely connect it to an Arduino Send and receive serial data over Bluetooth Build the foundation for wireless Arduino projects Watch the Project Overview What is the HC-06 Bluetooth Module? The HC-06 is a Bluetooth-to-Serial module designed to add wireless communication to microcontrollers such as Arduino. It uses Bluetooth 2.0 (SPP - Serial Port Protocol), which means it behaves like a wireless serial cable. Whatever is sent from the phone appears in Arduino’s Serial Monitor and vice versa. ...

How to Use SoftwareSerial on Arduino (Connect Multiple Serial Devices)

In the previous tutorial, you learned how Arduino uses hardware serial communication through pins 0 (RX) and 1 (TX). That built-in serial port is mainly used to communicate with your computer through the USB cable and Serial Monitor . But here is the problem beginners quickly face: Many popular modules use serial communication, such as: Bluetooth modules ( HC-05 / HC-06 ) GPS modules GSM modules Wi-Fi modules ( ESP8266 ) Arduino Uno has only one hardware serial port. So how can we connect these modules while still using the Serial Monitor? The solution is SoftwareSerial . In this tutorial you will learn how to create additional serial ports using normal digital pins. By the end, your Arduino will be able to talk to multiple serial devices. What is SoftwareSerial? SoftwareSerial is a special Arduino library that allows digital pins to behave like RX and TX pins. This means Arduino can create extra serial ports using software instead of hardware. Hardware Serial vs Software Seri...