Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to build a facial recognition system using ESP32-CAM

By Nikhil Agnihotri February 20, 2024

Facial recognition technology identifies individuals by analyzing and comparing their facial features. It uses biometric patterns and algorithms to map and distinguish a person’s unique characteristics. The technology has become an essential component of many security applications. 

Facial recognition is commonly used for access control, surveillance, biometric authentication, identity verification, criminal identification, attendance, emergency response, and fraud prevention. 

What if you could build a facial recognition system for under $20? This is possible with an ESP32 camera. The ESP32-CAM module typically costs around US $10 (though prices may vary), and is capable of still pictures, video streaming, and facial recognition. In this project, we build a facial recognition system using the ESP32-CAM with Arduino. 

Components required

  1. ESP32-CAM x1
  2. Arduino UNO or MEGA x1
  3. USB cable to connect Arduino with computer
  4. Jumper wires

ESP32-CAM
ESP32-CAM is a development board that combines the ESP32 microcontroller with a camera module, so it’s capable of capturing images and streaming video over Wi-Fi. It’s popular among developers and hobbyists for Internet-of-Things (IoT) applications and projects requiring a camera. 

ESP32-CAM has a two-megapixel OV2640 camera and an onboard TF card slot. The camera supports JPEG and BMP image formats and several modes like single shot, burst, etc. The module is based on the Dual-core Tensilica LX6 microprocessor, a low-power 32-bit CPU. It has an integrated 4 MB flash memory for program storage and a MicroSD card slot can be used for additional storage. It has built-in WI-FI and Bluetooth, and the camera module can stream video over Wi-Fi. 

ESP32-CAM has the following pin diagram:

The module has two pins for power – 3.3 and 5V – and three ground pins. Two pins are for the universal asynchronous receiver/transmitter (UART) communication. It does not have a USB port, so the UART port must be used to upload code via an FTDI programmer or Arduino. When uploading code, the GPIO0 of the module must be connected to the ground. 

Circuit connections
For this project, we’ll use Arduino to upload the sketch to ESP32-CAM. Either Arduino UNO or Arduino MEGA works well. 

The steps:

  • Connect GPIO1 (U0_TXD) and GPIO3 (U0_RXD) with Arduino’s TX and RX pins
  • Connect ESP32-CAM’s 5V and ground pin with Arduino’s 5V out and GND pins. 
  • Connect Arduino’s RESET pin to its ground pin. 
  • Upon uploading the sketch, connect ESP32-CAM’s GPIO0 with its ground pin.
  • After uploading the sketch, remove the connection between ESP32-CAM’s GPIO0 and ground pins. 

Circuit diagrams
This circuit diagram shows the connections between Arduino and ESP32-CAM when uploading the sketch.

The following circuit diagram shows the connections between Arduino and the ESP32-CAM for the camera after uploading the sketch. Note, the connection between ESP32-CAM’s GPIO0 and ground pins are removed.

The sketch
Before uploading the sketch, you must install ESP32’s add-on and the ESP32 library in Arduino IDE. For ESP32’s add-on, navigate to File->Preferences, and add the following lines under the ‘Additional Board Manager URLs.’ Then, click ‘OK.’

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

Next, open the board manager by navigating to Tools-> Board -> Board Manager. Search for ESP32 and install ‘ESP32 by Espressif Systems.’

After installing the ESP32 add-on, navigate to File-> Examples -> ESP32 -> Camera, and open the CameraWebServer example. In the CameraWebServer example, you must disable ESP32-CAM’s Brownout feature. To do so, add the following libraries from the beginning of the example.

#include “soc/soc.h”
#include “soc/rtc_cntl_reg.h”

In the setup() function, add one more line of code as follows:

WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);

In the example code, uncomment the following line of code:

#define CAMERA_MODEL_AI_THINKER // Has PSRAM

Replace the SSID and password assignments with the SSID and network key of your WI-FI connection.  The complete sketch of the modified example is provided below.

#include “esp_camera.h”
#include <WiFi.h>
#include “soc/soc.h”
#include “soc/rtc_cntl_reg.h”

The code

Uploading the sketch
First, complete the circuit connections as instructed above for uploading the code. Remember, to connect ESP32-CAM’s GPIO0 with its ground pin to properly upload the sketch.

Connect Arduino with your computer using a USB cable. Select ‘ESP32 Wrover Module’ as the board and set the following parameters under ‘Tools.’

Compile and upload the sketch by clicking the upload button on Arduino IDE.

Get the IP address
After uploading the code, remove the connection between ESP32-CAM’s GPIO0 and GND pins. Open Arduino IDE’s Serial Monitor and set its baud rate to 115200 bps. Press the reset button on ESP32-CAM and wait for the camera to connect with WI-FI.

After the camera is successfully initialized and connected to the Internet, the IP address that connects to the video streaming server will be printed on the Serial Monitor.

Accessing the video streaming server
Open the IP address obtained from ESP32-CAM in any Web browser. The video streaming server should open. Scroll down, and click ‘Start Stream.’

Here’s a video stream by ESP32-CAM over WI-FI.

You may also like:


  • How to use the TCS230/TCS3200 color-recognition sensor with Arduino

  • How to manage data on ESP32 for IoT projects

  • How to make HTTP requests using Arduino for the IoT

  • How to send email alerts from Arduino/ESP8266/ESP32 through IFTTT

  • The top computer vision tools for embedded systems

  • How to send SMS alerts from ESP32 without a GSM…

Filed Under: Tutorials, Video
Tagged With: camera, ESP32, facialrecognition, MicroPython ESP32 ADC, securitysystem, tutorial
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Diode recovery test Irrm timing.
  • How to make string LEDs?
  • The Analog Gods Hate Me
  • Battery Deep Discharge – IC Workarounds?
  • Safe Current and Power Density Limits in PCB Copper(in A/m² and W/m³) simulation

RSS Electro-Tech-Online.com Discussions

  • Raise your hand if your car had one of these:
  • Tektronix 2235 channel 1 trace unstable
  • How to make string LEDs?
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz
  • The Analog Gods Hate Me

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • Tria modules integrate edge AI processing with multi-core processors
  • pSemi introduces RF switch with 52 dBm PMAX,PEAK and 90-dBm IIP3 linearity
  • XP Power launches 1.3 kW power supply with 58.9 W/cm³ density
  • How to enable Wi-Fi provisioning in ESP32-based IoT products
  • Amphenol RF introduces FAKRA to SMA adapters with 4 GHz operating frequency

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe