IoT CCTV Camera using ESP32 CAM & Blynk App – Live Streaming

In this ESP32-CAM project, we will create an IoT CCTV live streaming camera using ESP32-CAM and Blynk application. It will enable us you monitor live streaming and surroundings where the ESP32-CAM is fitted using our android phone with the Blynk Application installed from anywhere.

IOT CCTV Camera using ESP32 CAM with live streaming

Blynk is a free-to-use app where the user can build software to control microcontrollers such as Raspberry PiArduino, ESP8266 NodeMCU, etc. For the user, it becomes extremely interactive and easy to use this application to build IoT projects from anywhere over the internet. Only the Blynk application and a steady internet connection in your device (smartphone, laptop, tablet, etc.) are a requirement.

You can also read this getting started guide on ESP32 CAM:

Connecting ESP32-CAM with FTDI programmer

We will require the following components for this project:

  1. ESP32-CAM development board
  2. FTDI Programmer/ USB Serial to TTL Converter
  3. Connecting Wires
  4. External 5V power supply (optional)

Unlike the ESP32 development board, the ESP32-CAM does not come with the USB port attached to it. So to upload a program sketch to the ESP32-CAM, we will need to use an FTDI programmer (USB to TTL Serial converter).

FTDI USB to serial converter pinout diagram
FTDI Programmer

You can learn more about this FTDI cable here:

The table shows the connections between the ESP32-CAM and FTDI programmer:

ESP32-CAMFTDI Programmer
5VVCC
UOR (GPIO3)TX
UOT (GPIO1)RX
GNDGND

Connect the 5V pin of ESP32-CAM with the VCC pin of the FTDI programmer to power up. Both grounds of the two devices will be connected in common. The TX pin of the FTDI programmer will be connected with UOR (GPIO3) of ESP32-CAM. Likewise, the RX pin will be connected with the UOT (GPIO1) of the ESP32-CAM module.

Additionally, you will need to connect GPIO0 with GND to enable the ESP32-CAM module to go in flashing mode. Remove this connection after uploading the program sketch to the module.

On some ESP32-CAM boards, you will get a brown-out detector error which is due to the insufficient voltage provided by the FTDI cable. In that case, you should connect an external 5V power supply to ESP32 as shown below:

ESP32-CAM and FTDI programmer connection diagram for sketch upload
ESP32-CAM and FTDI programmer Connection diagram

Setting up Arduino IDE for ESP32-CAM CCTV Camera

We will use Arduino IDE to program our ESP32 development board. Thus, you should have the latest version of Arduino IDE. Additionally, you also need to install the ESP32 plugin. You can visit the link shown below to have a look.

CCTV Camera ESP32 CAM Arduino Sketch

We will use the source code available on GitHub to create the live streaming video web server. Go to this link. The following web page will open up. Go to Code > Download Zip and download the zip file.

ESP32-CAM MJPEG Streaming Server download source code

After the download is complete, extract all the files in the folder. These are all the files that should be present after extraction.

ESP32-CAM MJPEG Streaming Server download source code 1

We will need the esp32_camera_mjpeg folder for this project. Click to open its contents. It consists of these two Arduino files and a src folder. Open esp32_camera_mjpeg.ino

ESP32-CAM MJPEG Streaming Server download source code 2

The .ino file will open in Arduino IDE. We will use this Arduino code to program our ESP32-CAM for the MJPEG streaming server.

Programming ESP32-CAM

However, we have to modify a few lines of code.

First head over to the definitions of the ESP32-CAM board. We are using Al Thinker ESP32-CAM so uncomment CAMERA_MODEL_AI_THINKER and comment CAMERA_MODEL_ESP_EYE which was set as default.

// Select camera model
//#define CAMERA_MODEL_WROVER_KIT
//#define CAMERA_MODEL_ESP_EYE
//#define CAMERA_MODEL_M5STACK_PSRAM
//#define CAMERA_MODEL_M5STACK_WIDE
#define CAMERA_MODEL_AI_THINKER

Next specify the SSID and password of your WiFi in the following variables. This will help us connect with the web server.

#define SSID1 "WRITE_YOUR_SSID"
#define PWD1 "WRITE_YOUR_PASSWORD"

Now, we are ready to compile and upload the code to our ESP32-CAM. Make sure the FTDI programmer is properly connected with the module and GPIO0 is grounded as well.

