Maker tech hub - AI · 3D print · Pi · ESP32 · plus the classic tech archive.

Free ESP32 kit · AI tools directory · Books · Archive

Project · Intermediate · ESP32

ESP32-CAM Timelapse Rig for Print Monitoring

Power, lens focus, and storage tips for overnight capture.

Written by

Avery J. Parker

IT veteran, maker educator, and author of Network Ninja, 3D Printing Mastery, and AI Workflow Mastery. Business IT: Diversified Tech Solutions.

In this guide

  • Goal & materials
  • Steps / firmware
  • Troubleshooting
  • AI assist notes
  • Related gear & books

The common ESP32-CAM boards (the AI-Thinker style module with an OV2640 camera and a microSD slot) are inexpensive enough to dedicate one to watching a printer. They can capture a frame every few seconds or minutes and save it to a card for a timelapse. Getting reliable overnight capture mostly comes down to power, focus, and storage. This guide covers each.

What you need

  • An ESP32-CAM board with PSRAM (most AI-Thinker style boards have it).
  • A way to program it: a USB-to-serial adapter, or a programmer base board made for the ESP32-CAM.
  • A microSD card. FAT32 formatting is the safe choice; smaller cards (32 GB and under) format as FAT32 by default.
  • A solid 5 V supply.
  • A mount that holds the camera steady relative to the bed or frame.

Power: the number one cause of trouble

The ESP32-CAM draws current in bursts when Wi-Fi transmits and when the camera starts. A weak supply or thin, long wires let the voltage sag, and the board resets with a brownout message or simply reboots in a loop.

  • Feed it from a regulated 5 V supply rated well above the board's needs, not from a programmer's 3.3 V pin.
  • Keep power wires short and reasonably thick.
  • A capacitor (a few hundred microfarads) across 5 V and GND near the board helps smooth bursts.
  • Do not "fix" resets by disabling the brownout detector. That hides the problem and can corrupt the SD card when voltage dips during a write.

Programming the board

  1. Connect the adapter's TX to the board's RX, RX to TX, and GND to GND.
  2. Tie GPIO0 to GND to enter flashing mode, then reset the board.
  3. In the Arduino IDE, choose the "AI Thinker ESP32-CAM" board, or the matching board in PlatformIO.
  4. After uploading, disconnect GPIO0 from GND and reset to run your code.

The Arduino-ESP32 core includes a "CameraWebServer" example. Start there to confirm the camera works and to try frame sizes and image settings before writing your own capture loop.

Focus and framing

The stock lens is often focused for a longer distance than a printer bed. Many people refocus by gently rotating the lens. The lens is usually held with a dab of glue, so this risks damaging the module; if you try it, hold the lens holder steady, turn in small steps, and check the live view between turns. Alternatives include buying a module with an adjustable or wide-angle lens, or mounting the camera farther back.

  • Frame the part area and the nozzle, not the whole room.
  • Consistent lighting matters more than resolution. A small LED strip on the frame keeps exposure steady through the night.
  • The onboard flash LED is very bright and shares a pin with the SD card interface; most timelapse builds leave it off.

Capture settings

  • Frame size: the OV2640 tops out at 1600 x 1200 (UXGA). Lower sizes like 1024 x 768 or 1280 x 1024 save card space and write faster.
  • JPEG quality: in the esp_camera config, lower numbers mean higher quality and larger files.
  • Settle time: discard the first frame or two after the camera starts or wakes, because auto exposure and white balance need a moment.
  • Interval: a frame every 10 to 30 seconds is a common starting point. Work backward from the video you want: at 30 frames per second, every 30 seconds of final video needs 900 frames.

Storage and file naming

  • Name files with a zero-padded counter, such as img_00001.jpg, so they sort correctly.
  • Store the counter in non-volatile storage (the Preferences library) so a reboot does not overwrite earlier frames.
  • If the board has Wi-Fi, sync the time over NTP and put a timestamp in the filename or in a log file.
  • Close each file promptly after writing so a power cut loses at most one frame.

Turning frames into video

Copy the images to a computer and use ffmpeg:

ffmpeg -framerate 30 -pattern_type glob -i 'img_*.jpg' -c:v libx264 -pix_fmt yuv420p timelapse.mp4

The glob pattern option works on Linux and macOS builds of ffmpeg. On Windows, use a numbered pattern such as -i img_%05d.jpg instead.

Troubleshooting

SymptomLikely causeWhat to try
Brownout resets or boot loopsWeak 5 V supply or thin wiresBetter supply, shorter wires, bulk capacitor
"Camera init failed"Wrong board pin definition or loose ribbon cableSelect the AI-Thinker pin map; reseat the camera ribbon
SD card mount failsCard format or sizeUse FAT32; try a smaller, known-good card
Blurry imagesLens focused far awayAdjust focus carefully or move the camera
Flicker between framesChanging room light, auto exposureAdd steady lighting; skip the first frames after wake
Weak Wi-FiOnboard antenna inside a metal frameReposition; some boards support an external antenna after moving a jumper resistor

Summary

Give the ESP32-CAM clean, strong 5 V power, frame the print with steady lighting, save frames with a persistent counter on a FAT32 card, and stitch them with ffmpeg. Most failed overnight captures trace back to power, so solve that first.

Related