In the previous RFID projects, we learned how RFID works and built a basic access control system.
Now we will take the next step and build a real electronic door lock system similar to those used in offices, labs, and smart homes.
This version introduces:
The concepts used here form the foundation of modern access control systems used in workplaces, laboratories, and smart homes. From this point, you can expand the system into a connected IoT security platform with logging, remote monitoring, and mobile integration.
Now we will take the next step and build a real electronic door lock system similar to those used in offices, labs, and smart homes.
This version introduces:
- A real electromagnetic door lock
- Secondary authentication using a keypad
- Proper power switching using a MOSFET/relay
- Security-focused design considerations
Learning Objectives
By completing this tutorial, you will learn how to:- Authenticate RFID cards using Arduino
- Add a keypad for two-factor authentication
- Safely control high-power loads (electromagnetic lock)
- Design fail-safe embedded security logic
- Understand how real access control systems work
Watch Project Overview
How the System Works
This project implements a two-step authentication process:- RFID card is scanned
- User enters a PIN on keypad
- If both are correct → door unlocks
- If not → alarm and access denied
Components Required
- Arduino Uno - Main Controller
- MFRC522 RFID Module - Reads RFID cards & tags
- Electromagnetic lock (12V) - Physical door lock
- 4x4 Keypad - PIN Authentication
- Relay Module / MOSFET - Switches the lock safely
- External 12V power supply - Powers the lock
- Buzzer - Alarm
- Red/ Green LEDs - Status indicators
Safety and Power Requirements
This project uses a 12V electromagnetic lock, which draws much more current than Arduino can provide.Important safety rules:
- NEVER power the lock from Arduino 5V
- Always use an external 12V power supply
- Use a relay or MOSFET to switch the lock
- Place a diode across the lock terminals to prevent back-EMF damage
Why Use a Relay or MOSFET?
Arduino pins provide only small current.The lock requires high current at 12V.
The relay/MOSFET acts as an electronic switch:
The relay/MOSFET acts as an electronic switch:
- Arduino sends small control signal
- Switch controls large lock current safely
Wiring Overview
RFID → Arduino (SPI)
MFRC522 Pin | Arduino |
|---|---|
| SDA | D10 |
| SCK | D13 |
| MOSI | D11 |
| MISO | D12 |
| RST | D9 |
| GND | GND |
| 3.3V | 3.3V |
Keypad Connections
Keypad Pin | Arduino |
|---|---|
| R1–R4 | D2–D5 |
| C1–C4 | D6–D9 |
Lock and Feedback Devices
Device | Arduino Pin |
|---|---|
| Relay/MOSFET | D3 |
| Green LED | A0 |
| Red LED | A1 |
| Buzzer | A2 |
Authentication Logic
The system follows this decision process:- Wait for RFID card
- Check if UID is authorized
- Ask for PIN via keypad
- If PIN correct → unlock door
- Else → trigger alarm
Code Snippet
Code Explanation
RFID Authentication
The system first checks whether the scanned UID matches an authorized user.Keypad Verification
If RFID is valid, the user must enter a correct PIN.Unlock Sequence
When both conditions are satisfied:- Relay activates
- Lock releases
- Green LED turns on
- Buzzer beeps once
Alarm Sequence
If authentication fails:- Red LED turns on
- Buzzer sounds repeatedly
- Door remains locked
Testing the System
Successful Access
- Scan authorized card
- Enter correct PIN
- Door unlocks for a few seconds
Failed Access
- Wrong card OR wrong PIN
- Alarm sounds
- Door remains locked
Security Discussion
This system demonstrates multi-factor authentication:- Something you have → RFID card
- Something you know → PIN code
- Encrypted RFID cards
- Event logging
- Network monitoring
- Backup power systems
Troubleshooting
RFID not detected
- Ensure module is powered with 3.3V
- Check SPI wiring carefully
Lock not activating
- Check external power supply
- Verify relay wiring and diode polarity
Keypad inputs incorrect
- Verify row/column pin mapping
Conclusion
You have built a complete RFID-based smart door lock system with two-factor authentication. This project combines RFID identification, keypad verification, actuator control, and safety-focused power design into one practical embedded system.The concepts used here form the foundation of modern access control systems used in workplaces, laboratories, and smart homes. From this point, you can expand the system into a connected IoT security platform with logging, remote monitoring, and mobile integration.





Comments
Post a Comment