In this project you are going to learn a quick guide on how to create a ESP 32 cam web server which streams over the local network server and also stream live video over the internet.
Features of ESP32 Cam module:
- ESP32 cam module is a cheaper one with nearly 9$.
- It is one of the smallest soc to have 802.11b/g/n Wi-Fi BT SoC which has inbuilt WiFi and Bluetooth.
- Low power 32-bit CPU
- Built-in 520 KB SRAM, external 4MPSRAM
- Support OV2640 and OV7670 cameras, with built-in flash LED light.
- Supports TF microSD card.
- Supports UART/SPI/I2C/PWM/ADC/DAC
- Supports local and remote firmware upgrades(FOTA)
ESP32 Cam module Pinout:
The following image show pinout diagram of ESP32 CAM (AiThinker module).
Here the GPIO0 Pin has an important role which is used to put board into flash mode when a jumper wire is connected between GPIO0 and GND. We need to use this mode while code uploading.
GPIO1 and GPIO3 are serial pins which are used for uploading code into the board and all the other pins connected internally to MicroSD card reader on board.
- GPIO 4: Data 1 (also connected to on-board LED blinks when SD card is used)
- GPIO 2: Data 0
- GPIO 14: CLK
- GPIO 15: CMD
- GPIO 13: Data 3
- GPIO 12: Data 2
Interfacing ESP32 Cam module with FTDI Programmer
You might have observed from the above images that ESP32 Cam module doesnot have an USB pin to connect it to PC to upload the code so in this case we are using a FTDI programmer connected to ESP32 cam. The following schematic diagram shows how to connect the FTDI programmer and how to put the ESP32cam in flash mode.
Upload the code to ESP32 cam module with Arduino IDE:
Connect the FTDI with USB to PC where Arduino IDE is installed and follow the steps.
- Paste the code in the IDE
- Click on tools and select ESP32 Wrover Module from Boards
- Select the port where our device is connected.
- Choose the baud rate to 115200
- In Tools ->select Partition Scheme, and select “Huge APP (3MB No OTA)“
ESP32 Cam Live stream in local server Code
The below code is to just to watch the live video on local server by accessing it through a generated IP address.
Get the code from the examples section in the arduino IDE as below
Choose the camara board model by removing the “//” before the model by default it is selected as WROVER_KIT as we are using the AI_THINKER board we can remove the backslash before aithinker and comment the default one with //.
// Select camera model
as the next step change the WiFi credentials to your WiFi ssid and password and then upload the code.
const char* ssid = "Your wifi name goes here";
const char* password = "your password goes here";
After code upload remove the flash jumper pin connected between GPIO0 and GND. then click ok reset button on board.
Open serial monitor in Arduino IDE and set the baud rate to 115200 if it not as default and then you can see that the board is connected to the wifi network and IP address to access the video stream are printed as shown in the below image.
As you got the Local ESP32-CAM IP address from the serial monitor you can watch the live stream from any device which are connected to the same wifi network where ESP is connected by just entering the IP address in any web browser and click on start stream.
Here You have the option take a photo by clicking get still button but we added libraries of SDcard so it wont be saved in storage. We will cover that topic in another article. As you can see in the above image there are lots of options to customise the video quality and add filters to it discover the best settings which suits you.
Live Streaming the ESP32-CAM over internet with the help of NGROK
1)The first step is to create an account in ngrok website and obtain a auth token as shown in the below image
2)Now download the ngrok for windows as we are running it on windows 10 PC.
4)Add your authtoken to ngrok with command “ngrok authtoken paste_you_token”
6) Thats it, You will be granted an URL which you can share to anyone who wants to watch the live stream anywhere from the world.
With this URL you can stream on your android device also through a blynk application just by adding a video streaming widget and adding URL in the URL address field.