RTSP Video Streamer – ESP32
This post will show you how you can build a $9 video streaming device that uses RTSP and the ESP32-CAM board. The sketch can be configured to connect to an existing WiFi network or it can also create its own access point that you can connect to, in order to view the stream.
The video above talks you through the entire process of building this project.
Step 1: Download, Prepare & Upload the Sketch
Download the sketch using the link at the end of this post. There are two ways for you to use the sketch:
Connecting To An Existing WiFi Network:
If you want the video streamer to connect to an existing WiFi network then you need to add the network credentials to the wifikeys.h file as shown in the image. You do not have to change anything else in the sketch and you can proceed to the downloading the sketch section below:
Creating A New Access Point:
You can also configure the board to create a standalone access point that you can connect to and view the stream from. To do this, you need to uncomment the “#define SOFTAP_MODE” line in the sketch. Optionally, you can also change the access point password if you want to. Use the image as a reference.
Downloading The Sketch:
The ESP32-CAM board does not have an onboard USB connector so you need to use an external USB to serial converter to upload the sketch. You can use the wiring connections shown above but make sure that the USB to serial converter is connected in the 3.3V mode.
It is recommended to use an external 5V supply to power the board, particularly if you are using an FTDI breakout board. For the external 5V supply, a simple USB breakout board will do just fine. There has been some success in powering the board directly from the CP2102 breakout board so you can try that first. The board also has a 3.3V power pin if needed.
The jumper is needed to put the board in the download mode. Once you have everything connected, power up the board, open a serial terminal (Tools->Serial Monitor) with a baud rate of 115,200 and press the reset button. You should obtain an output as shown in the image and this will indicate that everything is working as expected.
Next, hit the upload button and wait for it to complete the upload. The board will print the stream link to the serial terminal in either case and we need to use this to view the stream.
Step 2: View the Stream
Access Point Mode:
If you configured the board to create a new access point then you will have to connect to it first before you can view the stream. The default access point name is “devcam” and the default password is “12345678”. Once connected, you can proceed to view the stream below.
Using A Computer:
The easiest way to view the stream on the computer is by using VLC. So download and install it first. Next, select the “Open Network” option from the File menu and then paste or type the stream link (example: rtsp://192.168.1.31:8554/mjpeg/1) into the box that shows up. Hit open and wait for the stream to show up.
Using A Smartphone:
You can download an RTSP client app to view the stream using your smartphone. But typing in the IP address into a web browser will give you a stream that consists of the images.
Step 3: Use an Enclosure for the Camera
I decided to use the following model from Thingiverse for the enclosure: https://www.thingiverse.com/thing:3652452
Start by soldering wires to a microUSB breakout board and connecting the output to the 5V power pins of the ESP32-CAM board. Then, add some kapton or insulation tape to the microUSB board to avoid it shorting out the ESP32-CAM board. Insert a microUSB cable into the board to ensure that it is mounted correctly and use some hot glue to hold the microUSB board in position. Do not apply too much glue towards the edge of the enclosure as the back cover has to sit in place. Finally, add the back cover and you are good to go!
Download Sketch: https://github.com/bnbe-club/rtsp-video-streamer-diy-14