Simple timelapse camera using Raspberry Pi and a coffee tin

FeaturedContest Winner
Picture of 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.
Remove these adsRemove these ads by Signing Up

Step 1: What you need

Picture of 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

Picture of 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

Picture of 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
tundra2421 year ago
Sweet, I will try this. i've been to Oban/Mull/Iona
fotosyn (author)  tundra2421 year ago
Love it up there!!
pimmycouk.29 days ago

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

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?

I have the same problem, do you have solved it?

psnowknife10 months ago

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

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.

palmfiction7 months ago

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!!!

fotosyn (author)  palmfiction7 months ago

Hi there -- yes!

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

nashie00110 months ago

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.



mwestphal12 months ago

I am new to the Pi and Linux as well. I was having trouble downloading the python script. Tried the following and it worked.

sudo wget

FOXXfilms1 year ago
Heh, not bad! I wonder if it could make an 24h timelapse! Loved the inst. Though! Got my vote! Good luck!
fotosyn (author) 1 year ago
Hmmmmm good question -

the price of an illy coffee tin around £6 (nice coffee)

Pi and Camera £40

Batteries and Case £10

Probably tops around £55 maybe a little more. Main costs were the Pi and Camera

FOXXfilms1 year ago
How much did you spend on this? And how long does the battery last?
wooac1 year ago
Nice idea to use the coffee tin. I stuck my timelapse script in rc.local and used a bigger battery.
fotosyn (author)  wooac1 year ago
Thanks wooac!
Quick question, does it matter where the cron job is saved?
fotosyn (author)  GaryLittlemore1 year ago
Hey Gary...

yeah I think it's best to use

sudo crontab -e

this way you are editing the root's crontab and not storing any passwords. As it is root I think it is run from somewhere like /var/spool/cron/crontabs (need to check) but using the above command ensures you are editing the root's crontab.

Jim :D
fotosyn (author) 1 year ago
Thanks Petermonti !!
petermonti1 year ago
Great video !
kondzio291 year ago
I think you will won somethink in Raspberry pi Contest ;) Good luck !
fotosyn (author)  kondzio291 year ago
Thank you!! Very kind of you to say but there are some really cool projects in this contest. Part of the fun... wait and see!!
Of course you will win something, last time, I was saying the same and I won a 100$ 3d printing shapeways voucher (i'm still looking for someone who would buy it for 75$) and my instructable wasn't so much spectacular ;) you have got chances to win ;)
old_alex1 year ago
Looked at the script, given there is no RTC, how does the date code work.
Power up, take images, leave running or do you ssh in and shutdown in short how do keep from writing images when collecting the data in?
fotosyn (author)  old_alex1 year ago
Thanks Alex... I sometimes use it with a WiFi dongle that gets the correct date time. In cases where it's not been used, the date serves as an arbitrary number to prevent it over writing any previous time lapses.

Guess it could be supplemented in any way you see fir by a sequential number, but using the time means there is no need to store any such values.

Quick and dirty I guess.
dboulant1 year ago
Camera, in a coffee can, at the ocean? I really wanna call this the "Donny Cam"
it was probably their most modestly priced receptacle.
One cannot put a price on a quality Lebowski reference.
ASCAS1 year ago
fotosyn (author)  ASCAS1 year ago
Thanks ASCAS!!
Well done! Thanks for sharing!
fotosyn (author)  andrea biffi1 year ago
Thanks Andrea!