Simple Timelapse Camera Using Raspberry Pi and a Coffee Tin




Whilst developing BerryCam I thought it would be pretty cool to create a timelapse camera that could be left outdoors over a period of time, to capture a sequence of images that could be later joined together into a video clip. From the outset thoughts turned to housing everything in an ‘Illy’ coffee tin as it was pretty robust, watertight and could easily contain the Raspberry Pi and battery pack.

Step 1: What You Need

  • Raspberry Pi – Model A or B (A has better battery life)
  • Raspberry Pi camera module installed and set up
  • Illy coffee tin or similar sized container. Watertight and metal is best.
  • Some clear plastic, taped onto outer tin over hole
  • Plastic holder for camera. I used the lid from the case of these batteries
  • Elastic bands to hold the camera and cable in position
  • Battery pack – a 4xAA unit is best for size to power rating – I used this one
  • The Python script. Download from the FotosynLabs repo here

Step 2: Setting Up the Camera

A small hole drilled into the side of the tin allows the camera module to peer out of the tin. Living in Scotland rain is always a factor, as is the sea spray where I have been testing the device out. Using some clear plastic – the sort you get on moulded packaging, was ideal to keep everything enclosed and safe from water. But make sure you use an area that is flat and free from scratches or blemishes and that it is of good quality plastic (ie almost perfectly clear).

The camera module was mounted onto a plastic holder to easily allow for handling, adjustment and repositioning using Velcro tabs to mount this to the inside of the tin. Everything is held together with elastic bands, so changes in temperature and moisture won’t have as an immediate effect on adhesives. I had originally used electrical tape but the adhesive became soft, slightly gloopy and the pull of the ribbon between the Raspberry Pi and camera module had caused things to move about too easily.

Filling in behind this, is the power supply which keeps everything snug when in use. The particular unit has a handy power switch on top so you can easily switch the device on and off.

Using velcro on the plastic mount means you can easily remove the whole unit whenever you need access. When installing, make sure the camera is level in the tin (the edges of the plastic mount helps when aligned with the inner lip) and ensure the lens has an unobstructed view through the hole by looking through from the outside. If the lens appears centrally in this hole then it should ‘see’ everything without the edges of the hole creeping into the captured image. Testing is the best option to make sure everything is straight. Grabbing previews quickly with BerryCam is and ideal solution to do this.

With the camera installed – the Raspberry Pi and battery pack can easily be lifted out of the tin to allow of access to the various ports. I find it rests easily on the top of the tin when connecting to a display and keyboard if you need to use the device with a display. SSH works without the need to remove if you have a network connection available.

Step 3: Using the Python Script and Setting Up Raspbian

Setting up Raspbian to control the camera is pretty easy. Using the script I opted for an automated startup when the device is booted up. That way there’s no need for any SSH commands to be issued and it is simply a case of flicking a switch. To do this log into your box using Terminal on the Pi or log in remotely using Terminal or Putty.

ssh pi@XX.XX.XX.XX
(where XX.XX.XX.XX is the IP address of your Raspberry Pi)

First of all, we’ll need to get the Python script to control the camera. We’ll copy this into the /home directory as it’s easy to find and a good starting point, but copy to the place the suits you and your build.
cd /home
sudo wget <a href=""></a>

To check everything is installed, simply type


The script should be visible in the directory. Next, we can automate the startup so the camera activates each time it is powered up. To do we need to add a cron job. This will mean on each boot of the Raspberry Pi the script will activate and begin capturing images.

sudo nano crontab -e

At the bottom of the script insert

@reboot python /home/ &

Of course change /home to the correct pathway where you have the script.
Save this script (CTRL + X) and “Y”

Rebooting the device will mean this script executes. On testing I found that it needs a full shutdown before this will reliably work each time. So to reuse the device you’ll need to log in, and perform a shutdown with

sudo shutdown "now"

Once you have shut down correctly, you can simply switch on the Raspberry Pi’s battery power supply and the script will launch normally when the device boots up. This is easpecially useful if you’re deploying the timelapse camera for an extended period outside the range of network connections.

Step 4: Using the Camera

In this example I have set up the camera to shoot a big setting on the beach to catch the tide going out, some weather passing over and the clouds moving through the sky. When deploying outside, make sure your tin is securely closed and in a safe position so it won’t be blown away or toppled. Using a spirit level smartphone app while rested on top of the tin keeps everything level. And of course make sure the tin is secure and hidden from the view of passers by. Also make sure, if you do use this technique you don’t place it in places where such an item may cause alarm.

I did leave a note taped to the top of mine, explaining what it was and politely asking that it not be moved or disturbed. It all depends on where you use the camera but the rural southern coast of Arran with it’s rocky shore proved secure enough to leave out for lengthy periods of time.

Once you’re got everything in position and level, you’re good to go. Simply power up the camera, make sure all is secure and won’t be moved by a breeze and leave the camera to do its work.

