ESP32CAM Face Recognition Door Lock System


In this ESP32CAM project, I have made the ESP32CAM Face Recognition Door Lock System. You can enroll multiple faces in the esp32cam face detection automatic door lock. If it detects any enrolled face, the door will unlock automatically.

ESP32CAM Face Recognition Door Lock Face match

So this is a very useful smart home project using the esp32 camera module.

Circuit of the ESP32CAM Face Recognition Lock

Circuit ESP32CAM Face Recognition Door Lock

You can easily design this smart door lock with the camera using a 12v electronic lock, ESP32 CAM module, and some basic electronics components. 

Required Components for Face Detection Door Lock

Face detection Door Lock Components
  1. ESP32-CAM board
  2. Electronic door lock 12v
  3. 7805 voltage Regulator (5v)
  4. TIP122 NPN Transistor
  5. 10k Resistor (1no)
  6. 220-ohm Resistors (2no)
  7. Capacitor 220uF
  8. Diode 1N4007 (1no)
  9. LEDs 5-mm (2no)
  10. 12V DC adaptor
  11. FTDI232 USB to TTL conveter (for programming the esp32cam)

Programming ESP32-CAM board

Circuit esp32cam program

To program the ESP32CAM, I have used FTDI232 USB to Serial interface board. I have connected the FTDI232 with ESP32CAM as per the above circuit.

While uploading the code we have to connect GPIO 0 with the GND pin of ESP32CAM.

Before uploading the code to ESP32CAM, please check the following setting:

Face Recognition Door Lock Code
  • Update the Preferences –> Aditional boards Manager URLs:,
  • Board Settings:
    • Board: “ESP32 Wrover Module”
    • Upload Speed: “921600”
    • Flash Frequency: “80MHz”
    • Flash Mode: “QIO”
    • Partition Scheme: “Hue APP (3MB No OTA/1MB SPIFFS)”
    • Core Debug Level: “None”
  • COM Port: Depends On Your System
  • GPIO 0 must be connected to GND pin while uploading the sketch
  • After connecting GPIO 0 to GND pin, press the ESP32 CAM on-board RESET button to put the board in flashing mode

Tutorial video of ESP32CAM Face Recognition

In this tutorial video, I have shown how to make this DIY Face Recognition Door Lock System using esp32 cam step by step. For better understanding please watch the complete video.

Get the IP from ESP32-CAM

ESP32 CAM IP address
How to get the IP from ESP32CAM

1. After uploading the code disconnect GPIO 0 from GND pin.
2. Open Serial Monitor with Baud rate 115200.
3. Press the RESET button on the ESP32CAM board
4. Copy the IP Address from the last line.

Now connect all the components as per the circuit diagram. And give the 12v DC supply to circuit.

After that open any browser, then type the IP address to start the stream.
Now, we have to enroll faces.

1) Click on the Start Stream.
2) Turn on Face Detection and Face Recognition.
3) Click on Enroll Face.
4) Then ESP32CAM will take some sample pictures of the face.
5) At last, a green box will appear around the face.

In this way we can enroll multiple faces.

Finally, ESP32-CAM Face Recognition Lock is ready

ESP32CAM Face Recognition Door Lock Face match
Lock open after the face matched

Now, if the ESP32 CAM detects any enrolled face, it will unlock the door and Green LED will turn on for 6 seconds.

ESP32-CAM Face Recognition Door Lock Face not match
Lock closed as the Face does not matched

If the face does not match with the enrolled face, the door will remain lock as you can see in the above picture.

I hope you like this Smart home project using ESP32-CAM board.

You can also subscribe to our newsletter to receive more such useful electronics projects through email.

Please do share your feedback on this ESP32 project. Thank you for your time.

This Post Has 14 Comments

  1. Esa Malik

    Hey bro. I want to make this project for my house. Please can you help me in this. I’ve some doubts regarding unlocking and locking. I request you to please help me in this so that I finish my project and start using for my house

    1. techstudycell

      Please let me know your doubt. But this circuit has following limitation:
      The enrolled faces will delete from memory if you turn off the power.

  2. Esa Malik

    camera_pins.h: No such file or directory

    Im getting this error

  3. imad

    Can u help me making this

    1. techstudycell

      Sure.. If you face any problem you can always ask here…

  4. Prashant Vasala

    What if you are not at home and someone breaks into home? What if this ESP32-CAM can be used to send alert message to the owner. Is it possible. Please help me out

  5. Obaid

    Hi many thanks for your help but how can I turn on stream on boot of my esp 32 cam so it does not need to be activated all the time when I need to enter in my house(I have to enable stream from its web page every time).

  6. imad uddin

    Ok tnx

  7. imad uddin

    Can i get its docomnts

  8. imad

    Iam using espressif …..Module is there any difference between aithinker and pressif

  9. imad uddin

    Iam facing an error compiling code plx help me

  10. imad uddin

    I can not get ip from camera

  11. imad uddin

    I git some errors plx help me

  12. Cody Wessel

    Arduino: 1.8.13 (Windows Store (Windows 10), Board: “Arduino Uno”
    Arduino: 1.8.13 when I hit upload it says, “Code_FaceRecognitionDoorLock_ESP32CAM_01:25:10: fatal error: esp_camera.h: No such file or directory

    #include “esp_camera.h”


    compilation terminated.

    exit status 1

    esp_camera.h: No such file or directory

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.”



    Cody Wessel

Leave a Reply