Choose the correct board and COM port before uploading your code to the ESP32-CAM board. Go to Tools > Board and select ESP32 AI Thinker.

select ESP32 CAM AI thinker board in Arduino IDE

Next, go to Tools > Port and select the appropriate port through which your board is connected.

Click on the upload button to upload the code into the ESP32-CAM board.

If you view Connecting….._____….._____….. in the error window, press the RESET button present on the ESP32-CAM as shown below:

ESP32 CAM reset button

After you have successfully uploaded your code to the board, remove the connecting wire from GPIO0 and GND.

Now open the serial monitor and press the RESET button on the ESP32-CAM.

You will be able to view the following messages including the IP address and the address we use to access the MPJEG streaming server. It is highlighted below:

ESP32-CAM MJPEG Streaming Server serial monitor demo
Serial Monitor

In a computer connected with the same WiFi connection as the ESP32-CAM, open a new web browser. Type this address: IP address/mjpeg/1 and press enter. The ESP32-CAM live streaming web server will open up.

Here we have set the ESP32-CAM near our fish aquarium and will monitor it through live video streaming.

ESP32-CAM MJPEG Streaming Server computer

Live Video Streaming (CCTV Camera) Set up on Blynk Application

Now let us see how to view our ESP32-CAM live streaming video in our Blynk application.

Blynk is a highly accessible smartphone-based application available for both Android and iOS operating systems. It provides an interactive dashboard where the user can build their own IoT projects by placing components. This will as a result create a mobile app through which the user will be able to control microcontrollers connected through WIFI. You can control LEDs, relays, electric motors, and many more. No internal programming is required to build your project in Blynk. You only need to drag and place your electronic components and it is as easy as that. Thus, building your IoT projects through Blynk is extremely easy and requires very little effort.

Installing and Getting Ready

We will use an Android smartphone for this project. So go to Google Play or Apple Store (if using an iPhone).

Telegram_ESP32_ESP8266_GooglePlayIcon_AppStoreIcon

Search for ‘Blynk’ and install the application.

Blynk app install

You will have to create an account to proceed further. You can also log in with your Facebook account if you possess that.

Blynk app account

Creating Project

After you have successfully signed in the following window will appear. Click ‘New Project.’

Blynk app new project

Now specify the name of your project, device and connection type. After that press the ‘Create’ button.

ESP32-CAM MJPEG Streaming Server Setting up Blynk 1

You will receive a notification regarding your Authorization token. This can be accessed from the email account you signed in with and also through Project Settings. We do not require it for this project.

Now the Blynk canvas will open as shown below:

ESP32-CAM MJPEG Streaming Server Setting up Blynk 2

Press on the screen. The widget box will appear. Now we will build our project. Click on the Video Streaming icon.

ESP32-CAM MJPEG Streaming Server Setting up Blynk 3

This is how it looks in the canvas now:

ESP32-CAM MJPEG Streaming Server Setting up Blynk 4

Press the widget again on the canvas to change its parameters. In the URL address, add the address we obtained and used to access the ESP32 MPJEG Streaming web server. Leave the output as it is.

ESP32-CAM MJPEG Streaming Server Setting up Blynk 5

This is how the project should be set. Now press the ‘Play’ button.

ESP32-CAM MJPEG Streaming Server Setting up Blynk 6

After a few moments, the live video streaming will start on the Blynk application.

You can set up the ESP32-CAM in different areas to get the view you want. Here are two screenshots of the live streaming video from two different angles.

ESP32-CAM MJPEG Streaming Server Setting up Blynk 7

Watch the video below:

You may also like to read:

5 thoughts on “IoT CCTV Camera using ESP32 CAM & Blynk App – Live Streaming”

  1. Hello
    After the rst button, it does not give the IP code in the serial monitor and gives the error code 0X00024
    Thank

    Reply
  2. Creating an IoT CCTV Camera using ESP32 CAM and the Blynk App for live streaming is a remarkable fusion of hardware and software innovation. This project not only showcases the versatility of ESP32 CAM but also highlights the power of Blynk for remote monitoring. The live streaming feature adds a dynamic dimension to traditional CCTV setups, allowing users to access real-time footage conveniently. This DIY approach not only provides a cost-effective solution but empowers enthusiasts to delve into the realm of IoT, learning and implementing cutting-edge technologies in the process. A commendable project for those exploring the intersection of IoT, surveillance, and live streaming.

    Reply

Leave a Comment