ESP32 Cam Face Recognition Door Lock System circuit and programming

(Last Updated On: September 7, 2020)

ESP32 CAM Face Recognition

ESP32 Cam Face Recognition, Description:

ESP32 Cam Face Recognition Door Lock System– This is my third tutorial on the ESP32 Camera module. In this tutorial, you will learn how to make Face Recognition based Door Lock Control system using ESP32 Camera Module and a 12V electronic lock. For the Authorized person, the onboard white LED is turned ON and also the electronic lock is opened. This ESP32 Camera based face recognition door lock control system depends on my previous two tutorials.

ESP32 CAM Face Recognition

In my first video tutorial I explained how to program the ESP32 Camera using the Arduino IDE, In this tutorial, I covered the basic settings including the ESP32 Camera board manager installation and I also explained how to fix the most common errors including the Detected Camera not supported and the Camera Probe failed with error 0x20004, I also explained some other issues. You should read this article, if you are using the ESP32 Cam for the first time, otherwise you won’t be able to upload the program.

ESP32 CAM Face Recognition

While in my second tutorial, I designed development board for the ESP32 Camera Module, so that the ESP32 Cam Module can be easily used with other I/O devices. So, I high recommend first read my previous two tutorials and then you can resume from here. Because in this tutorial, I will not explain the things, which I have already explained in my previous two tutorials. In this tutorial, I will only explain the new things including the modified circuit diagram, Interfacing, and programming.

Without any further delay, let’s get started!!!


Amazon Purchase Links:

ESP32 Camera Module:

Arduino Uno:

One Channel 12V relay Module:

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

ESP32 CAM Face Recognition Project Circuit Diagram:

ESP32 CAM Face Recognition

This is the schematic of the top PCB board. As you can see there is nothing complicated. Male Headers are connected with the Power Supply and I/O pins of the ESP32 Camera Module. The SV3 and SV4 male headers are used to make connection with the bottom circuit board. The JP1 and JP2 male headers are used to connect 3.3V and 5v Lipo Battery. While all the other male headers are used for interfacing Sensors and other output devices.

The top circuit remains the same; I didn’t even change a single connection. Now let’s have a look at the bottom circuit.

ESP32 CAM Face Recognition

The 5V regulated power supply and the headers connections with the ESP32 Camera module remains the same. This time I added a one channel relay module which is used to control the electronic lock. The One Channel relay module is controlled using the IO Pin 12 of the ESP32 Camera module. The onboard white LED is connected with the IO4.

Following are the final circuit boards, which I have already explained in my previous article.

ESP32 CAM Face Recognition

High quality & Only 24 Hours Build time

Using these top and bottom circuit boards, we can easily connect different types of IO devices and can monitor and control different electronic sensors and output devices without any problem. As in this tutorial is about the door lock control system and for this we will need an electronic lock that we can control through electrical signals.



ESP32 CAM Face Recognition

You can see a 12V Electronic Lock provided with two Red and Black wires. Red is the 12V wire and of course Black is the ground wire. When these wires of the Electronic Lock are connected with the 12Vdc power supply the Electronic Lock will get open. You can see I have soldered a female type power jack. You might be wondering why have I cut the Red wire?

If you don’t cut this wire and connect the 12Vdc power supply the Electronic Lock will remain Open forever until you disconnect the 12V power supply. For the automatic control of the Electronic Lock we need to cut one of the two wires. So I selected the Red wire and cut it. Now if you connect the 12Vdc power supply with the DC Female Power jack and you touch the two heads of the Red wire, the Electronic Lock open and if you disconnect the two heads of the red wire the Electronic Lock will close again. So by connecting and disconnecting the red wires we can control the Electronic Lock. Instead, of manual connecting and disconnecting these red wires, we will use a relay.

ESP32 CAM Face Recognition

The Red wires are connected with the 12V SPDT Type relay Normally Open and Common contacts. Now by turning ON and turning OFF this relay the Electronic Lock can be controlled automatically using the ESP32 Cam Module. You can use a readymade relay module or you can make the one by yourself by following the circuit diagram. Now, to control this relay we will need to connect this with the ESP32 Camera module.

ESP32 CAM Face Recognition

I soldered the 12V and GND wires from the relay module with the 12V and Ground points of the power supply and connected the relay module input wire with the IO12 of the ESP32 Camera module.

ESP32 CAM Face Recognition

I completed my connections as per the circuit diagram already explained. Now let’s have a look at the programming.


ESP32 CAM Face Recognition and Door Lock Programming:

Before, you are going to start the programming, first of all, make sure you have installed the ESP32 Cam Board.

This is the same exact program I used in my previous two tutorials, this time I made a few changes, I defined pins for the LEDs and the electronic lock. I also defined two variables matchFace and openLock of the type Boolean. I also defined an interval of 6 seconds. When the face is recognized, the electronic lock will remain open for 6 seconds.

In the end two conditions, which locks and unlocks the electronic lock and also controls the LEDs.

ESP32 CAM Face Recognition

To compile and upload this code successfully, you will also need the app_httpd.cpp, camera_index.h, and camera_pins.h files.

Download Full Project Code

Now the final step is to upload the code. While uploading the code you might get an error as you can see in the picture below.

ESP32 CAM Face Recognition

Don’t worry at all the code will upload anyway.


ESP32 Cam Face Recognition Door lock control system Project Testing:

I started off by powering up the Electronic Lock and the ESP32 Camera Module using a 12V adaptor. You will need the local IP address for the live video streaming using the same wifi network. I have already explained this in the first article.

ESP32 CAM Face Recognition

So, I know about my local IP address. Turn ON the Face Detection and Face Recognition and click on the start stream button. Click on the Enroll face and start taking the samples, when everything is done successfully the electronic lock will open and also the white LED will turn ON.

ESP32 CAM Face Recognition

It will take some samples, when the samples taking process is completed. Then the ESP32 Camera module can recognize the face and it will activate the Electronic Lock and will also turn ON the onboard White LED.

ESP32 CAM Face Recognition

As you can see, everything is done successfully, if you find it hard to follow the steps, watch video tutorial, given in the end of this article.

You can see the text welcome on the recognized face. You can change this text, you can write the person name or you can write anything. For this you will need to open the app_httpd.cpp file. If you scroll down you will see the welcome text, you can change this, you can also see the intruder Alert! Text, this is for the unauthorized person, you can also change this text.



ESP32 CAM Face Recognition

I hope you have learned something new from this article. Don’t forget to subscribe to my website and YouTube channel “Electronic Clinic”.

Watch Video Tutorial:

 

Other Image processing Projects:

·         Arduino Image Processing based Entrance lock Control System

·         Forest Fire Detection System using Arduino and Image Processing vb.net

·         Arduino Image processing CCTV camera system using VB.net

·         Arduino image processing Eye Pupil Tracking, how to make Haarcascade XML file

·         OCR Optical Character recognition using VB.net and Arduino

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply