ESP32 CAM Smart Door Lock for ESP32-CAM
An ESP32 camera project for AI Thinker ESP32-CAM involving OLED display, Camera module.
Parts and sourceBefore you start
Check the exact OLED display, Camera module configuration against the upstream wiring or parts list.
Upstream README
๐ ESP32-CAM Smart Door Lock System
An AI-powered smart door lock system using ESP32-CAM, Edge Impulse, and Arduino IDE for offline face recognition and secure access control.
๐ Overview
This project is a Face Recognition Based Smart Door Lock System developed using the ESP32-CAM module and Edge Impulse TinyML.
Unlike cloud-based face recognition systems, this project performs completely offline face recognition without requiring an internet connection.
To improve power efficiency, the ESP32-CAM remains in sleep mode until motion is detected by the PIR sensor. When a person is detected, the camera wakes up, captures the face, performs face recognition using the trained Edge Impulse model, and unlocks the door only if the face belongs to an authorized user.
โจ Features
- ๐ Offline AI-based Face Recognition
- ๐ท ESP32-CAM Camera Module
- ๐ค PIR Motion Detection
- โก Relay Controlled Door Lock
- ๐ Automatic Door Unlock
- ๐ Automatic Door Relock
- ๐ก Flash LED during face detection
- ๐ข Status LED for successful authentication
- ๐ด Sleep Mode for low power consumption
- ๐ No Internet Required
โ๏ธ Working Principle
- ESP32-CAM remains in sleep mode.
- PIR sensor detects human movement.
- ESP32-CAM wakes up.
- Flash LED turns ON.
- Camera captures the user's face.
- Edge Impulse model performs face recognition.
- If the face matches a registered user:
- Relay turns ON
- 12V Solenoid Lock unlocks
- Green LED turns ON
- After a predefined delay:
- Relay turns OFF
- Door locks automatically
- ESP32-CAM returns to sleep mode.
If an unknown face is detected, the door remains locked.
๐ Hardware Used
| Component | Quantity |
|---|---|
| ESP32-CAM (AI Thinker) | 1 |
| PIR Motion Sensor | 1 |
| 5V Relay Module | 1 |
| 12V Solenoid Door Lock | 1 |
| LED | 1 |
| Breadboard | 1 |
| Jumper Wires | Several |
| USB to TTL Programmer | 1 |
| 12V Power Supply | 1 |
๐ป Software Used
- Arduino IDE
- Edge Impulse
- ESP32 Board Package
- C++
๐ง Machine Learning Model
The face recognition model was trained using Edge Impulse.
Multiple images of authorized users were captured and used for training. The trained model was exported as an Arduino library and integrated into the ESP32-CAM project along with PIR sensor, relay, LED, and sleep mode functionality.
๐ Repository Structure
ESP32-CAM-Smart-Door-Lock
โ
โโโ Code
โ โโโ ESP32_CAM_Door_Lock.ino
โ โโโ README.md
โ
โโโ Images
โ โโโ Breadboard connection.jpg
โ โโโ ESP_32 CAM &PIR.jpg
โ โโโ README.md
โ
โโโ Demo
โ โโโ Working.mp4
โ โโโ README.md
โ
โโโ LICENSE
โโโ README.md
๐ธ Hardware Setup
Complete Hardware Setup

ESP32-CAM and PIR Sensor

๐ฅ Demonstration
The working demonstration video is available in the Demo folder.
๐ Demo/Working.mp4
๐ Getting Started
Clone the Repository
git clone https://github.com/roopankumar1404/ESP32-CAM-Smart-Door-Lock.git
Open
Code/ESP32_CAM_Door_Lock.ino
using Arduino IDE.
Install Required Libraries
- ESP32 Board Package
- Edge Impulse Library
Upload
Connect the ESP32-CAM using a USB-to-TTL programmer and upload the sketch.
๐ฎ Future Improvements
- Mobile Application Integration
- Visitor Log Storage
- Cloud Notifications
- RFID Backup Authentication
- Fingerprint Authentication
- Battery Backup
- OLED Status Display
- Remote Door Unlock
๐จโ๐ป Author
Roopan Kumar
Electronics and Communication Engineering
GitHub: https://github.com/roopankumar1404
๐ License
This project is licensed under the MIT License.
โญ If you found this project useful, consider giving this repository a star.