Acoptex.Com

Learn ESP32, ESP8266, Arduino, and Raspberry Pi

How to make a video streaming web server with ESP32-CAM

We will learn in this project how to make a video streaming web server with ESP32-CAM. More ESP32-CAM projects you can find here.

Tag: Project 136b How to make a video streaming web server with ESP32-CAM AI-Thinker

Project resources

  • Libraries used: None
  • Code: sketch

1. ESP32-CAM Development Board with camera 1 set

ESP32-Cam

2. Arduino IDE ( you can download it from here  )

3. USB to TTL/Serial adaptor/converter 1 pc

USB to TTL/Serial adaptor/converter
USB to TTL/Serial adaptor/converter

4. Jumper cables F-F

JUMPER CABLES

5. Micro SD card and SD card adapter 1 pc

MICRO SD WITH ADAPTER

6. WiFi AntennaCompact Internal WiFi Antenna with U.FL connector and 5.9 inch cable 1 pc (optional)

WiFi Antenna, Compact Internal WiFi Antenna with U.FL connector and 5.9 inch cable

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.

You can find the ESP32-CAM schematic here, ESP32-CAM development board specification is here, camera specification is here.

Signals and connections of the ESP32-CAM Development Board with camera

Signals and connections of the ESP32-CAM Development Board with camera

ESP32-CAM pinout:

ESP32-CAM pinout
  • 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

Wiring

ESP32-CAM WIRING

ESP32-CAM module    FTDI programmer

U0TXD (GPIO1)         RXI                  

U0RXD (GPIO3)         TX0

GND                          GND

5V                             5V

GND and GPIO0 (for flashing only)                                 

Step by Step instruction

1.Preparations

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. 

ESP32-CAM webserver

7.Go to Tools -> Port and select the COM port the ESP32-CAM Development Board connected to (we have COM3).

ESP32-CAM webserver

6. Open this sketch in your Arduino IDE, modify with your local network data (ssid and password).

ESP32-CAM webserver

8.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.

ESP32-CAM webserver

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.

ESP32-CAM webserver

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). 

13. That’s it. You are ready for next project with ESP32-CAM now.

ESP32-CAM webserver

3. Troubleshooting

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.

Failed to connect to ESP32: Timed out waiting for packet header

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.

Solution:

  • 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

Code

Before uploading the code, you need to insert your local network credentials in the following variables:const char* ssid = “yourSSIDhere”;const char* password = “yourPasswordHere”;

Summary

We have learnt in this project how to make a video streaming web server with ESP32-CAM.

Check for more DIY projects on Acoptex.lt and Acoptex.com!

If you are looking for high quality PCBs PCBWay is the best choice: