Related project: ESP32-CAM Video Streaming Web Server (works with Home Assistant and Node-Red)
Watch the Video Tutorial
You can watch the video tutorial or keep reading this page for the written instructions.
To follow this tutorial you need the following components:
Introducing the ESP32-CAM
Here is a list with the ESP32-CAM features:
- The smallest 802.11b/g/n Wi-Fi BT SoC module
- Low power 32-bit CPU,can also serve the application processor
- Up to 160MHz clock speed, summary computing power up to 600 DMIPS
- Built-in 520 KB SRAM, external 4MPSRAM
- Supports UART/SPI/I2C/PWM/ADC/DAC
- Support OV2640 and OV7670 cameras, built-in flash lamp
- Support image WiFI upload
- Support TF card
- Supports multiple sleep modes
- Embedded Lwip and FreeRTOS
- Supports STA/AP/STA+AP operation mode
- Support Smart Config/AirKiss technology
- Support for serial port local and remote firmware upgrades (FOTA)
The following figure shows the ESP32-CAM pinout (AI-Thinker module).
There are three GND pins and two pins for power: either 3.3V or 5V.
The following pins are internally connected to the microSD 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
Video Streaming Server
1. Install the ESP32 add-on
- Installing the ESP32 Board in Arduino IDE (Windows instructions)
- Installing the ESP32 Board in Arduino IDE (Mac and Linux instructions)
2. CameraWebServer Example Code
In your Arduino IDE, go to File > Examples > ESP32 > Camera and open the CameraWebServer example.
The following code should load.
Before uploading the code, you need to insert your network credentials in the following variables:
const char* ssid = "REPLACE_WITH_YOUR_SSID"; const char* password = "REPLACE_WITH_YOUR_PASSWORD";
Then, make sure you select the right camera module. In this case, we’re using the AI-THINKER Model.
So, comment all the other models and uncomment this one:
Now, the code is ready to be uploaded to your ESP32.
3. ESP32-CAM Upload Code
Important: GPIO 0 needs to be connected to GND so that you’re able to upload code.
To upload the code, follow the next steps:
1) Go to Tools > Board and select AI-Thinker ESP32-CAM.
2) Go to Tools > Port and select the COM port the ESP32 is connected to.
3) Then, click the upload button to upload the code.
After a few seconds, the code should be successfully uploaded to your board.
Getting the IP address
After uploading the code, disconnect GPIO 0 from GND.
Open the Serial Monitor at a baud rate of 115200. Press the ESP32-CAM on-board Reset button.
The ESP32 IP address should be printed in the Serial Monitor.
Accessing the Video Streaming Server
There are also several camera settings that you can play with to adjust the image settings.
Finally, you can do face recognition and detection.
- Failed to connect to ESP32: Timed out waiting for packet header
- Camera init failed with error 0x20001 or similar
- Brownout detector or Guru meditation error
- Sketch too big error – Wrong partition scheme selected
- Board at COMX is not available – COM Port Not Selected
- Psram error: GPIO isr service is not installed
- Weak Wi-Fi Signal
- No IP Address in Arduino IDE Serial Monitor
- Can’t open web server
- The image lags/shows lots of latency
We hope you’ve find this tutorial useful. If you don’t have an ESP32-CAM yet, you can grab it here.
If you like this project, you may also like other projects with the ESP32-CAM:
- ESP32-CAM Video Streaming Web Server (works with Home Assistant and Node-RED)
- ESP32-CAM Take Photo and Save to MicroSD Card
- ESP32-CAM PIR Motion Detector with Photo Capture (saves to microSD card)
- ESP32-CAM Take Photo and Display in Web Server
- Build ESP32-CAM Projects (eBook)
- Read all our ESP32-CAM Projects, Tutorials and Guides