Skip to content

Latest commit

 

History

History
144 lines (109 loc) · 6.8 KB

File metadata and controls

144 lines (109 loc) · 6.8 KB

Smart Lock

Microcontroller based DIY Smart Lock

DIY Smart Lock with Arduino and RFID

DIY Smart Lock Arduino Mega 2560 RFID MFRC522 Embedded System

Project intro Components Project structure

Table of Contents

🚀 Project intro

In this project, I have used an RFID reader (MFRC522), Arduino microcontroller (Mega 2560), Arduino programming language and other components to create an RFID-based smart lock. This lock is a small version of an automated RFID-based smart lock, an important component of an automated home.

Features

Core features

Feature Status Description
RFID access control ✅ Current Uses the MFRC522 module to read authorized RFID tags and grant access.
Master card programming ✅ Current Lets you define a master card to add or remove user cards.
EEPROM storage ✅ Current Saves approved RFID IDs in non-volatile memory so access records remain after power loss.
LED status feedback ✅ Current Uses red, green, and blue LEDs to indicate access, denial, and programming mode.
Solenoid lock control ✅ Current Activates a relay/MOSFET circuit to unlock the door for a set duration.
Wipe/reset mode ✅ Current Supports a wipe button to clear stored records and reset the system.

Requirements

Hardware

  • Arduino. I've used a Mega 2560, though any Arduino board or clone will suffice.
  • 3 x 220 ohm resistors
  • 1 x 10k ohm resistor
  • Logic-level N channel MOSFET
  • MFRC522 module with at least two cards
  • Red, blue, and green LEDs
  • 12v Solenoid ($2)
  • 12v power supply
  • Breadboard and hook up wires

Software

  • Arduino IDE
  • MFRC522 library
  • SPI and EEPROM libraries (already included with the Arduino core)
  • Serial Monitor set to 9600 baud for debugging and setup

📁 Project structure

Microcontroller-based-DIY-Smart-Lock/
├── CSE323_PROJECT/
│   └── CSE323_PROJECT.ino
├── HARDWARE SETUP/
│   └── CSE323 Project Hardware Circuit setup.pdf
├── Delay-Timer-Circuit-using-IRFZ44N.jpg
├── Introduction-to-IRFZ44N_3.png.png
├── LICENSE
├── pinout-Arduino-Mega2560__1.png
├── pinout-Arduino-Mega2560__2.png
├── ProjectCode.zip
└── README.md

Project setup

📌 Pin diagram

The following Arduino Mega 2560 pin diagram shows the main board connections and pin layout used during the hardware setup.

Arduino Mega 2560 pin diagram

How to setup the project

Use the files in this repository in this order:

  1. Open the hardware setup guide in HARDWARE SETUP/CSE323 Project Hardware Circuit setup.pdf to wire the Arduino Mega 2560, MFRC522 reader, LEDs, relay/MOSFET, and 12V solenoid correctly.
  2. Open CSE323_PROJECT/CSE323_PROJECT.ino in the Arduino IDE and make sure the required libraries are available: SPI.h, EEPROM.h, and MFRC522.h.
  3. Upload the sketch to the Arduino Mega 2560 using the pin mapping defined in the code:
    • MFRC522 RST → pin 5
    • MFRC522 SDA/SS → pin 53
    • SPI MOSI → pin 51
    • SPI MISO → pin 50
    • SPI SCK → pin 52
    • LEDs → pins 6, 8, and 10
    • Relay/MOSFET control → pin 11
    • Wipe button → pin 33
  4. Power the circuit with the 12V supply and then open the Serial Monitor at 9600 baud to follow the setup process.
  5. Scan a tag to define it as the master card, then use other RFID cards to grant or deny access. Press and hold the wipe button to clear stored RFID records if needed.

This setup is based on the main sketch, the hardware circuit guide, and the Arduino Mega pin diagram files included in the project folder.

⚙️ How it works

  1. The Arduino boots and initializes the SPI communication with the MFRC522 reader.
  2. The system waits for an RFID tag to be scanned.
  3. If the scanned card matches the stored master card, the device enters programming mode.
  4. In programming mode, new cards can be added or removed from EEPROM memory.
  5. In normal mode, authorized tags unlock the solenoid for a short time, while unknown tags trigger the denied signal.
  6. The wipe button can erase the stored access records when you want to reset the system.

Troubleshooting

  • If the MFRC522 reader is not detected, check the SPI wiring and ensure the correct SS/RST pins are connected.
  • If the relay or solenoid does not respond, verify the MOSFET/relay driver circuit and the 12V supply.
  • If the serial monitor shows no output, confirm that the board is connected and the baud rate is set to 9600.
  • If cards are not being recognized, re-scan the master card and confirm the RFID library is installed correctly.

🎥 Demonstration

Watch the project demonstration video below to see the smart lock in action.

Smart Lock Demonstration

Click the image above to open the YouTube video in a new tab.

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.