We’re now going to use the ESP32-CAM to capture and save video to a microSD card.
This sketch will be based on the following github repository and the team have done some
very impressive work. Here are some sample videos that have been captured using the sketch.
The team have also added FTP capability to the sketch so that you can obtain the videos and images
without having to retrieve the microSD card. This video is going to show you how you can
use this with the ESP32-CAM board.
All the ESP32 projects we have worked with involve capturing images. However, a video
stream is simply a series of images timed in a correct sequence and that is the basis
behind this sketch. We would need the ESP32-CAM board and a suitable microSD card. Start by
downloading and opening up the sketch in the Arduino IDE. The first thing we need to do
is add our WiFi network name and password. This is needed to control the board over
the network and to access the microSD card contents.
The next bit is optional but you can also change the default video capturing settings
in the sketch. I’d recommend using the Find option to search for the keyword EDIT as this
will quickly take you to the relevant section. These settings can also be changed later using
the browser but let’s just go over them in the sketch for now. We will be using the
default settings when testing the sketch.
Essentially, you can specify the framesize with 10 being the highest quality, the number
of files to be created along with the playback speed which allows you to create a time-lapse
effect. You can also specify color or grayscale images, the capture interval, and total frames
or capture duration. I’d highly recommend you read through the github page to get a
deeper understanding of all these options.
Another thing to keep in mind is that the LED flash control line is shared by the microSD
card and thus, it will keep flickering as the board communicates with the microSD card.
You can either disable the LED flash by modifying the board a little or you can cover it as
needed. There are instructions on how you can lift the transistor pin to disable the
flash. This is reversible which means that you can always solder the transistor pin back
in place to enable the flash.
Let’s test this out by uploading the sketch. Before you can do this, you need to ensure
that you install the board support package in the Arduino IDE. There are two posts on
the website to help you get started. Next, insert the microSD card which has to be formatted
with the FAT32 file system. Wire up the board in the serial upload configuration and hit
the reset button to obtain a serial output similar to this. Then, hit the upload button
and wait for it to complete. Remove the boot jumper, keep the serial monitor open and press
the reset button. You should obtain an output similar to this. Keep in mind that it does
print your network password to the serial terminal. If everything works as expected
then you should see an IP address printed to the serial terminal and the board should
start capturing images. The red LED on the board will flash every time a frame or image
is captured. You can control the board by typing in the IP address into a web browser
or you can simply type desklens.local which is the hostname specified in the sketch.
You can click the link shown here to stop the recording. The page also lists a few options
for you to restart the recording. Keep in mind that these are the same options that
we looked at previously. You can also start recording by specifying the settings you require
directly in the address bar.
Now that we know how to start and stop the recording, let’s access the FTP server to
obtain the files. It is recommended to use an FTP client for this and I will be using
Filezilla. The computer that you use should be connected to the same WiFi network for
this to work. Open up the site manager. Enter the Host which can be the IP address or the
hostname . Enter 21 for the port and select the option plain FTP.
Specify the username and password which is esp by default and then click connect. You
will then be able to view the microSD card contents. You can obtain the files by simply
right clicking the file you want and selecting download. Wait for it to complete and you
can then use the file browser to navigate and open the file.
You can use a 3D printed case like this one to mount the camera module. Instead of using
a microUSB breakout board, I added some wires to the 5V power pin to power it externally.
The video quality is not exactly bad considering that the board along with the camera module
costs less than $9. We will create a separate sketch just for the FTP feature in a future
video so do subscribe if you’d like to see that. Thank you for watching and I will see
you in the next one.