The problem
Digital Code Lock with Intruder Photo Capture using ESP32-CAM is a physical door lock that replaces keys with a PIN and photographs anyone who guesses the code wrong. A 4x4 matrix keypad provides 16 keys (datasheet value), so a 4-digit PIN gives 10,000 combinations (a defensible count). The controller — an Arduino/ESP32-class board — scans the keypad, compares the entered digits against the stored PIN, and on a match drives a relay that energizes a 12V DC solenoid/electric-strike lock. The coil retracts the steel bolt and the door releases for a configurable few-second window. On a wrong PIN the controller refuses the strike and increments a failure counter; after a configurable number of consecutive wrong attempts it wakes the ESP32-CAM's OV2640 2MP camera (datasheet value), captures a frame, and pushes it to the owner's Telegram chat over Wi-Fi. A buzzer sounds on each failure, repeated attempts trigger a lockout timer, and an admin mode lets the owner change the PIN.
Stands at the door and enters the PIN on the keypad.
Follow the working sequence
How it works
The lock runs a continuous sense-decide-actuate loop. The controller polls the 4x4 keypad row-by-row (matrix scanning) and buffers each keypress, echoing a masked character to the 16x2 LCD so the code stays hidden from onlookers. When the entered length matches the configured PIN length, the controller compares the buffer against the PIN stored in non-volatile EEPROM; a match energizes the relay, the 12V solenoid coil pulls the strike bolt back, and the door stays released for a few seconds before re-locking automatically. A mismatch raises the failure counter and sounds the buzzer. When failures reach the configured threshold, the controller powers the ESP32-CAM, commands a JPEG capture from the OV2640, and posts the frame to the owner's Telegram chat as an intruder alert. Crossing the repeat-attempt limit starts a lockout timer that ignores keypad input entirely. Entering admin mode with the master code opens PIN-change and threshold-setting options that persist in EEPROM.
- The controller scans the 4x4 keypad in a matrix loop (rows driven one at a time, columns read), buffers each keypress, and shows a masked character per digit on the 16x2 LCD.
- When the buffered length reaches the configured PIN length, the firmware compares it with the PIN stored in EEPROM; on a match it energizes the relay, the 12V solenoid coil retracts the strike bolt, and the door releases for the configured open window before re-locking.
- On a mismatch the controller increments the wrong-attempt counter, sounds the buzzer, and the LCD shows the remaining attempts before escalation.
- When consecutive failures reach the configured threshold (design target: 3), the controller wakes the ESP32-CAM, captures a JPEG from the OV2640 camera, and posts it to the owner's Telegram chat as an intruder alert.
- If failures continue past the repeat-attempt limit, a lockout timer (design target: 60 seconds) starts and all keypad input is ignored until it expires.
- The owner can enter admin mode with the master code to change the user PIN, the photo trigger threshold and the lockout duration — stored in EEPROM so they survive power cycles.
Tech stack:
- ESP32-CAM (OV2640 camera) + Arduino/ESP32-class controller
- 4x4 matrix keypad, 16 keys (datasheet value)
- 12V DC solenoid / electric-strike lock
- 5V relay module with opto-isolation
- Telegram Bot API (photo alerts over Wi-Fi)
- 16x2 character LCD
- EEPROM for PIN and settings storage
- Arduino IDE, C/C++ firmware
| Parameter | Value |
|---|---|
| Keypad | 4x4 matrix, 16 keys (datasheet value) |
| PIN combinations (4-digit PIN) | 10,000 (defensible count) |
| Controller | Arduino Uno / ESP32-class board (design choice) |
| Camera | ESP32-CAM with OV2640 2MP sensor (datasheet value) |
| Strike mechanism | 12V DC solenoid / electric-strike lock, energized-to-release (datasheet value of chosen part) |
| Relay | 5V single-channel module with opto-isolation (design choice) |
| Photo trigger | After 3 consecutive wrong PINs (design target, adjustable in admin mode) |
| Lockout duration | 60 seconds (design target, adjustable in admin mode) |
| Unlock open window | Approximately 5 seconds (design target, adjustable) |
| Alert delivery | JPEG photo to Telegram bot over Wi-Fi (expected behavior) |
| Display | 16x2 character LCD (design choice) |
| Power | 12V DC adapter for the solenoid; separate regulated 5V for controller and ESP32-CAM (design requirement) |
Project features
Three capabilities define this build. First, keypad PIN access control: a 4x4 matrix keypad (16 keys, datasheet value) feeds an Arduino/ESP32-class controller that validates a configurable-length PIN and drives a 12V DC solenoid strike through an isolated relay — 4-digit codes give 10,000 combinations (defensible count), and the firmware masks typed digits on the 16x2 LCD so onlookers cannot read the code. Second, evidence capture on tamper: the ESP32-CAM's OV2640 2MP camera (datasheet value) photographs the doorway after a configurable number of consecutive wrong PINs and delivers the frame to the owner's phone through a Telegram bot — no subscription, just Wi-Fi and the free Telegram Bot API. Third, tamper response in the hardware loop: a buzzer sounds on every failed attempt, a lockout timer freezes keypad entry after repeated failures, and admin mode lets the owner change the PIN or reset the lock without reflashing the firmware.
- [Keypad PIN access control] The 4x4 matrix keypad (16 keys, datasheet value) is scanned row-by-row by the controller; a configurable-length PIN (default 4 digits, 10,000 combinations) is compared against the EEPROM-stored code, with typed digits masked on the LCD.
- [Solenoid strike actuation] On a PIN match the controller drives a 5V relay that switches the 12V DC solenoid/electric-strike lock — the energized coil retracts the bolt and releases the door for an adjustable open window, then re-locks automatically.
- [Intruder photo capture] After a configurable number of consecutive wrong PINs, the ESP32-CAM captures a frame with its OV2640 2MP camera (datasheet value), pointed at the doorway where the person entering the code stands.
- [Telegram intruder alerts] The captured JPEG is posted over Wi-Fi to the owner's Telegram chat via a Telegram bot — the owner receives the intruder's photo within seconds, with no cloud subscription involved.
- [Buzzer and lockout tamper response] A buzzer sounds on every wrong attempt; crossing the repeat-attempt limit starts a lockout timer that ignores keypad input, deterring rapid guessing even though the code space itself is finite.
- [Admin mode] Entering a master code opens an admin menu to change the user PIN, adjust the wrong-attempt threshold and the lockout duration — all persisted in EEPROM, no firmware reflash needed.
- [LCD status display] A 16x2 LCD shows masked entry progress, LOCKED/UNLOCKED states, failure counts and lockout countdowns, giving the demonstrator and the viva panel full visibility.
What is included
- Working prototype: 4x4 keypad panel, controller board, ESP32-CAM module, relay module, 12V DC solenoid/electric-strike lock with strike plate, buzzer and 16x2 LCD
- Complete firmware: keypad matrix scanning, PIN compare, lockout logic, admin mode, ESP32-CAM capture and Telegram photo push
- Circuit diagram and wiring guide, including flyback-diode placement across the solenoid coil and the separate 5V supply requirement for the ESP32-CAM
- Builder notes documenting the two most common failure modes of this build (diode-less relay arcing; camera brown-out on weak 5V)
- Project report PDF (background, mechanism, firmware design, wiring, testing procedure)
- PPT presentation for final review
- Viva Q&A preparation document (matrix scanning, EEPROM, inductive kickback, Wi-Fi + Telegram API)
Limitations & prerequisites
- The OV2640 captures usable frames only in lit conditions — a dark doorway yields a dark photo; low-light or IR-illuminated capture is future scope.
- Telegram photo alerts need working Wi-Fi and the owner's phone online; the keypad, solenoid and lockout logic all keep working locally without network.
- The strike is demonstrated on a prototype panel — mortising a real door frame and routing final wiring is the buyer's installation work, guided by the manual.
- The base build ships without battery backup — on a mains cut the fail-secure bolt stays engaged, so the door cannot be opened until power returns.
- No face recognition is implemented — the photo is delivered for the owner to review visually, not identified on-device.
- The solenoid needs a dedicated 12V supply rated to the part's datasheet current; USB or controller-board power is insufficient for the lock coil.
- A 4-digit PIN offers 10,000 combinations — brute forcing is deterred by the lockout timer and the photo evidence, not by code space alone.
Frequently Asked Questions
How does the intruder photo capture actually work?
When consecutive wrong-PIN entries reach the configured threshold — 3 by default, adjustable in admin mode — the controller commands the ESP32-CAM to take a photo with its OV2640 2MP camera and sends that JPEG to the owner's Telegram chat as an intruder alert. The capture fires on the threshold attempt rather than on every single wrong keypress, which keeps the owner from being spammed by one fumbling user. The camera is aimed at the doorway so the person entering the code is in frame; Wi-Fi must be available or the alert is skipped while local locking keeps working.
Why does the solenoid need a flyback diode across its coil?
Because a solenoid coil is an inductor: the instant the relay contacts open, the collapsing magnetic field generates a high-voltage reverse spike across the coil, and without a diode to clamp it that spike arcs across the relay contacts and can punch into the controller. A 1N4007 diode soldered directly across the coil (cathode toward the +12V lead) gives that current a harmless recirculation path. This is the single most common reliability failure in student solenoid-lock builds — relays that pit, weld or chatter after a few weeks are almost always missing this diode.
Why does the ESP32-CAM need its own clean 5V supply during photo capture?
The OV2640 sensor plus the ESP32's Wi-Fi radio draw sharp current bursts while capturing and transmitting a photo, and a weak or shared supply sags below the camera's operating voltage — the result is brown-out resets, corrupt JPEGs, or a module that hangs mid-upload. The reliable build runs the ESP32-CAM from its own regulated 5V source with short, thick power wiring, separate from the solenoid's 12V line and the controller's logic rail. This is the second most common failure mode in this project and is called out explicitly in the wiring guide.
How many PIN combinations does the lock offer?
A 4-digit PIN on the 16-key keypad gives 10,000 combinations (0000–9999, a defensible count); the firmware supports longer PINs, so 6 digits raises this to 1,000,000 combinations — though real deterrence also comes from the photo evidence and the lockout timer. The PIN is stored in EEPROM and can be changed in admin mode without reflashing. For the demo and the viva, avoid trivial codes like 0000 or birthdays — the report documents how the lockout timer, not the code space alone, stops rapid guessing.
What happens if the power fails or the Wi-Fi goes down?
The locking stays safe: the solenoid is fail-secure, so without power the bolt stays engaged and the door remains locked — but nobody can enter via the keypad either until power returns, since the base build ships with no battery backup. A Wi-Fi outage only disables the Telegram photo alerts; PIN validation, the solenoid, the buzzer and the lockout timer all run locally on the controller. An optional battery or UPS for the controller rail is listed as future scope.
Is this project suitable for a final-year project?
Yes — for Electronics, E&TC and IoT & Embedded programs. It combines embedded firmware, keypad matrix scanning, EEPROM-backed configuration, power-electronic switching of an inductive solenoid load, and a working Wi-Fi-to-Telegram IoT alert pipeline in one demonstrable, buyer-testable build from day one. Viva angles are strong: matrix keypad scanning, EEPROM persistence, the physics of inductive kickback and why the flyback diode exists, and the Wi-Fi-to-Telegram alert path. Every demo claim is buyer-testable — the wrong-PIN photo delivery and the lockout timer can be shown live — and the honest limitations give the student a genuine discussion section.
Components & software requirements
- ESP32-CAM (OV2640 camera) + Arduino/ESP32-class controller
- 4x4 matrix keypad, 16 keys (datasheet value)
- 12V DC solenoid / electric-strike lock
- 5V relay module with opto-isolation
- Telegram Bot API (photo alerts over Wi-Fi)
- 16x2 character LCD
- EEPROM for PIN and settings storage
- Arduino IDE, C/C++ firmware
Delivery information
Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.
Support terms
Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.
Download free synopsis (PDF)
Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.