Step 5: Post Capture and Editing

Putting the images together is easy. QuickTime allows you to join a sequence of images together and save out as a video clip. There are other tools out there like Premier and After Effects too. If you find your images are slightly off kilter I recommend running everything through a Photoshop action to remove the offset angle.

You can also combine still frames to make a movie clips using a command line entry like:

cd /<your_timelapse_folder>
ls *.jpg > list.txt
sudo apt-get install mencoder
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o timelapse.avi -mf type=jpeg:fps=24 mf://@list.txt

View an example of the resulting timelapse video

You can also get support on setting up and using the Timelapse camera here
Raspberry Pi Contest

Second Prize in the
Raspberry Pi Contest



  • Stone Concrete and Cement Contest

    Stone Concrete and Cement Contest
  • Backyard Contest

    Backyard Contest
  • Classroom Science Contest

    Classroom Science Contest

40 Discussions


4 years ago on Introduction

Quick question, I want to make this in order to timelapse my house being built, but won't be able to get out to it every day to change the batteries. Any pointers on putting together a power system that could let this operate for a few days to a week at a time?

Thanks, love the project.

3 replies

Reply 4 years ago on Introduction

I have been using a solar charged power pack like this one. This would power the board for months:


Reply 1 year ago

I'm curious - especially since we're 2 years later, how do you feel today about (this or other) solar powerbanks? Every solar product I find has tons of negative reviews, ranging from "50000mAh is really only 5000mAh" and "takes ages to charge" to "simply doesn't charge at all", so I'm wondering if I'm simply looking at the wrong ones...

I'll be taking images maybe once per hour initially to gauge how the sun will strike my lawn (I have shading trees at the back of my lot) but after that it will be only once or twice per day.


3 years ago

Thanks for the instructions. Although I've got this working ok on mains power, I have big problems getting it to work on batteries.

I've got the gomadic 4xAA holster you suggest, and loaded it with 4 x 2400mAh rechargeables, but It just gets unstable and crashes with wierd errors.

How did you do the battery side of things?

Nice one dude, I feel inspired to make one with the old Pi I've never learned how to use.


4 years ago on Introduction

How long can you run with that battery pack - Trying to figure out the capacity of the battery pack to run for a week?

2 replies

Reply 4 years ago on Introduction

This link(1) suggests about 17 hours on a 10,000mAh battery pack. However a Pi boots on powerup. I guess it would not be too hard to hard to put a timer on the power supply and a poweroff at the end of the 'take photo' script, have it running 5 minutes in the hour would give 8 days, 1 min/hour ~40 days.



Reply 4 years ago on Introduction

Update Just realized use a Pi A that has a 2-3 times lower consumption and could double or triple the endurance.


4 years ago on Introduction

there is a problem; "sudo nano crontab -e" needs to be "crontab -e"

otherwise you're making a new file called crontab.


4 years ago on Step 5

Thanks for the instructable. I'm 90% there. When I run the python program from the terminal window, everything functions properly. All pics are saved in the expected folder. Then I put the @reboot statement in the crontab. When the Pi starts up the light on the camera shows me it is taking photos, but the folders are not created and the.jpg's don't save. Both the program and the crontab instruction refer to /home/pi folder where the python progrm resides and where I expect the jpg folders to be created.

Any thought's?

1 reply

5 years ago on Introduction

After Running the script, all I get is "========= Doing nothing at this time" print statement, which tells me that if d.hour check is never resulting to true and hence not taking any pictures. can anyone tell me what the .hour method is checking and why it could be failing?.

I ran my script using sudo python

1 reply

Reply 4 years ago on Introduction

The default is that if d.hour is greater than 2, the script runs, else it just loops on '========= Doing nothing at this time' until the point where d.hour > 2 again.

d.hour is the current time, so with the default settings, when the time hits midnight 'Doing nothing' will loop for 2 hours. If you change this to 0, it should work fine.


5 years ago on Introduction

Did anybody find a way to do automatically take the pictures when connecting the pi to a power supply (without having to manually shutdown before!) ?

I want to build the pi into my van and connect to the van's power supply. Whenever I turn on the engine, the pi should boot and start taking pictures. It works so far, but only if I manually shut down the pi beforehand.

Any Ideas or references? Would be great, thanks!!!

1 reply

Reply 5 years ago on Introduction

Hi there -- yes!

Dougie Lawson over on the Raspberry Pi forums has a solution that makes the whole startup process more reliable


5 years ago on Introduction

Hi there,

I have an issue where the image name goes:





It is kind of like the while statement is skipping a beat. I have tried redownloading the script and not changing anything, and it still has the issue.

I know this may not be a problem on your script.. might be my pi...

It would be great to hear your thoughts.




5 years ago

Heh, not bad! I wonder if it could make an 24h timelapse! Loved the inst. Though! Got my vote! Good luck!