Timelapse Pi Mk1

Simple Raspberry Pi timelapse camera.

raspberry pi timelapse camera

My requirements

--- maybe ---

The Essentials

Install headless OS on Raspberry Pi Zero W I had laying around.

Create bash script to take still photos (named mine "run-timelapse.sh"):

#!/bin/bash
while : #infinite loop to just take photos!
do
    echo "taking still photo"
    libcamera-still -o /home/pi/timelapse/ --datetime -q 95 --width 1920 --height 1080 --nopreview
    sleep 120 #in seconds
done

Make script executable:

sudo chmod a+x FILENAME

Set script to run on reboot with:

sudo crontab -e

by adding this line to the end of the file:

@reboot /home/pi/timelapse/run-timelapse.sh

Then ssh to the pi and navigate to the directory where the pictures should be. If new images show up every two minutes, you're good to go!

ssh pi@timelapsepi

Copy photos to local computer

From the terminal on the local machine:

scp -r pi@timelapsepi:timelapse /Users/directory

Make the video using ffmpeg:

ffmpeg -framerate 12 -pattern_type glob -i "*.jpg" FILENAME.mp4

1 picture every 2 minutes = 30 pictures / hr = 720 pictures / day

720 frames x 12 frames / sec = 60 sec video

So to make a video of April 14:

ffmpeg -framerate 12 -pattern_type glob -i "*0414*.jpg" 2022-4-14.mp4

Delete files after copy

Let's say I want to find all files from April 8 in the timelapse directory.

From within the timelapse directory:

find . -name "*0408*"

If I want to delete those files:

find . -name "*0408*" -delete

Or all .jpgs in the folder:

find . -name "*.jpg*" -delete

Preview camera for initial setup

Start the camera and open a preview window, indefinitely:

libcamera-hello -t 0

-t = time, 0 = indefinitely

Connect with RealVNC

The simplest solution for connecting to the Pi in a headless setup. Both Mac / iPhone apps.

RealVNC

That pretty much covers the basics. Plug it in and pictures start being taken right away!


Maybe later...

Install 16mp autofocus Arducam

Actually started with this camera, but it didn't work right out of the box (memory buffer issue) so I just reverted back to the official camera module for now.

Note that this required a different cable than what came with the camera (Pi Zero camera connector is smaller than normal).

Could also try the official Rapsberry Pi HQ camera. No autofocus, but it would likely take significantly better photos.

3D print case for pi and camera

Should have an adjustable camera mount. And wall mount for the entire thing maybe? Screw slot? Power switch?

Small touchscreen display

To show when the camera is running / taking a photo. And maybe ability to adjust photo frequency on the fly? Small buttons to move it up and down?

Automate video creation?

1 timelapse per day, made with a simple script each night, texted to me?

Set to run between 8am and 8pm

Use something along these lines:

#!/bin/bash
H=$(date +%H)
if [ $H > 8 ]
then
  if [ $H -lt 20 ]
  then
    echo $H
    echo 'take photo - after 8am and before 8pm'
  fi
fi
    

But I'll probably just leave this out so it can work like a simple security camera...


Why build it?

Our museum exhibit design and fabrication process often happens over a longer timeframe than is captured well on video.

Plus, we'll be moving out of our buildings soon and into a bigger one, and I thought it would be fun to do a timelapse capture of that process.

Perhaps most importantly, it's fun. I enjoy the learning / solving / building process. Working through interesting new challenges and then distilling the solution down into simple components.