Smart Door Lock System using ESP32, RFID, Keypad, Servo Motor, and Blynk IoT
- LearnElectronics
- 2 days ago
- 5 min read
Introduction of the Smart Door Lock Project
Traditional door lock systems provide basic security, but they lack flexibility, remote accessibility, and advanced authentication methods. With the rise of IoT and smart home technologies, it is now possible to create intelligent access control systems that can be monitored and controlled from anywhere in the world.
In this project, we will build a Smart Door Lock System using ESP32, RFID authentication, a 4x4 keypad, a servo motor, LEDs, a buzzer, and Blynk IoT. The system allows users to unlock the door using an RFID card, a keypad password, or remotely through the Blynk mobile application.
This project can be implemented both in the Wokwi simulation environment and on actual hardware with minimal modifications.

Features
RFID-based door authentication
Password-based keypad authentication
Remote door control using Blynk IoT
Servo motor-based locking mechanism
Green LED indication for successful authentication
Red LED indication for access denial
Audible buzzer alerts
Real-time IoT control through smartphone
Compatible with both simulation and real hardware
How the System Works
The Smart Door Lock System supports three different authentication methods:
RFID Authentication
When an RFID card is placed near the RC522 RFID reader:
ESP32 reads the card UID.
The UID is compared with the authorized UID stored in the code.
If the UID matches:
Access is granted.
Green LED turns ON.
Buzzer beeps.
Servo motor unlocks the door.
If the UID does not match:
Access is denied.
Red LED turns ON.
Long buzzer alert is generated.
2. Keypad Authentication
Users can unlock the door using a password.
Process:
Enter the password using the keypad.
Press # to submit.
ESP32 compares the entered password with the stored master password.
If the password is correct:
Door unlocks.
If incorrect:
Access denied alert is generated.
Example Password: 1234#3. Blynk IoT Authentication
The door can also be controlled remotely through the Blynk mobile application.
Process:
Open the Blynk App.
Toggle the switch widget.
Blynk Cloud sends the command to ESP32 through Wi-Fi.
ESP32 unlocks or locks the door.
This feature enables remote access control from anywhere with internet connectivity.
Components Required
Here we have provided 2 separate components list for both Wokwi Simulation as well as Hardware Implementation of the same project.
Components for Wokwi Simulation
Component | Quantity |
ESP32 Development Board | 1 |
RC522 RFID Reader | 1 |
RFID Card/Tag | 1 |
4x4 Matrix Keypad | 1 |
Servo Motor | 1 |
Red LED | 1 |
Green LED | 1 |
Piezo Buzzer | 1 |
220Ω Resistors | 2 |
Components for Hardware Implementation
Component | Quantity |
ESP32 Development Board | 1 |
RC522 RFID Reader | 1 |
RFID Card/Tag | 1 |
4x4 Matrix Keypad | 1 |
SG90 Servo Motor | 1 |
Red LED | 1 |
Green LED | 1 |
Piezo Buzzer | 1 |
Breadboard | 1 |
Jumper Wires | As Required |
220Ω Resistors | 2 |
USB Cable | 1 |
5V Power Supply | 1 |
Circuit Connections
RFID RC522 Connections
RC522 Pin | ESP32 Pin |
SDA (SS) | GPIO5 |
SCK | GPIO18 |
MOSI | GPIO23 |
MISO | GPIO19 |
RST | GPIO22 |
3.3V | 3.3V |
GND | GND |
Servo Motor Connections
Servo Pin | ESP32 Pin |
Signal | GPIO13 |
VCC | 5V |
GND | GND |
LED Connections
Green LED
LED Pin | ESP32 |
Anode | GPIO2 |
Cathode | GND through 220Ω resistor |
Red LED
LED Pin | ESP32 |
Anode | GPIO15 |
Cathode | GND through 220Ω resistor |
Buzzer Connections
Buzzer Pin | ESP32 |
Positive | GPIO4 |
Negative | GND |
Keypad Connections
Keypad Pin | ESP32 Pin |
R1 | GPIO12 |
R2 | GPIO14 |
R3 | GPIO27 |
R4 | GPIO26 |
C1 | GPIO25 |
C2 | GPIO33 |
C3 | GPIO32 |
C4 | GPIO21 |
Creating the Blynk IoT Dashboard
Step 1: Create a Blynk Account
Create an account and log in to the Blynk IoT platform.
Step 2: Create a New Template
Template Name: Smart Door Lock System
Hardware: ESP32
Connection Type: WiFi
Step 3: Create Datastream
Create a Virtual Datastream.
Parameter | Value |
Name | Door Control |
Pin | V1 |
Data Type | Integer |
Min | 0 |
Max | 1 |
Step 4: Create Dashboard
Add a Switch Widget.
Configure:
Property | Value |
Datastream | V1 |
Mode | Switch |
Save/Apply
Switch <=> Door relation
Switch ON = Unlock Door
Switch OFF = Lock Door
Step 5: Copy Credentials
Copy the following credentials:
BLYNK_TEMPLATE_ID
BLYNK_TEMPLATE_NAME
BLYNK_AUTH_TOKEN
Paste them into the Arduino code.
Wokwi Simulation Setup
Step 1 - Open Wokwi and create a new ESP32 project.
Step 2 - Add the following components:
ESP32
RC522 RFID Reader
RFID Tag
4x4 Keypad
Servo Motor
Buzzer
Green LED
Red LED
Step 3 - Make all circuit connections according to the wiring tables provided above.
Step 4 - Paste the Arduino code.
Step 5 - Insert your Blynk credentials.
Step 6 - Run the simulation.
The Smart Door Lock System is now ready for testing.
Wokwi Simulation -
Hardware Implementation
The wiring remains exactly the same as the Wokwi simulation. However, there are several additional considerations when working with real hardware.
Servo Power Supply Recommendation
A servo motor can draw significant current during operation. Current consumption may exceed: 500mA to 700mA Therefore, powering the servo directly from the ESP32 board is not recommended.
Use:
5V 1A adapter
5V 2A adapter
Power bank
for reliable operation.
Common Ground Requirement
When using an external power supply, ensure that all grounds are connected together.
Connect:
ESP32 GND
Servo GND
RFID GND
Power Supply GND
to a common ground. Failure to do this may result in unstable servo operation.
RFID Voltage Warning
The RC522 RFID module operates at 3.3V. Never connect the module to 5V. Doing so may permanently damage the RFID module.
Finding the RFID UID
Before using RFID authentication, you must know the UID of your RFID card.
Run the project once and scan your RFID card.
The Serial Monitor will display something similar to:
RFID Tag Detected: 04 5B 32 1ACopy this UID.
Locate the following line in the code:
if (tag == "01 02 03 04")Replace it with:
if (tag == "04 5B 32 1A")Upload the code again.
Your RFID card is now authorized.
Testing the System
Test 1: Correct RFID Card
Expected Result:
Green LED ON
Buzzer beep
Servo unlocks door
Test 2: Unauthorized RFID Card
Expected Result:
Red LED indication
Long buzzer alert
Door remains locked
Test 3: Correct Password
Enter: 1234#
Expected Result: Door unlocks successfully.
Test 4: Incorrect Password
Enter: 9999#
Expected Result: Access denied alert.
Test 5: Blynk Mobile Control
Turn ON the switch widget.
Expected Result: Door unlocks remotely.
Turn OFF the switch widget.
Expected Result: Door locks remotely.
Applications
This project can be used in:
Smart Homes
Offices
Hostels
Laboratories
Libraries
Smart Cabinets
Restricted Areas
Industrial Access Control Systems
Future Enhancements
The project can be extended with advanced security features such as:
Fingerprint Authentication
Face Recognition
OTP Verification
Telegram Notifications
Email Alerts
Camera Integration
Visitor Logging
Cloud Database Storage
Multiple User Management
Voice Assistant Integration
Conclusion
In this project, we successfully developed a Smart Door Lock System using ESP32, RFID technology, a keypad, and Blynk IoT. The system supports multiple authentication methods and remote access control, making it suitable for modern smart home and security applications.
The project can be easily simulated in Wokwi for learning purposes and deployed on real hardware for practical implementation. By combining RFID authentication, password protection, and IoT connectivity, the system provides a flexible and secure solution for access control applications.

Comments