loading

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.

Materials:

Raspberry Pi (any Model B)

Raspberry Pi Camera

Power Supply for RasPi

Optional:

Case for Raspberry Pi and Camera

Setup:

KB/Mouse/Monitor

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.

https://www.raspberrypi.org/downloads/

If you download an single image file then you need to follow the image installation instructions:

https://www.raspberrypi.org/documentation/installa...

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:

https://www.raspberrypi.org/help/camera-module-set...

There is a lot of documentation available on the Raspberry Pi webpage in the help tab seen below.

https://www.raspberrypi.org/help/

Step 3: Test Your Camera

The RasPi camera is activated with the raspistill program, if you issue

/usr/bin/raspistill -?

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:

#!/bin/bash

DATE=`/bin/date +%Y%m%d-%H%M%S`

/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:

#!/bin/bash
DATE=`/bin/date +%Y%m%d-%H%M%S`

/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.

<p>Can you tell me where can I buy this case? I like it, because camera can be placed in it.</p><p>/radiohead</p>
<p>I didn't actually buy this case it was given to me but a google search for &quot;raspberry pi + camera case&quot; reveals it as the first one in images and looking into the site it's posted on indicates it's available from maker shed. I have not verified this however but it's probably where it was originally from.</p>
<p>Ok thanks, meanwhile I have found mine :)</p>

About This Instructable

2,304views

25favorites

License:

More by sepeters228:Custom frosted glassware Raspberry Pi Timelapse How to make Flat Sheets of Instamorph and other tips 
Add instructable to: