This project builds upon the previous digital image camera project and we build a time-lapse camera using the ESP32-CAM board. All the images are saved to the microSD card in sequence and the board goes to sleep after taking an image to help save power. This is handy if you power it using a battery.
The video above covers everything you need to know and also explains how the sketch is put together.
We Need A Suitable microSD Card
The ESP32-CAM board already contains the camera module, and microSD card slot that we need for this sketch. In addition to this, you will need a microSD card, a 5V power source and also a USB to serial converter to upload the sketch.
Wiring For Sketch Upload
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.
Serial Output In Download Mode
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.
Download the sketch using the link at the end of this post and open it using the Arduino IDE.
Overview Of Sketch
EEPROM Image Numbering Logic
The sketch requires that the microSD card be formatted in the FAT32 file format which is usually the default file system. In windows, you can do this by right-clicking the microSD card, selecting format, then the correct settings and hitting start. Once this is done, insert the microSD card into the ESP32-CAM board.
Serial Output When In Operation
Power up the board in the sketch upload mode and hit the upload button. 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 lapse and the board will wake up again to repeat the cycle.
Statement That’s Responsible For Sleep Time
Adjust The Sleep Time By Changing This
The second last line in the setup() function specifies the time-lapse and you can update this by changing the pre-processor directive located at the top of the sketch.
Images Saved To The microSD Card
The images will be stored in the microSD card and can be used as needed.
An enclosure greatly helps in taking steady images and I found a nice little enclosure the works great for this build.
3D Printed Enclosure
Link to 3D model: https://www.thingiverse.com/thing:3652452
Wiring The 5V Power Pins
Back Cover In Place With The Stand
You can add a microUSB breakout board to power the ESP32-CAM board but since I only had one board with me, I decided to solder wires to the 5V and ground pin and use an external breakout board. The back cover was flipped to support this. The 3D model also contains several stands that allow for versatile mounting.
It’s amazing what this little board can do and the images produce some interesting results once color corrected. Do check out the video for a sample clip.