Introduction: Raspberry Pi Timelapse
This project will show the reader how to setup and customize a timelapse application using a Raspberry Pi, Model B and a RasPi Camera. The timelaplse can be customized to take pictures as fast as 1 per second or any time slower to once per year.
Raspberry Pi (any Model B)
Raspberry Pi Camera
Power Supply for RasPi
Case for Raspberry Pi and Camera
Step 1: Setup RasPi
If you have a case for your RasPi assemble your system.
1. Attach Camera to case in appropriate location as shown in the picture.
2. Assemble & attach RasPi to case.
3. Attach Camera To RasPi using the provided Ribbon cable as shown.
4. Close case and connect KB/Mouse/Monitor.
Step 2: Preparation of RasPi for Use With Camera
This step will be a little vague and point to appropriate resources as every user will have different preferences.
You can always use a pre-installed image that can be purchased from many of the RasPi Kit vendors but the basics of getting your Raspberry Pi installed if you are doing your own installation are below.
Install your OS on the Raspberry Pi Model B by first downloading the image you want to install.
If you download an single image file then you need to follow the image installation instructions:
If you download the Noobs installation it is actually a bunch of files in a Zip file, unzip the file once you download it and look for an INSTRUCTIONS-README.txt file for how to do the installation.
Once your OS installation is complete follow the instructions for configuring the RasPi Camera:
There is a lot of documentation available on the Raspberry Pi webpage in the help tab seen below.
Step 3: Test Your Camera
The RasPi camera is activated with the raspistill program, if you issue
It will give you a full listing of all of the camera options which you can test and use as needed by modifying the scripts. For this exercise we are assuming the camera will be taking pictures in a well lighted area that doesn't require any special settings. Running the test you can verify that the images come out correct before taking a full time-lapse.
To test the camera, from the command line issue:
/usr/bin/raspistill -o test.jpg
This will take an image and put it in the current directory, simply open the file to check that the image is as expected.
Step 4: Prepare Scripts and Setup Automatic Execution
I created two scripts the first simpler one is for execution at 1x/minute or more and will set up a cron job to execute either script once per minute.
1. Create crontab as root with crontab -e
The added line to execute 1x/minute should be:
* * * * * /root/cam.sh 2>/dev/null
2. Now create the first script
Edit a file /root/cam-60.sh and make it executable. This script will execute the raspistill program to take a standard picture every time it is executed. If longer than 1x/minute is desired simply modify the cron job above to run when desired.
Here is the script:
/usr/bin/raspistill -o $DATE.jpg
3. Create the second script for more than 1x/minute pictures.
Edit a file /root/cam-tl.sh and make it executable. This script will execute the raspistill program in Time-Lapse mode to take multiple pictures per minute this means the cron job needs to run every minute as in the example above.
Here is the script for taking pictures every 20 seconds:
/usr/bin/raspistill -t 40000 -tl 20000 -o $DATE-%03d.jpg
The options -tl means to take a picture every 20000 milliseconds (20 seconds) and the -t when used with the -tl option means that the execution runs for 40 seconds. This will create one picture at 20 seconds after the minute, one at 40 seconds after and a final one at 60 seconds after the minute as the next instance is starting.
Just remember that the -tl defines how long until the first picture and every following picture so it should be fairly easy to modify the options to get any time period down to the limit of the speed of the camera and storage.
Note: Having the two scripts makes it easy to change between them by simply copying which ever is desired to /root/cam.sh and later removing the /root/cam.sh will disable the cron job because the script will not be found to execute.
I have a short sample timelapse from one of our Raspberry Jams and will attach it as soon as I can get it to work.
We have a be nice policy.
Please be positive and constructive.