We’ve previously used the ESP32-CAM board to capture video and stored it on a microSD
card. We’re now going to build a $9 video streaming device that eliminates the need
for a storage device.
We know that video is nothing but a series of well-timed images taken in sequence. Instead
of saving these images to a storage device, we will send them over a network to a client
which will receive and display them. We will be using the real time streaming protocol
or RTSP for this sketch. The advantage of having an RTSP stream is that the camera and
storage locations are different. And this means that even if the camera is stolen or
damaged, you can still access the previous videos if they were recorded to a hard disk
for instance. However, if you do simply record to the microSD card, then the video files
will be lost if the camera is stolen or damaged.
The sketch is based on the Micro-RTSP github repository which allows you to create a video
streamer that can either connect to an existing WiFi network or that can create it’s own
access point for you to connect to. There were a couple of things that needed to be
dealt with before it could work with the ESP32-CAM board. There was no easy way for you to use
it with the Arduino IDE as the repository is created for PlatformIO. It also could not
recognize the camera module contained within the ESP32-CAM board as the pin configurations
were different. Lastly, the access point was unreliable and often caused a kernel panic
which rebooted the board. This appears to be a common bug that is corrected by changing
the access point initialization command sequence.
Start by downloading and opening the sketch in the Arduino IDE. By default, it will try
to connect to a WiFi network so make sure you specify your network credentials. I’ve
added the camera pins file which contains with pin configuration for various supported
boards. The main sketch also contains the camera selection and configuration. This sketch
has only been tested with the ESP32-CAM board as that’s the most popular one that’s
used for projects like this one. You do not need to change anything and you can simply
upload the sketch to your board. Start by connecting the board as shown here and press
the reset button to put it into the download mode. You should receive a message like this
on the serial terminal. Hit the upload button and wait for it to complete. Remove the download
jumper and press the reset button. The board will try to establish a network connection
and it will print the status along with the stream link.
The correct way for you to view the stream is by using a client like VLC. So download
and open VLC. Select the open network option from the file menu and then type in or copy
the stream link and hit open. Give it few seconds and you should be able to view the
stream in VLC. Also note that you can type in the IP address into a web browser and obtain
the stream. I suspect that this is not technically the actual RTSP stream but simply the JPEG
images which gives you the same effect.
In order to use the streamer in a standalone, access point mode, you will have to uncomment
the SOFTAP_MODE statement in the sketch. As mentioned earlier, the access point mode was
unreliable and I used to keep getting errors like this every time I tried connecting to
it. Apparently, this is a common problem that is solved by changing this section in the
sketch. In the original sketch, the softAPConfig function was called before the softAP function
and there was no delay between the two.
Again, there’s no need to change anything in the sketch. If you want to, you can change
the default password that will be used to connect to the access point. Once done, put
the board in the download mode, and upload the code to it. Remove the jumper and press
the reset button. The serial terminal will print the status and it will also give you
a stream link. You can use your smartphone to connect to the access point and you can
then type in the IP address into a web browser to view the stream or images. You can also
use a computer to connect to the access point and use the link in VLC to view the stream.
I’ll be using this model from Thingiverse, which will serve as the enclosure. You can
solder some wires to a microUSB breakout board and solder them to the 5V power pins on the
ESP32-CAM board. Slide the board in place and use some hot glue to hold the microUSB
board in position. I plugged in a microUSB cable to ensure that the port is aligned correctly.
Finally attach the back cover and mount it on the stand. The model also has different
options for the stand so do take a look to see which one works best for you. And that’s
how you can build a wireless video streamer using the ESP32-CAM board. Don’t forget
to like, share and subscribe as I’ve recently starting posting videos like this one and
your support will help massively with the YouTube algorithm. Thank you for watching,
and I will see you in the next one!