The circuit design incorporates an ESP32-CAM module, which is the central processing unit capable of image capture and face recognition. The circuit also includes a solenoid, a voltage regulator, two LEDs (green and red), a 1-channel relay, a 9V battery, an electrolytic capacitor, and a 2-pin push switch. The ESP32-CAM is responsible for capturing images and running the embedded code for face recognition, which interacts with other components to trigger actions based on the recognition results.
5V
to Voltage Regulator IN
GND
to common groundIO12
to Green LED anode
IO13
to Red LED anode
IO2
to Relay signal
IO14
to Push Switch Output +
pin1
to Relay NO
pin2
to Relay C
GND
to common groundOUT
to ESP32-CAM 5V
IN
to 9V Battery +
cathode
to common groundanode
to ESP32-CAM IO12
cathode
to common groundanode
to ESP32-CAM IO13
NC
not connectedsignal
to ESP32-CAM IO2
C
to Solenoid pin2
power
to Voltage Regulator OUT
NO
to Solenoid pin1
ground
to common ground+
to Voltage Regulator IN
-
to common ground+
to Voltage Regulator IN
-
to common groundInput +
to Voltage Regulator OUT
Output +
to ESP32-CAM IO14
The embedded code for the ESP32-CAM is written in C++ and is designed to perform face recognition using the camera module. The code includes the Blynk library for IoT applications, allowing remote interactions and notifications. The camera initialization and configuration are set up in the setup()
function, while the loop()
function continuously checks for button presses to trigger face recognition and take photos. The code also includes a web server setup for streaming video and capturing images, which can be accessed via HTTP requests.
The face recognition algorithm uses a multi-task cascaded convolutional neural network (MTCNN) for detecting faces and a recognition model to match detected faces with enrolled faces. When a known face is detected, the green LED is turned on, and the solenoid can be activated to unlock a door. If an unknown face is detected, the red LED is turned on.
The code also includes HTML and CSS files for the web interface, which provides a live video stream from the camera and buttons for controlling the camera settings and face recognition features.
The camera pins are defined in a separate header file, camera_pins.h
, which maps the ESP32-CAM GPIOs to the camera module pins based on the selected camera model. The web server functionality is implemented in app_httpd.h
, which sets up the endpoints for the web interface and handles HTTP requests for streaming video, capturing images, and controlling camera settings.