An Arduino RFID door lock is a practical security project that replaces keys with RFID cards or tags. Tap your card on the reader, and the door unlocks for a few seconds before automatically relocking. This kit build guide covers the complete build from components to code, including adding and removing authorised cards without reprogramming.
Table of Contents
- Components List
- How RFID Works
- Wiring Guide
- Arduino Code
- Adding and Removing Cards
- Physical Installation Tips
- Frequently Asked Questions
- Conclusion
Components List
The RFID door lock project requires an Arduino Uno or Nano (Rs 300 to Rs 600), an MFRC522 RFID reader module with cards and key fobs (Rs 150 to Rs 250), a 12V solenoid lock or electromagnetic lock (Rs 300 to Rs 800), a 12V relay module to switch the lock (Rs 80 to Rs 150), a buzzer for audio feedback (Rs 20), LEDs (green and red) for visual status (Rs 10), a 12V power supply for the lock (Rs 100 to Rs 200), and connecting wires. The total cost ranges from Rs 1,000 to Rs 2,200.
How RFID Works
RFID (Radio Frequency Identification) uses electromagnetic fields to identify tags at short range. The MFRC522 reader operates at 13.56 MHz and can read MIFARE Classic and MIFARE Ultralight tags from a distance of up to 5 cm. Each tag has a unique 4-byte ID that the reader transmits to Arduino over the SPI interface. The Arduino compares this ID against a list of authorised IDs and grants or denies access accordingly.
The RC522 module communicates via SPI, using pins MOSI (pin 11), MISO (pin 12), SCK (pin 13), SS (pin 10), and RST (pin 9) on Arduino Uno. The MFRC522 library handles all the low-level communication, providing simple functions to detect cards and read their UIDs.
Wiring Guide
Connect the RC522 to Arduino’s SPI pins as described above. Connect the relay module’s signal pin to Arduino digital pin 7. The relay switches the 12V solenoid lock. Connect a green LED to pin 4 (access granted indicator) and a red LED to pin 5 (access denied indicator) through 220-ohm resistors. Connect the buzzer to pin 6 for audio feedback.
Power the Arduino via USB or a 7-12V supply to the barrel jack. The 12V lock power supply connects through the relay. Keep the lock power supply separate from the Arduino power to prevent voltage fluctuations from the solenoid affecting the Arduino’s operation.
Arduino Code
The code flow is straightforward. In the setup function, initialise the SPI bus, RFID reader, and pin modes. In the main loop, check for a card. When detected, read the UID and compare it against stored authorised UIDs. If the UID matches, activate the relay (unlock the door), light the green LED, beep once, wait 3 seconds, then deactivate the relay (relock). If the UID does not match, light the red LED, beep three times rapidly (denied sound), and continue scanning.
Store authorised UIDs in an array. For a basic system, hard-code 5 to 10 UIDs. For a more advanced system, store UIDs in the Arduino’s EEPROM so you can add and remove cards without reprogramming.
Adding and Removing Cards
Implement a master card system for easy card management. Designate one special card as the “master card.” When you scan the master card, the system enters programming mode (indicated by alternating LED flashes). The next card scanned is either added to or removed from the authorised list. If it is a new card, it gets added. If it is already in the list, it gets removed. Scan the master card again to exit programming mode.
Store the authorised card list in EEPROM so it persists across power cycles. The Arduino Uno’s EEPROM has 1024 bytes, enough to store approximately 250 card UIDs (4 bytes each). The EEPROM library’s read() and write() functions handle persistent storage.
Physical Installation Tips
For a practical door lock installation, mount the RFID reader on the outside of the door frame at a comfortable hand height (approximately 1 metre). Route the SPI cable through the door frame to the Arduino mounted inside. The solenoid lock mounts on the door frame, engaging with a strike plate on the door. Use a fail-secure lock (locked when power is off) for security, or a fail-safe lock (unlocked when power is off) for fire safety compliance.
Protect the electronics from weather if installed on an exterior door. A small weatherproof enclosure for the reader and a sealed indoor box for the Arduino and relay provide adequate protection. Include a backup key lock for situations where the electronics fail.
Frequently Asked Questions
How secure is an Arduino RFID lock?
For a home or office room, it provides reasonable security. The MIFARE Classic protocol has known vulnerabilities and can be cloned by determined attackers with specialised equipment. For high-security applications, use MIFARE DESFire tags which offer encrypted communication. For most residential applications, the RFID lock is as secure as a standard mechanical lock.
Can I use my phone as an RFID card?
Most smartphones with NFC can emulate RFID cards. However, the emulated UID changes with each session on many phones, making reliable identification difficult. A dedicated NFC tag sticker on your phone case is more reliable. Alternatively, add Bluetooth or WiFi-based unlocking using an ESP32 for phone-based access.
What happens during a power cut?
This depends on your lock type. A fail-secure solenoid lock remains locked during power cuts (secure but potentially trapping occupants). A fail-safe lock unlocks during power cuts (safe for evacuation but less secure). For most homes, use a fail-safe lock with a battery backup that provides 4 to 8 hours of operation during outages.
Conclusion
An Arduino RFID door lock is a rewarding project that combines electronics, programming, and practical security. The master card system for managing authorised cards makes it a genuinely usable system, not just a demonstration. Build it as a learning project, then install it on a room or office door for daily use.
Get all the RFID door lock components at Zbotic.in with fast delivery across India.
Add comment