Setting up a Raspberry Pi with Auto-Timelapse Recording

This blog post is still in the makes, you can, however, already take advantage of the pretty content available so far.

  1. Install Arch Linux ARM on SD Card (get the image from here)
  2. Plug SD card into RPi, connect the Camera Module (see this) and power up the RPi
  3. SSH into the RPi with user/pw root/root (find the IP of your Raspi with sudo nmap -sP | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}').
  4. Change the root password with passwd
  5. Bring system up-to-date and install some important tools with pacman -Syyu vim htop screen
  6. Change the hostname to lapsepi using hostnamectl set-hostname lapsepi
  7. Get the time at startup via NTP using systemd-timesyncd:
    Edit /etc/systemd/timesyncd.conf and uncomment the Servers then
    pacman -R openntpd || pacman -R ntp
    systemctl start systemd-timesyncd.service
    systemctl enable systemd-timesyncd.service
  8. Fix the timezone with timedatectl set-timezone Europe/Berlin
  9. Add these lines to your /boot/config.txt:
    Also adjust the gpu_mem_xxx values in the /boot/config.txt file:
  10. Install the Raspberry Pi firmware: pacman -S raspberrypi-firmware
  11. Improve bash experience with
    cat << "EOF" >> ~/.bashrc
    export PATH=$PATH:/opt/vc/bin
    export HISTSIZE=2000000
    export HISTFILESIZE=50000000
    echo 'if [ -f ~/.bashrc ]; then . ~/.bashrc; fi' > .bash_profile
    Then log back in via SSH
  12. If you are using a new B+ model, you may need to blacklist i2c_bcm2708 if they didn't fix this yet.
  13. Reboot and check that the camera module works via raspistill -o image.jpg

Now you're ready to use your Pi as a Time Lapse Recorder.

More preparations

Own FAT Partition for images on a USB thumb drive

Find the USB thumb drive drive:

ls /dev/sd?

Create Partition

parted -s $DEV mklabel msdos
parted -s $DEV mkpart primary 1 -1
#parted -s $DEV set 1 boot on
#parted -s $DEV set 1 lba on
parted -s $DEV print


pacman -S dosfstools
mkfs.vfat -F 32 /dev/sda1

Simple use of raspistill, raspivid...

# start a *screen* session (will continue to run even when disconnecting ssh):
# capture an image every 30 seconds for 6 hours:
raspistill -o a%04d.jpg -t 21600000 -tl 30000
# capture 6 hours of video
raspivid -w 1280 -h 720 -o video.h264 -t 21600000


Get ffmpeg using pacman -S ffmpeg. Then you can embed a recorded movie in an mp4 container like this:

ffmpeg -r 30 -i $MOVIE -vcodec copy $(basename -s .h264 $MOVIE).mp4

Python Script

  1. Install Python using pacman -S python python-pip
  2. Install the Python bindings for the camera module: pip install picamera

Continue with

Use to capture pictures every x seconds.

Get some ideas from

Add to autostart

Add a cron entry with crontab -e:

@reboot python /root/timelapse/ &

Afterwards shutdown -h now and unplug the battery/plug it back in.

Alternative: Write a systemd service file.

Putting it together in a watertight box

Check this post where they use an illy coffee tin.

Adding a shutdown button

Python script to monitor GPIO #17:

import RPi.GPIO as GPIO
import time
import os
GPIO.setup(17, GPIO.IN,pull_up_down=GPIO.PUD_UP)
while True:
    print GPIO.input(17)
    if(GPIO.input(17) == False):
        os.system("sudo shutdown -h now")

Add python /root/ to autostart via crontab:

@reboot python /root/

Then short GPIO Pins 9 and 11 to shut down.


Or maybe completely via Shell script?

# monitor GPIO pin 17 (wiringPi pin 1) for shutdown signal
# export GPIO pin 17 and set to input with pull-up
echo "17" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio17/direction
echo "high" > /sys/class/gpio/gpio17/direction
# wait for pin to go low
while [ true ]
  if [ "$(cat /sys/class/gpio/gpio17/value)" == '0' ]
    echo "Raspberry Pi Shutting Down!"
    #halt &
    shutdown -h now &
    exit 0
  sleep 1

Add bash /root/ to autostart via crontab:

@reboot bash /root/

The script should also stop the image capture script first.

Also see

Converting the pictures to a movie

Using avconv

avconv -r 10 -i timelapse_%04d.jpg
   -r 10 -vcodec libx264 -crf 20 -g 15
   -vf crop=2592:1458,scale=1280:720

Using mencoder

pacman -S mencoder

Then combine the images to the mpeg4 file timelapse.avi:

cd ~/pictures
ls *.jpg > stills.txt
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o timelapse.avi -mf type=jpeg:fps=30 mf://@stills.txt

Converting a real-time movie file to a timelapse movie file

Changing the Framerate / FPS of an x264 .mp4 movie file without re-encoding

Finally some ideas for your timelapse movies

  • Flowers blooming,
  • cleaning your room,
  • traffic moving at night,
  • people walking on the street,
  • sunsets/Sunrises,
  • lights turning on in buildings,
  • driving through town,
  • the front window on a train/subway,
  • snow piling up,
  • day-to-night/Night-to-day,
  • daily selfies,
  • seasons changing,
  • making a drawing,
  • boats on a harbor,
  • hyperlapse - walking around a building,
  • tourself working out.

Also check out 10 things you should not do in Time-lapse.