

Features
- Motion-Triggered Image Capture
- PIR motion sensor detects movement and activates the camera.
- Real-Time Telegram Alerts
- The ESP32-CAM sends captured photos directly to Telegram along with alert messages.
- Remote Lock/Unlock Control
- Solenoid lock controlled through a relay, toggled via Telegram commands.
- Instant Notifications
- Receive alerts on your phone when someone approaches or stands near the system.
- Secure Remote Access
- User can verify the image and decide whether to lock or unlock the door.
Components Used
- ESP32-CAM, Microcontroller with built-in camera module
- PIR Motion Sensor, Detects motion and triggers camera capture
- Solenoid Door Lock, Physical locking mechanism
- Relay Module, Controls the solenoid lock through ESP32-CAM
- Jumper Wires, Internal connections
- Power Supply, Powering ESP32-CAM and solenoid lock
How it Works
- Motion Detected
- PIR motion sensor detects movement near the system.
- Camera Triggered
- ESP32-CAM captures an image instantly.
- Telegram Notification
- The captured image is sent to the user via Telegram along with a message.
- Remote Lock Control
- Inside the Telegram chat, the user can send lock/unlock commands.
- ESP32-CAM activates the relay → relay controls the solenoid lock.
Working
Smart Cam Security Lock System
Code, Installation & Circuit Diagram
The complete source code is available in the GitHub repository.
My Learnings
- How to work with the ESP32-CAM module (camera initialization, image capture, handling frame buffer, JPEG compression)
- Interfacing and configuring the PIR motion sensor for motion-based triggering
- Sending messages and photos through the Telegram Bot API, including:
- Chat ID authentication
- Handling HTTP requests to send images
- Controlling a solenoid lock using relay switching while managing power isolation between logic (ESP32) and load (lock)
- Secure remote access workflow: capture → notify → verify → control
- Managing Wi-Fi reconnection and avoiding blocking delays inside camera tasks
- Using non-blocking programming to handle:
- Camera capture process
- Telegram commands
- PIR trigger events
- Handling real-time IoT communication (Telegram commands → ESP32 actions)
