We will learn in this project how to make a video streaming web server with with face recognition and detection on ESP32-CAM. More ESP32-CAM projects you can find here.
Tag: Project 136c How to make a video streaming web server with with face recognition and detection on ESP32-CAM AI-Thinker
- Libraries used: None
- Code: sketch
In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):
2. Arduino IDE ( you can download it from here )
3. USB to TTL/Serial adaptor/converter 1 pc
4. Jumper cables F-F
Understanding the USB to TTL converter
You can read more about them here.
Understanding the ESP32-CAM Development Board with camera
You can read more about it here.
Signals and connections of the ESP32-CAM Development Board with camera
- GND – ground pin. Connected to Arduino board GND pin.
- 5V – external power supply pin 5VDC 2A
- VCC – power supply pin. Connected to 5V pin.
- 3V3 – power supply pin. Connected to 3V3 pin.
- U0TXD, U0RXD – Serial pins. You need these pins to upload code to your board.
- GPIO 0 – pin which determines whether the ESP32 is in flashing mode or not. When GPIO 0 connected to GND, the ESP32-CAM is in flashing mode.
The following pins are internally connected to the Micro SD card reader:
- GPIO 14: CLK
- GPIO 15: CMD
- GPIO 2: Data 0
- GPIO 4: Data 1 (also connected to the on-board LED)
- GPIO 12: Data 2
- GPIO 13: Data 3
ESP32-CAM module FTDI programmer
U0TXD (GPIO1) RXI
U0RXD (GPIO3) TX0
GND and GPIO0 (for flashing only)
Step by Step instruction
We assume that you have the latest version the Arduino IDE and ESP32 add on installed in your Arduino IDE. You can read how to do it here – Basics: Project 137 Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, Linux). You can download the latest Arduino IDE version Windows Installer here. We are using PC with Windows 7 64 bit OS.
2.Uploading the code to ESP32-CAM
1.Do wiring. Very important: GPIO 0 (IO 0) must be connected to GND otherwise you will not be able to upload code.
2. Attach WiFi antenna (optional). It will help you to increase WiFi range.
3.Attach OV2640 camera.
4.Plug your FTDI programmer into your PC USB port.
5.Open Arduino IDE.
6.Go to Tools -> Board… -> ESP32 Arduino ->and select AI Thinker ESP32-CAM. Make sure you select the right camera module. In this project we use the AI-THINKER ESP32-CAM Development Board with camera.
7.Go to Tools -> Port and select the COM port the ESP32-CAM Development Board connected to (we have COM3).
6. Open this sketch in your Arduino IDE, modify with your local network data (ssid and password).
7.Click the upload button in Arduino IDE to upload the sketch. When you see Uploading… message press the ESP32-CAM Development Board on-board RST (RESET) button to restart your ESP32 in flashing mode.
9.When uploading completed disconnect GPIO 0 from GND.
10.Open the Serial Monitor of Arduino IDE (Tools -> Serial Monitor) at the baud rate of 115200. Press the ESP32-CAM Development board on-board RST (RESET) button.
11.The ESP32-CAM Development board IP address should be printed in the Serial Monitor (We have 192.168.0.113).
12.You can access your camera streaming server on your local network. Open any internet browser (IE,Google Chrome,..) (We used Google Chrome) and type the ESP32-CAM Development board IP address (we have http://192.168.0.113). Press the Start Streaming button to start video streaming.
13. You have the option to take photos by clickingon Get Still button. This example doesn’t save the photos, but you can modify it to use the on board microSD Card to store the captured photos. There are also several camera settings that you can play with to adjust the image settings.
14. Finally, you can do face recognition and detection. First, you need to enroll a new face. It will make several attempts to save the face. After enrolling a new user, it should detect the face later on (subject 0).
15. That’s it. You have your video streaming web server up and running with face detection and recognition with the example from the library now and you are ready for next project with ESP32-CAM.
If you don’t follow the previous instructions exactly, you may get the following errors:
1.Failed to connect to ESP32: Timed out waiting for packet header.
This error means that the ESP32-CAM is not in flashing mode or it is not connected properly to the FTDI programmer.
2. Brownout detector or Guru meditation error.
When you open your Arduino IDE Serial Monitor and the error message “Brownout detector was triggered” is constantly being printed over and over again. It means that there’s some sort of hardware problem.
It’s often related to one of the following issues:
- Poor quality USB cable;
- USB cable is too long;
- Board with some defect (bad solder joints);
- Bad computer USB port;
- Or not enough power provided by the computer USB port.
- Try a different shorter USB cable (with data wires);
- Use a different computer USB port or use a USB hub with an external power supply;
- Try to power the ESP32-CAM with 5V instead 3.3V.
3.Board at COMX is not available – COM Port not selected.
It means that you haven’t selected the COM port in the Tools menu. In your Arduino IDE, go to Tools -> Port and select the COM port the ESP32-CAM connected to.
It might also mean that the ESP32-CAM is not establishing a serial connection with your computer or it is not properly connected to the USB connector.
For a more extensive list of the most common problems with the ESP32-CAM and how to fix them, check out in our Basics: Project 084d ESP32-CAM Development Board with camera – Troubleshooting
Before uploading the code, you need to insert your local network credentials in the following variables:const char* ssid = “********”;const char* password = “**********”;
Make sure you select the right camera module. In this case, we’re using the AI-THINKER ESP32-CAM Model. Comment all the other models and uncomment this one: #define CAMERA_MODEL_AI_THINKER
If none of these correspond to the camera you’re using, you need to add the pin assignment for your specific board in the camera_pins.h tab.
We have learnt in this project how to make a video streaming web server with ESP32-CAM.