Time-lapses are a great way to capture the changing weather, a construction that is happening nearby, or even the growth of a plant. While you could use an app for your smartphone to capture a time-lapse, you might have a concern about leaving an expensive device unattended for long periods. What if I told you there was a way to capture time-lapses using a much cheaper device?

There is! An ESP32-CAM board can be had for less than $10, and with a little bit of programming (don't worry, I'll show you how!), you can use it to save a great-looking time-lapse!

Gathering Supplies for this Project

For this project, you will need:

  • An ESP32-CAM board with a programming daughterboard or a USB port
  • A micro USB cable
  • A micro SD card
  • (Optional) A tripod and a 3D printed case from Thingiverse

Choosing a Suitable ESP32-CAM Board

For this project, you will need a way to program the board using a USB cable from your computer. I recommend buying either an ESP32-CAM with an ESP32-CAM-MB daughterboard or a newer ESP32-CAM-CH340. Both of these have the necessary USB port.

Be aware that most 3D printed cases are for the ESP32-CAM and that the larger ESP32-CAM-CH340 will probably not fit in these, so the option with a daughterboard would be preferable in that case. If you buy a plain ESP32-CAM and don't have a daughterboard or some other serial programmer, you will not be able to program it.

Related: Why You Should Consider the Feature-Packed ESP32-CAM for Your Next Project

Setting Up the Arduino IDE

To program the ESP32-CAM, you will need the Arduino IDE from the Arduino website. At the time this article was written, 1.8.19 was the current version.

Once the download is complete, launch the application. The first time you run it, you might get an unrecognized application warning from Windows. It is safe to click More info followed by Run Anyway.

Related: How to Stop Windows 10 From Blocking Your Downloaded Files

Once the Arduino IDE starts up, it will look like this:

A screenshot of the Arduino IDE version 1.8.19

You will need to make some changes to allow the Arduino IDE to recognize the ESP32-CAM. First, open Preferences from the File menu. Where it says Additional Boards Manager URLs, paste in the following line:

        https://dl.espressif.com/dl/package_esp32_index.json
    

Then, click OK.

Now, open the Tools menu and hover your mouse over the menu item that starts with Board: (it may be something like Board: Arduino Uno). From the submenu that appears, select Boards Manager.

This will bring up a new window with a search bar at the top. Type "ESP32" in the search bar. Doing so should allow you to select esp32 by Espressif Systems. Click Install. When the download finishes, click OK to exit the Boards Manager.

Now, return to the Tools menu and again open the submenu that starts with the word Board. This time, you should see an ESP32 Arduino item that was not there before. This is a submenu with a long list of boards names. Find AI Thinker ESP32-CAM and select that.

That's it, the Arduino IDE is now configured for the ESP32-CAM!

Uploading a Test Sketch

In Arduino lexicon, a "sketch" is a program—a recipe, if you will—that will tell the ESP32-CAM what to do. As a test, let's write a sketch to blink the white LED. Notice that the Arduino IDE already has some starter code in it. Modify it so it looks like this:

        void setup() {
 // put your setup code here, to run once:
  pinMode(4, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(4, HIGH);
  delay(1000);
  digitalWrite(4, LOW);
  delay(1000);
}

Now, click the round checkmark button. You will be asked to save the Sketch somewhere. Once you do that, it will say Compiling sketch.

After some time, it will say Done compiling. If instead of seeing that, you get an error, it means you mistyped something. This is what a successful compilation looks like vs. what it looks like with an error:

Errors happen a lot in programming and computers are very nit-picky about the code being just so! Check over your code carefully, correct any errors and try again.

Once the compilation succeeds, the last step is to upload the program to the board. Do this by clicking the button that looks like an arrow in a circle. The Arduino IDE will recompile, say Uploading for a while, and then finally say Done Uploading. At this point, the white LED on the board should begin blinking!

If this step fails, you may need to tell the Arduino IDE to use a different serial port. To do so, open the Tools menu and look for the submenu that starts with Port. You may have to try all the available ports until you find one that works.

Uploading the Time-Lapse Sketch

Now that you know how to upload a sketch, let's get on to making the time-lapse! The sketch for this is more complicated, but you can download it premade. Follow our link to directly download a zip file with the Arduino sketch.

Unpack the zip file to a folder on your computer and then, from the Arduino IDE, select Open from the File menu. Locate the file esp32cam-timelapse-microsd.ino from the folder you just unzipped.

By default, this Sketch is set up to capture one image every half-an-hour. If you want to change this, edit the number on the line that reads #define MINUTES_BETWEEN_PHOTOS 30.

Compile and upload this sketch to the ESP32-CAM just as you did the blink sketch. Initially, nothing will happen. Unplug the ESP32-CAM from your computer and insert a micro SD card in the card slot. Then, plug the ESP32-CAM back in. After five seconds, the white LED should flash once. This indicates a photograph was saved to the micro SD card. The next photograph will be taken half an hour later unless you change the interval.

Before recording a time-lapse, I recommend you take the SD card over to your computer to verify that there is a photograph on the card called photo00001.jpg. If everything looks good, you are ready to capture a time-lapse!

Recording the Time-Lapse Using the ESP32-CAM

Set the ESP32-CAM up someplace and use a USB charger to power it. If the ESP32-CAM was already in place, but you reinserted the card, momentarily cut the power by unplugging it and plugging it back in. After plugging it in, wait for the LED to flash once.

This tells you that the first image was captured successfully. Once this happens, you can leave it to record the rest of the photos for as long as you like!

ESP32-CAM in a 3D Printed Case on a Tripod
Image Credit: Marcio Teixeira/Flickr

Whenever you remove the SD card and reinsert it, you will need to cut power to the ESP32-CAM to start a new recording. The easiest way to do this is to unplug and plug in either the cable or charger. Always watch for the LED to flash once so that you know the capture has started!

When you've left the ESP32-CAM recording for a few days, remove the micro SD card to see the photos that make up your time-lapse! Insert the micro SD card into your PC's media card reader and select the Picture Tools item from the File Explorer's toolbar. Then click the Slideshow button.

If you hold down the right arrow key, you can quickly flip through the pictures, giving you a nice animated time-lapse!

An Easy Yet Powerful Time-Lapse

While this project shows you how to make an easy time lapse using the ESP32-CAM, there are several ways to improve upon this project. One idea is to use the wireless capabilities of the ESP32-CAM to add a web interface for downloading the pictures or to use a smartphone as a viewfinder.

This can help you frame your subject during setup without having to remove the SD card and start all over. With the ESP32-CAM, the possibilities are endless!