We will now build a simple time lapse camera using the ESP32-CAM board. All the images
will be saved to a microSD card and the time interval can be updated to suit your needs.
This sketch is based on the previous video, where we built a digital camera by making
use of the reset button as the shutter or capture button.
At a very high level, here’s what the sketch will be doing. As soon as we boot, the board
will take an image, save it to the microSD card and it will then go to sleep for a pre-determined
time interval to save power. This is handy if you decide to power it using a battery.
The board will then wake up, repeat the above and go to sleep again, this continues indefinitely.
Also, we store the image number in the EEPROM and read it before taking a new image, this
way, all the images are in sequence.
We would need a suitable microSD card to run this sketch. The microSD card should be formatted
with the FAT32 file system. In windows, you can do this by right clicking the microSD
card, selecting format, then the correct settings and hitting the start button. Once this is
done, insert the microSD card into the ESP32-CAM board.
Next, we need to upload the sketch but before we do this, let’s take a look at it. The
first thing we do is select the right camera model as this is needed to assign the correct
camera pins. For the ESP32-CAM board, this is the AI_THINKER model. Next, we specify
the EEPROM addresses and count. By default, all the EEPROM locations hold the value 0xFF
or 255 so we use the ID_ADDRESS and ID_BYTE to check if the image count is valid or if
we need to initialize it if the EEPROM is empty.
Rest of the sketch is pretty easy to understand and there are comments to guide you through
it. The important change compared to last time is the second last line which tells the
board how long it needs to sleep for. The TIME_TO_SLEEP is listed in seconds and you
can change this at the top of the sketch depending on your requirement.
Let’s upload the sketch to the board. Simply wire the ESP32-CAM board using this image
as a reference. Once again, it is recommended to use an external 5V power source to power
it and a USB breakout board works just fine. Download the sketch from the link in the description
and open it up in the Arduino IDE. Make sure you have the boot jumper in place, then Power
ON the board, open up the serial monitor, and press the reset button. If everything
is OK then you will obtain a message like this indicating that the board is ready to
accept new code. Then, hit the upload button and wait for it to complete. Once done, remove
the boot jumper and press the reset button. The board will take an image, save it to the
microSD card and go to sleep. The serial terminal will give you the board status along with
any errors or warnings. Wait for sufficient time to pass and the board will then boot
to repeat the cycle. Keep a note that the sketch prints out a lot of data to the serial
terminal which takes time. This means that the images will not be captured precisely
after 10 seconds and there will be some additional time taken to complete everything. You can
eliminate the serial statements and also get rid of the half a second delay shown here
to speed things up.
Once you are done taking images, you can remove the microSD card, and connect it into your
computer. All the images should be visible for you to use.
I found a 3D model for the ESP32-CAM board on Thingiverse and decided to print it. It
has suitable openings for the camera, LED flash and microSD card. The board slides perfectly
into the mount and you can add a microUSB breakout board to power it. Since I only have
one board with me, I decided to solder some wires to the 5V pins and use that instead
of gluing a USB breakout board. The model also contains multiple stands to hold the
camera in place. Here’s a sample clip made from the images I obtained.
And that’s how easy it is to build a time lapse camera using the ESP32-CAM board. If
you liked this video, then don’t forget to hit that like button. We will be building
many more projects using this board along with the regular DIY projects so do subscribe
to stay notified. Thank you for watching and I will see you in the next one.