Time lapse photography on the Raspberry Pi

This is part of my Weather Balloon project.

There are a lot of tutorials on the Internet showing how this can be done, but I spent some time trying to get it to work. The following procedure worked for me and may be of use to others.

Start the LX Terminal to enter the following:

Step 1 – make a new folder where all the files and images will be kept.

mkdir Timelapse

cd /home/pi/Timelapse


This creates a new folder then navigates to that folder.

Step 2 – write code that will take a picture

Create a new file called timelapse.sh

nano timelapse.sh

Then enter the following code

#! /bin/bash
DATE =$date("%d-%m-%Y_%T")
raspistill -o /home/pi/Timelapse/$DATE.jpg

Save and exit by clicking on Ctrl x

To check this works enter

sh timelapse.sh

The LED on the camera board should light and a picture should be taken and saved to the Timelapse folder with the date and time as a file name.

If all is well then you need to write the code that will take pictures at regular intervals. Crontab is used and it is started as follows.

Step 3 – The Crontab code.

crontab -e

This starts the editor, scroll down to the bottom of the code and enter the following code

*/1 * * * * /home/pi/Timelapse/timelapse.sh

This is where I went wrong, no one said that there has to be a space after the */1 and between each of the * characters and a space before the command address. Without those spaces it will not work, and I admit that the code on the Internet had those spaces but they were impossible to see on my iPad.

Save and exit and if all is well the camera will start taking pictures at a 1 minute interval. This can easily be changed, for example */15 would take images at a 15 minute interval.

If an error message is shown when you exit from crontab go back and check the code.

Controlling Cron.
sudo /etc/init.d/cron stop
sudo /etc/init.d/cron start
sudo /etc/init.d/cron restart

All the images will be in the Timelapse folder and a programme like AVIdemux can be used to stitch them into a movie.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s