Simple timelapse camera using Raspberry Pi and a coffee tin

Posted by on Aug 21, 2013 in General, Raspberry Pi | 267 Comments
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.

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 raspiLapseCam.py Python script. Download from the FotosynLabs repo here

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

Showing hole drilled near top of tin with Velcro fasteners
Showing hole drilled near top of tin with Velcro fasteners

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.

Inner workings of tin, all hooked up.
Inner workings of tin, all hooked up.

Everything loaded into the tin, top - camera module, middle - Raspberry Pi and bottom - battery pack.
Everything loaded into the tin: top – camera module, middle – Raspberry Pi, bottom – battery pack.

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.

Make sure the camera lens has an unobstructed view through the hole drilled into the tin.
Make sure the camera lens has an unobstructed view through the hole drilled into the tin.

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.

Using the Python script and setting up Raspbian

Setting up Raspbian to control the camera is pretty easy. Using the raspiLapseCam.py 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. This is also a good time to create a folder to write images to, and change the permissions to make it writeable. This setup should work as the script writes to the folder /home/timelapse/ as a default; although you can change this if you wish. Just make sure you update the pathway within the Python script itself.

cd /home
mkdir timelapse
chmod 777 timelapse
sudo wget https://bitbucket.org/fotosyn/fotosynlabs/raw/9304ee9262638efebdd66d543b844a3075401782/RaspiLapseCam/raspiLapseCam.py

To check everything is installed, simply type

ls

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/raspiLapseCam.py &

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.

Using the camera

raspiLapseCam.py will create a folder for each timelapse session. You can change where this saves within the .py file but as a default this is in the same location in a subfolder. This way you can easily grab all the images from a session and then sequence them into an animation or video clip.

The effects and adjustments are all still available as it uses raspistill to capture images. Simply edit these parameters within the script if you want to make changes.

Next thing is to use it! There are no rules but as a suggestion best times are at dawn and dusk when the light is at its most changeable and dramatic. Many photographers refer to this time as the ‘Golden Hour’

Shooting overnight proved a bit more tricky with everything in darkness. I guess there would be a trade-off between the required increase in exposure time and battery life. Under normal conditions I was getting around 7.5 hours uptime using standard Durcaell AA batteries and a Raspberry Pi Model B.

The Timelapse Camera set up in position
The Timelapse Camera set up in position

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.

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

 

It may take some experimentation to get everything the way you want it, but this is a great way to enjoy nature’s beauty, the changing light, weather systems and wildlife, even if the weather is inclement.

267 Comments

  1. Roy
    September 1, 2013

    This great, have got it running fine in the desktop environment and keeps the photos. But I run it on start up, via the crontab command it seems to take the photos, but is either saving them somewhere else or not at all. Any ideas?

    Reply
  2. Jim at Fotosyn
    September 1, 2013

    Thanks Roy…

    I found that sometimes it didn’t fire if I didn’t shutdown the Pi correctly using…

    sudo shutdown “now”

    When I was testing outside, I made sure that I always ‘primed’ it up before setting up again.

    I’d also try using the Terminal more and trying

    cd /home
    ls

    you may well see timelapse folders here. If you have got Apache running, I found it useful to save the images to /var/www and that way you can access them in a web browser.

    I hope some of this helps… thanks for trying the script and glad to hear at least you have had some results out of it.

    Reply
    • Rob
      February 12, 2014

      I’m having the problem as well, and a clean shutdown doesn’t help. I can run the script manually and it works great, but if I run it from crontab the camera turns on and appears to work, but the images aren’t being saved.

      Any other suggestions?

      Thanks!

      ~Rob

      Reply
  3. Sancho
    September 6, 2013

    To playback sequence of images, I would recommend using mplayer, something like
    mplayer mf://*.jpg -mf w=1920:h=1080:fps=25:type=jpg
    To encode the images into MPEG4 video, try
    mencoder mf://*.jpg -mf w=1920:h=1080:fps=25:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -o output.avi

    I made something similar with 2 differences – I used standard (lower resolution) USB webcam – it was cheaper and available, although the resolution was only limited to 1280×720.
    The second thing I did was to use uvcdynctrl to set a manual apreture – this allows smoother “sunrise” without the webcam brightness compensation. On the other hand, I had to set it up upfront and hope for the next-day weather ;)

    Reply
  4. Michael Horne
    September 6, 2013

    Great write-up for a nice little project – thank you! Might use it at a Raspberry Jam to do a time-lapse of the crowd!

    Reply
  5. MIguel
    September 6, 2013

    Good work!

    Without ventilation/heat dissipation, how was the temperature of the rpi?

    Best regards,
    Miguel M.
    Portugal

    Reply
    • Jim at Fotosyn
      September 6, 2013

      Hey Miguel… thanks for your question

      In my tests it was absolutely fine although that is the cooler climate of Scotland.

      I think the metal container helps conduct the heat away but I guess it would be different in various environments

      Reply
  6. Waterproofing your timelapse rig | Raspberry World
    September 6, 2013

    [...] You might remember the post we wrote about BerryCam, a way to operate your Pi’s camera board (available from any of our main distributors – check the “Buy a Pi” links at the top right of the page) from your mobile phone, from  the other day. Jim, one of the BerryCam engineers, has also been playing with the camera board in another project: a waterproof timelapse rig in a coffee can. [...]

    Reply
  7. Amedee Van Gasse
    September 6, 2013

    You can also render to h264 video on the Raspberry Pi itself.

    Reply
  8. Håkan
    September 6, 2013

    why not make a script that produce the movie after 1440 pictures( 1440mins=24 hours)

    just

    ffmpeg -y -r 25 -i %*.jpg -b 2000000 my_timelaps_movie.avi

    just install ffmpeg first :)

    Lycka till..

    Reply
    • Jim at Fotosyn
      September 6, 2013

      Good idea although in many cases I doubt the battery life would last that long, but if it were powered by mains then yes definitely a good call :)

      Reply
      • Swifty aka Steve Swift
        December 29, 2013

        I’ve heard that the newest generation of NiMh “pre-charged” batteries have a longer life than standard “AA” batteries. They’re also cheaper in the long run. I’m testing SANYO Eneloop HR-3UWXB 1.2v 2450 mAH.
        However, I’m testing them in my Logitech laser mouse, and the darn things last WEEKS… I’m still on my first pair!

        Reply
        • Jim at Fotosyn
          January 4, 2014

          Hey Swifty… blimey that’s good battery life! I’m using 7DayShop 2900mAH batteries which seem to pair up great with the Model A.

          Reply
  9. Steve
    September 6, 2013

    Brilliant project write up – thank you.

    Personally very impressed with the camera module, couldn’t believe how windy it was the other day when using motion capture youtube.com/watch?v=l5znDO using the simple python script goo.gl/A8QWVf – VERY tempted to create a trail cam very similar to this project.

    I know it would have used more power, but I add one of these http://goo.gl/gKd6AD to check what is happening via an XRDP connection.

    Again, many thanks for the write up and sharing this great project

    Steve

    Reply
  10. Andy Armstrong
    September 6, 2013

    Very cool :)

    Instead of shooting discrete stills you can do what are, in effect, speeded up movies. There’s (poorly documented) code here to do that:

    https://github.com/AndyA/timewarp

    The results look like this:

    https://vimeo.com/66772178

    Reply
    • Jim at Fotosyn
      September 6, 2013

      BAM!! That is super cool. Need to do this one though I’ll need bigger batteries!

      Reply
  11. coni
    September 6, 2013

    Great work!

    The flying penguin at the end is a particularly good flourish! ;-)

    Reply
    • Jim at Fotosyn
      September 6, 2013

      Haha thanks!!! Yeah there was a big heron plodding about the area but missed it

      Reply
      • Tom
        September 7, 2013

        Herons are evil things. Ate one of my frogs.

        Reply
  12. Raven
    September 6, 2013

    Have you (or anyone else) got any insight into how to weatherproof it a little more permanently? I’m working on setting up my Pi as a combination wireless doorbell and security camera. For now I’ve got the board on the inside of my window, but I’d like to stick it outside to get a better view.

    Reply
  13. BerryCam | Circle and Square
    September 6, 2013

    [...] BerryCam is an amazing time-lapse photography project for the Raspberry Pi. Check it out, and check out the photography! [...]

    Reply
  14. Joël
    September 6, 2013

    Dear Jim,

    I followed your tutorial, and every things goes as you explained.
    So when I type “ls”, I see that the files are there.

    But when I use “sudo nano crontab -e” I get an empty screen, which I can edit.
    But shouldn’t there be a script with all the settings?

    Thank you in advance for replying.
    Joël

    Reply
    • Thijs
      September 8, 2013

      Hey Joël,

      Its in the map /etc
      So it would be “sudo nano /etc/crontab -e”

      Have Fun

      Reply
      • Nigel
        September 8, 2013

        Just plain ‘crontab -e’ works for me.

        Nigel

        Reply
        • Joël
          September 9, 2013

          Thanks Thijs & Nigel!

          One more noob question though. How do I open/edit the .py file, so I can change some parameters?

          Reply
          • Jim at Fotosyn
            September 9, 2013

            Hey Jöel you can use

            sudo nano raspilapseCam.py

            Which open the editor in the Terminal

      • Antoine
        January 24, 2014

        I’ve got it in the /etc directory too. Does that mean that in the crontab file I should add another ‘/’ before /home/pi/raspiLapseCam.py?

        Reply
        • Antoine
          January 24, 2014

          Oh and yes… I’m a noob :-)
          I’m asking this because I did everything as described in the tutorial, but after rebooting it does not start recording.

          Will try now to add ‘sudo’ before the python command.

          Reply
  15. Daniel Radcliffe (Dan3008)
    September 6, 2013

    Nice rig, I’d been looking for a way of doing a water proof timelapse. Now i just need to persuade my wife to let me get all the parts (and a new pi, my current two are tied up as a home media player, and an internet radio of sorts lol)

    Reply
    • Jim at Fotosyn
      September 6, 2013

      Go on get a model A – £20 odd squid and a good excuse to drink more coffee!!

      Reply
      • Daniel Radcliffe (Dan3008)
        September 7, 2013

        haha, I’ve got the coffee tin, granted it’s 1/2 full of coffee atm. Problem is, the wife says until I get a new job (Everyone hates redundancies) I’m not aloud a new pi :( So i need to get a pi, a battery pack, and a camera board…

        few months, and i’ll get everything lol

        Reply
  16. karl
    September 8, 2013

    fascinating stuff.

    Reply
  17. Raspberry Pi – Erste Schritte mit Raspbian WheezyMindcloud | Mindcloud
    September 8, 2013

    [...] Nach ein wenig recherchieren fand ich dann ein paar Projekte, die mit einem Raspberry Pi umgesetzt wurden. Z.B. das hier: Eine Zeitraffer-Kamera in der Kaffeedose [...]

    Reply
  18. Llion
    September 8, 2013

    Have you had any issues with SD card corruptions when the battery runs out and the pi doesn’t shutdown properly? Or do you have some clever way of shutting down before that happens?

    Reply
    • Jim at Fotosyn
      September 8, 2013

      Not as such and I’ve pulled the plug many a time when I was developing this and BerryCam — but I guess it’s the luck if the draw but never had that issue

      Reply
  19. jonas odorizzi
    September 8, 2013

    Congratulations ! its very interesting !

    Reply
  20. Raspberry Pi Bookmarks - Yet Another Blog
    September 9, 2013

    [...] Fotosyn » Simple timelapse camera using Raspberry Pi and a coffee tin [...]

    Reply
  21. David
    September 10, 2013

    Hi,

    Great project, and thanks for sharing.

    Does the battery pack you used come with all the correct cables? The Amazon description is really odd and the makers don’t seem to understand how a Raspberry Pi actually works…but it’s a fairly cheap product…

    Ta

    David

    Reply
    • Leigh
      September 19, 2013

      I bought the one from the link, from Amazon. It comes in two parts. The main housing, with an output that looks like a 3mm jack, and a connecting cable which converts the 3mm jack to micro USB.

      Not tried attaching to the RPi yet, but I’ll give it a go tonight

      Reply
  22. Ken Nickerson
    September 11, 2013

    It’s a little weird to use a Pan/Tilt on something like this, but this KickStarter might add some new dimension here:

    Pi-Pan for Raspberry Pi
    http://www.kickstarter.com/projects/1842571016/pi-pan-a-pan-tilt-for-raspberry-pi-camera

    going to give this a try just for fun… maybe some sort of tilt/shift effect?

    Reply
    • Daniel Radcliffe (Dan3008)
      September 12, 2013

      Thats cool :)

      I’m currently using n EBB (from a second hand egg bot lol) to drive 2 stepper motors to achive a similar effect.

      Reply
  23. Sam Jamieson
    September 17, 2013

    Hey. This is great, I just made my own time lapse Pi so thanks!! I am confused about what this piece of script is for?

    d = datetime.now()
    if d.hour > 2:

    Cheers!

    Reply
    • Jim at Fotosyn
      September 17, 2013

      Oh yeah! Well spotted. I reckon it’s back from testing days where I was triggering the camera to start at 2am. The resins why escape me at the moment, I have no idea other than probably the early light mornings up here in Scotland in June and July.

      I would imagine you could replace this with simply…

      d = datetime.now()
      if d.hour:

      or

      d = datetime.now()
      if d.hour > 0:

      Reply
  24. Balco
    September 17, 2013

    I still cannot find any pictures saved when using crontab
    this works ok when run directly
    I have tried closing down completely but after booting up theres nothing there.
    it goes through the motions of taking the picture but nothing stored
    I believed Roy had the same problem but I did not see the answer
    could you help

    Reply
    • Sam Jamieson
      September 18, 2013

      I had this same problem. I found that as I had not specified where I wanted it to save them it was putting them in the root directory. I fixed it by editing the script where it talks about make directory. I simply added /home/ before the info about timelapse+number+time.

      Sorry I can’t copy the actual script in but I am on my phone. If that doesn’t help I can get te exact changes I made when I get home.

      Sam

      Reply
  25. Sam Jamieson
    September 18, 2013

    Also thanks for the reply Jim! I will try those changes out. My last test ended with a two hour gap from 00:00 to 02:00, haha.

    Reply
    • Jim at Fotosyn
      September 18, 2013

      Gargh thank you for flagging it up – I’ll roll out the new code tonight once I’ve tested it

      Reply
  26. Dan3008
    September 20, 2013

    I’ve just got a python controled we server working on my pi :D
    so when my camera arrives, I’m going to test it out. My idea is to add start/stop timelapes functionality, as well as a config modifier. and maybe the ability to take single stills…

    all this and more to come :D

    Reply
    • Jim at Fotosyn
      September 20, 2013

      Sounds awesome! Look forward to this!

      Reply
      • Dan3008
        September 21, 2013

        I’ve have to modify the time lapse code to run from a config file instead of hard coded values, slowing it down slightly.

        Thinking about it, I’d bet even money that i could persuade it to do video recording too from the web interface…

        I’ve got the basic code working, just waiting on all my parts for making this :D. Once its done, I’ll write a bog post and share it with you :)

        Similarly, it ill be open source, so everyone can play :D

        Reply
  27. Gasha
    September 23, 2013

    Thanks!
    Set up similar can as this, and it looked great.
    Some problems however:
    1) Raspberry model B is too hungry. Didn’t get my A model in time, so had to use whatever had. Battery pack with UBEC ended too fast.
    2) I got some red stains in image corners, because of can reflections and red LED during camera capture. Fix would be black tape around hole inside can.

    Reply
  28. Gasha
    September 26, 2013

    Couple of comments.
    In short, i got A model today.
    Perhaps nobody wants it in Latvia, and local RS distributors made mistake.
    But thanks to them, they fixed it very fast, and even gave discount.

    Connected HDMI to configure, and one side effect is that picture shows live during capture.
    Modified script “if d.hour < 99:", this looks more correct. Might be that previous time that prevented to take more pictures.
    Also i have "sleep(10);", and with all overhead it gives me 4 pictures every minute. Approx 5 seconds to take picture and write it to btrfs partition.

    Im using UBEC converter (couple of USD, from eBay), and connected all to 12V12Ah lead accid battery right now. Connected multimeter, and it measures approx 60mA during idle, and 130mA during capture. I think this gives good starting point for runtime calculation. Without HDMI might be less.

    Idea is to put larger battery inside some bucket with cover.

    Reply
    • Gasha
      September 26, 2013

      Measured the same setup with Model B:
      Difference is HUGE!
      Shutdown = 60mA (the same as idle for A)
      Idle = 150mA (more than loaded A)
      Capture = 230mA

      If you don’t have Raspberry A model, it is right time to order one.

      Reply
      • Jim at Fotosyn
        September 26, 2013

        Great post. Yep I have both As and Bs and definitely noticed the difference.

        Reply
  29. Sam Jamieson
    September 26, 2013

    Hey, I just wanted to say I have been using this battery – http://www.amazon.co.uk/gp/product/B00CEZJT2E/ref=oh_details_o00_s00_i00?ie=UTF8&psc=1 – It fits in the tin nicely, has given me over 12 hours of power and is easily rechargable. Definitely recommend.

    Reply
    • Jim at Fotosyn
      September 26, 2013

      That looks really cool! Might need to check that out. Thanks for posting the link.

      Reply
  30. Terry
    October 6, 2013

    Hi Jim Loved the article started to run the script last night just one little problem.
    I keep all my scripts in one place /root/scripts/ so the files are of course ending up in it plus the date etc. Tried to add the location required but keep getting errors . Would have been easier 35 years ago and Z80 code. The location I am trying to get the file to go to is. /media/pictures/
    Can you advise the exact place to add the directories.
    I have one timelapse system running in a waterproof plastic box can fit on a tripod.
    Wife has just bought the coffee so have to empty the tin. ;)
    One of my timelapse is on Vimeo 24 Hour Timelapse Cacti Flower

    24 Hour Timelapse Cacti Flower
    http://vimeo.com/69685086
    Hoping to get the full tide on the shorline at the Severn River with your project.as it gets a tide up to 14m
    Keep up the good work

    Reply
    • Jim at Fotosyn
      October 6, 2013

      Whoa Terry!!

      That’s a great timelapse… never realised flowers could open so quick…

      Really looking forward to seeing what you do with the Severn project… that is some tidal shift!

      If you want to get this running in your /medi/pictures folder simply do this

      cd /media/pictures/
      sudo wget https://bitbucket.org/fotosyn/fotosynlabs/raw/9819edca892700e459b828517bba82b0984c82e4/RaspiLapseCam/raspiLapseCam.py

      If you run it from here using

      sudo python raspoLapseCam.py &

      You should be able to save and ultimately get access to the files you need.

      Let me know how you get on. Cheers!

      Reply
  31. Terry
    October 6, 2013

    Hi Jim Yes that works when I correct the o to i in pi;). I was trying to run the python script from my /scripts/ directory but if it has to be the p/pictures/ so be it.
    The cacti flowers and dies in 48 hours and they open completely in the dark so have to edit that.
    Perhaps next year will try to light it up at night.
    Orchids are good they take 48 hours did a few but besides the bud opening it moved towards the camera to close and ended up out of focus.
    I use mencoder and make the frame rate 50 per second it seems to give a nice smooth change.The Pi does very well to render 48 hours of pictures.
    Terry

    Reply
  32. Sam Jamieson
    October 6, 2013

    Hi, does the script record an event log anywhere? For some reason it finished early and I cannot work out why. I did catch someones leg in a frame about an hour earlier though…

    Sam

    Reply
    • dan3008
      October 6, 2013

      I don’t believe it does, but shouldn’t be to difficult to add it.

      Reply
  33. Leigh
    October 15, 2013

    My first proper effort:

    http://vimeo.com/76993626

    Admittedly, It was shot through a window from a couple of feet away, but a bit pixelated for some reason…

    settings:

    imgWidth = 1920
    imgHeight = 1080

    os.system(“raspistill -w ” + str(imgWidth) + ” -h ” + str(imgHeight) + ” -o ” + str(folderToSave) + “/” + str(fileSerialNumber) + “_” + str(hour) + str(mins) + “.jpg -q 100 -sh 50 -awb cloud -mm average -v”)

    Reply
    • Jim at Fotosyn
      October 15, 2013

      Leigh this is AMAZING!

      Great sense if distance and the use of that building in the foreground to show reflection and texture was inspired.

      Checked it in an iPhone but please drop me a still from your sequence and I’ll take a look. Other than that it looked really fantastic. Thanks for sharing!

      Jim

      Reply
  34. Jeremy
    October 16, 2013

    thanks for this Jim! I bought a 8000mAh battery pack from monoprice.com and put my set up in a pelican case with a clear plastic lid. I could never get the crontab thingy to work to run the python script so I edited a file called rs.local. Also, I used a usb microSD card reader to save the files to but I first had to figure out how to mount the usb drive. Here is my first timelapse: http://imgur.com/fsmrdyG

    Reply
    • Jim at Fotosyn
      October 16, 2013

      Fantastic timelapse! Live the flaring light near the end and the scrabble if clouds! Keep em coming!!

      Reply
  35. Vicky
    October 19, 2013

    Hi Jim,

    Thanks for sharing this great tutorial! This is my first Raspberry Pi project and I’m hoping to get it running up and running in time for my trip to Iceland this week.

    Like Joël, I found I needed to add /etc/ in front of “crontab -e”. The first time I did it without and ended up creating a new file called crontab in my home directory, which I had to figure out how to delete.

    The script is in /home and I’ve done the full shutdown. However, I still find when I add power again it boots up straight to Raspbian. The camera doesn’t appear to be doing anything between the time I remove the power and when I plug it back in.

    I am using USB power supply instead of a battery pack. Could that be it?

    Any suggestions would be much appreciated!

    Reply
    • Jim at Fotosyn
      October 21, 2013

      Hi Vicky.

      First off your trip sounds FANTASTIC! I’m jealous as I know Iceland is a photographers paradise.

      I found sometimes that when I pulled the poweron the RPi it needed a reboot and proper shutdown to get things working reliably for it’s next session. TO do this I simply hooked it up to a TV with HDMI and let it boot, then did a

      sudo shutdown "now"

      Not sure if it does some form of recovery checking on reboot from a bad shutdown, but this solved the problem.

      Also, in your crontab file, are you running as sudo? I’d doubt very much it had anything to do with power sources.

      I hope this works for you, and like many I am sure really excited to see your results! I’m hoping someday soon to develop BerryCam to work with the timelapse aspect on both iOS and Droid devices.

      Reply
      • Vicky
        October 21, 2013

        Hi Jim,

        Thanks! I’m hoping to set up the camera by the window and to try and capture some northern lights activity. I don’t think I’ll have the time to put into a weatherproof case.

        I’m not sure what you mean am I running my crontab as a sudo. To get into the crontab, I typed “sudo nano /etc/crontab -e” into the SSH.

        I then put in “@reboot python /home/raspiLapseCam.py &” at the bottom of the crontab file.

        I then did shut down using the sudo shutdown “now” command. And then when I removed and reinserted the the power source, it just booted up like normal.

        Am I missing something?

        Reply
        • Jim at Fotosyn
          October 28, 2013

          Hi Vicky…

          If you maybe try

          @reboot sudo python /home/raspiLapseCam.py &
          

          That might do the trick!

          Thanks… Jim

          Reply
          • Charles
            February 26, 2014

            Hi Jim! Thanks for a great Project! Works fine, but I can’t get that Pi to autostart. Same problem as Vicki. I did exactly as she did, and even tried to put a “sudo” there too as you suggested. Have I too missed something?

            Here is a copy of her note:
            Hi Jim,

            Thanks! I’m hoping to set up the camera by the window and to try and capture some northern lights activity. I don’t think I’ll have the time to put into a weatherproof case.

            I’m not sure what you mean am I running my crontab as a sudo. To get into the crontab, I typed “sudo nano /etc/crontab -e” into the SSH.

            I then put in “@reboot python /home/raspiLapseCam.py &” at the bottom of the crontab file.

            I then did shut down using the sudo shutdown “now” command. And then when I removed and reinserted the the power source, it just booted up like normal.

            Am I missing something?

            Best wishes,
            Charles

          • Sam Jamieson
            February 27, 2014

            Hi Charles,

            I had the same problem when I reinstalled the script this weekend. I could only get it to work if dropped both the sudo and nano eg $ crontab -e

            If you run crontab -l afterwards it will tell you if you have any cron jobs running and therefore if it worked.

            If it is right then you should see a screen with some info explaining how crontab works. If I used sudo nano crontab then I seemingly created a new crontab file that did nothing. Sorry if this is a bit vague, I am a beginner and am at work so can’t check what I did properly.

            Sam

        • Jim at Fotosyn
          November 4, 2013

          Hi Vicky did the ‘sudo’ option work out for you.

          Once thing I have noticed is at night the darkness can be very dark… so might want to change the camera setting in RaspiStill to something more suited to night time??

          Reply
  36. Terry
    October 21, 2013

    Jim decide while waiting for the battery to arrive to give the coffee tin a water test.
    Smeared vaseline around the threads of lid and tin put into water upside down for 6 hours
    and only had haff a teaspoon full of water.
    Have not drilled the camera hole but do have waterproof type sellotape for that hole with clear plastic.
    So if one put some of this very absorbent sponge on the top above the PI and battery I think it will work under water.
    Terry

    Reply
  37. Samir Sogay
    October 25, 2013

    I have been able to run timelapse successfully but I want to be able to save to a specific folder rather than home. How do I edit the script so that it saves to /home/pi/imagefolder. What should be the line folderToSave = “timelapse_” + str(initYear) + str(initMonth) + str(initDate) + str(initHour) + str(initMins) in this case?

    Reply
    • Jim at Fotosyn
      October 28, 2013

      Hi Samir,

      Yep, if you change that line to where you want the files to save that’ll work.
      Try:

      folderToSave = “/home/pi/imagefolder/timelapse_” + str(initYear) + str(initMonth) + str(initDate) + str(initHour) + str(initMins)
      

      Jim

      Reply
  38. Ole
    November 3, 2013

    Can you help me solve this?

    pi@raspberrypi /home $ python raspiLapseCam.py
    Traceback (most recent call last):
    File “raspiLapseCam.py”, line 67, in
    os.mkdir(folderToSave)
    OSError: [Errno 13] Permission denied: ‘timelapse_201311032112′
    pi@raspberrypi /home $

    How do I grant permission?

    In advance, thank you! :-)

    Reply
    • Jim at Fotosyn
      November 4, 2013

      Hi Ole…

      Maybe try running the script as sudo

      pi@raspberrypi cd /home 
      pi@raspberrypi sudo python raspiLapseCam.py
      

      Let me know how you get on.

      Reply
  39. dan3008
    November 4, 2013

    Got a PiNoIR on order, hope to try this with infer read photography :)

    Reply
  40. Jim at Fotosyn
    November 5, 2013

    Just picked up a Pi Noir from Element 14.
    Will see what I can do with this, might make for a great nocturnal wildlife cam.

    I have a spare Raspberry Pi rig, coffee tin to give this a shot.

    More info on that Pi Noir here…
    http://www.raspberrypi.org/archives/5128

    Reply
  41. triple clones
    November 6, 2013

    Have you thought of setting “tvservice -off” on startup? I’m lead to believe this will assist with battery life

    Reply
  42. Jim at Fotosyn
    November 13, 2013

    Hi all, the Bitbucket source has been updated…
    This fixes the “2am” issue. Simply pull the new pythin source using the guide in the original article.

    Reply
  43. Dan Roscigno
    November 22, 2013

    Thanks for the instructable, I have been trying to think of a way to video an owl nest box I am building, this will be perfect.

    Reply
    • Jim at Fotosyn
      November 22, 2013

      Dan, this sounds really cool! I’m playing around with a PiNoir at the moment using IR LEDs. Owls being noctural (I think) this might work as a good option too!?

      Reply
  44. Paul Hart
    November 26, 2013

    Awesome work Jim, thanks for your hackery!

    I had a few issues getting the cron job setup & permissions, here’s what worked for me if it helps.

    Using NOOBS the default login directory is /home/pi so that where I downloaded the script too & I had no problems saving folders/images to that directory (it was failing in the home directory)

    To get the cron working I excluded nano from the command to create the crontab

    crontab -e

    then add path to the script – @reboot python /home/pi/raspiLapseCam.py &
    save & exit then check it’s been added with crontab -l

    Reply
    • Jim at Fotosyn
      December 1, 2013

      Thanks Paul for the words and the tip. A pint I owe you!

      Reply
    • Gary Littlemore
      January 18, 2014

      Hi Paul/Jim

      Are you doing just ‘crontab -e’ within the /etc/ folder? Are you putting ‘sudo’ at the start of the command?

      Gary

      Reply
  45. Jose
    November 30, 2013

    Hi!

    First of all, thanks for the great tutorial. I wanted to pass along some of my findings while doing this with a Model B board and a possibly older version of Raspbian.

    Initially, I wasn’t able to get things reliably working after reboot until I did the following –

    * upgraded the OS (using 1) “sudo apt-get update” then 2) “sudo apt-get upgrade” then 3) “sudo apt-get dist-upgrade”)

    * used “crontab -e” to add launch the raspiLapseCam.py script (and confirmed it via crontab -l). Thanks for the tip Paul Hart!

    * shutdown the Pi using “sudo shutdown “now””, then waited until my ssh connected was terminated and IMMEDIATELY disconnecting power to the Pi. When I powered on again, things were working. While this has been stated already, I think I was disconnecting the power at some point after the Pi had booted up which caused the script to fail at the next boot time.

    I hope this helps!

    Reply
  46. Rick
    December 9, 2013

    Thanks for the great script I have been testing it and am planning on using to create a timelapse of my daughters 2 year birthday party.

    Here is something else that might interest you that I have been modifying. It is a script that uses raspistill to test all the exposure and auto white balance settings so you can decide which are the best settings for your capture: https://github.com/ntalekt/RaspiStill_Camera_Options

    Reply
    • Jim at Fotosyn
      December 10, 2013

      Hey Rick this sounds great and I’ll need to check it out! I’m playing around with small TFT screens which would be handy to check in the field and I am at some point looking to implement timelapse into BerryCam so in essence the functionality you get with RaspiLapse will be in that app.

      Part of the attraction in doing this is to allow for previews before shooting. I’m also thinking if there’s a way to apply logic to images (maybe if they are mostly black) where it lengthens the interval to cut out long periods of darkness.

      Winter in Scotland presents ample conditions to test this (it’s constantly bloody dark at the moment) and with the run up to the shortest day, and a bit of free time over the break might be a good time to try something (iOS and Droid)

      But I will need to check out your script too as it does sound really useful. A handy addition could be a rendered overlay on each image with the settings.

      Maybe such a sequence could be part of an enlarged BerryCam with picker view to choose the best looking image and settings? You know kinda like that variants tool in Photoshop.

      Like I say I have a Droid version of BerryCam in the works.

      Cheers!!

      Jim

      Reply
      • Rick
        December 11, 2013

        Droid version of BerryCam would be great because I’m an Android user. RaspiLapse functionality in BerryCam would be fantastic and would remove the requirement for an RaspiLapse LCD in the field.

        Interesting idea about the logic to sense dark images and extend the interval, i’ll look into that.

        I’ve been thinking instead of the RaspiStill_Camera_Options script outputting images to a folder that it could output a formatted gallery or “contact sheet” to a web server on the RPi. Which would make viewing and selecting the perfect exposure and white balance configuration a lot easier.

        Definitely agree with you and think the setup and workflow of defining the optimal raspistill settings would be a great additional to an enlarged BerryCam project. Would reduce pre-capture setup time.

        Reply
  47. Terry
    December 9, 2013

    Rick what a great little script I have just loaded it and caught the final light of the day to test. It will be very use full. . I did get black only pictures with the SPOTLIGHT option.
    do you get the same.
    Question to JIM and all watching this blog has anybody go their coffee tin camera working with a WiFi dongle on AD-HOC to a Laptop. I found a plastic cup from a vacuum flask fitted the tin giving a WiFi signal and maintained the waterproof.

    Terry

    Reply
    • Rick
      December 10, 2013

      Terry, thanks it’s been really helpful for me too. Yes I did get the same results with the spotlight option. I tried it inside and the spotlight option picked up my overhead light so I’m guessing it’s only for extreme light environments or maybe when you have a light pointed directly at the lens.

      Reply
      • Terry R
        December 10, 2013

        Rick thanks for the reply perhaps a test of direct sun rise or sunset with the spotlight command will need to try it. I have found the hard plastic caused the picture to go soft. I have had a glazier stick a thin glass 40mmx10mm on the coffee tin and it is waterproof.

        Reply
  48. Don DeGregori
    December 10, 2013

    Hi Jim, Just finished your super TL project. Your .py script works great. The need for sudo shutdown “now” before another shoot is interesting. How about putting the shutdown phrase within the code triggerd by .jpg serial number, lets say 300 (5 hours)? That way one could start another 5 hour session without a needing a computer in the field. Or maybe better yet, a button to push to send the shutdown phrase at anytime.

    Reply
    • Jim at Fotosyn
      December 10, 2013

      Don – the button is a great idea. Something I might take a look at over the break. :-D

      Reply
  49. Kenneth
    December 11, 2013

    I can really recommend this python-script. It works so smooth! I’ve been running up for two days now and still running without any issue :D

    Reply
  50. Terry R
    December 11, 2013

    Jim I have a push button/toggle switch working on my Coffee Tin Camera the bash script runs on switch on and looks at 2 gpio pins every second. 1 pin going low start the timelapse program and 1 Pin runs a HALT could be changed to reboot. You are welcome to the script as I found it on the web a year ago just changed it for my use..

    Reply
  51. Don DeGregori
    December 11, 2013

    Hi jim,

    A few days ago, I posted a comment about adding a proper shutdown command within your python script, so it would come up upon boot. Could you e-mail me about about my question?

    Thanks, Don

    Reply
  52. Don DeGregori
    December 11, 2013

    Thanks, I should have known I have to subscribe this blog.

    Don

    Reply
  53. Don DeGregori
    December 12, 2013

    If a time lapse session is started, the date and time could be incorrect from the last session. I think the RPi rig should be first connected to the network via SSH to receive network time and then do the normal proper shutdown to then boot with battery, unless one is using wireless or LAN during the shooting session. Is this right?

    Reply
    • Jim at Fotosyn
      December 12, 2013

      Hi Don

      Yeah pretty much. The date time thing is a quick and dirty way to use an incremental ID number so to avoid in general the overwriting of files and folders and the need for some kind of configuration file.

      Cheers!

      Jim

      Reply
      • Don
        December 12, 2013

        Understand. Think I’ll get out there and start a session instead of talking.
        Today, many clouds, finally!

        Thanks,
        Don

        Reply
  54. Don
    December 15, 2013

    Hi Jim,
    I’m using a Type A RPi and Pi Cam. Powering with 5 volt stable switching regulator. Started taking pictures at 1 per minute. Didn’t change any other option. Looking at Christmas Cactus with red flowers, many not opened yet. For some reason camera stopped at 213 pictures, over a 100 megabytes. Ran less than 4 hours. The 4 GB SD card still has 1.3 GB left. Why it stopped?

    Reply
    • Terry R
      December 15, 2013

      Don Cannot help you with your problem just would like to say for Christmas Cacti one every minutes is to often. I have just finished one and it was every 3.5min over 10 day for a bud to open ended up with 5244 pictures as I used cron to stop and start the timelapse program each day.
      Just posted the video on Vimeo if you want a look

      24 Hour Timelapse Cacti Flower
      http://vimeo.com/69685086

      Christmas Cacti Timelapse on a Raspberry PI
      http://vimeo.com/81707982

      Next project a forsythia bursting into yellow flower then turning into green leaf I hope.

      Terry R

      Reply
      • Jim at Fotosyn
        December 15, 2013

        Great vids Terry! Really smooth but I guess that’s helped because things move so slooooooww.

        Cheers,

        Jim

        Reply
    • Jim at Fotosyn
      December 15, 2013

      Thanks for your post Don,

      It could be a number of things – maybe the power source? Maybe the way the time-lapse command is invoked? It’s difficult to tell unless you could re-run the test with say a different power source, or take into account any other settings on the Pi. Without additional testing or info, it’s gonna be difficult to tell you where the problem lies.

      Are you invoking the time-lapse command from another device through SSH or is it directly on the Pi itself?

      For your reference, have you tried the set up as per the blog post? The reason I say this is because I had mine running at 1 shot per minute and it was absolutely fine. I did trigger the camera using a cron job mind you so maybe that’s where the difference lies.

      Jim

      Reply
      • Don
        December 15, 2013

        Hi Jim,
        More info. Looks like it quits at midnight, on its way to changing to the next day. I ran again from 10:05 PM on the 14th and it stopped on 23:59, same day. One picture per minute, all options default. The power is l up for I can still ssh. I can see all the jpg’s listed on the terminal. But, no more shooting. Cam starts shooting right after I first do a proper shutdown and restore power. I left the wi-fi dongle connected. Removed HDMI cable fro Pi. Only power connected to Pi. Something with time and date, like previous run.
        Don

        Reply
  55. Don
    December 15, 2013

    Wanted to add: I think it’s not the time, but the change to the next day triggers the stop. Got to look at the the .py script again. I suppose I have the latest modified 11/13/13

    Reply
    • Jim at Fotosyn
      December 15, 2013

      Great thanks Don I will take a look.

      Reply
    • Jim at Fotosyn
      December 15, 2013

      Don… I’ll run a test with the latest script tonight seeing we’re approaching the roughly same time you experienced the outtage. Will report back at some point tomorrow!

      Reply
      • Don
        December 15, 2013

        Jim,
        I’m running again. now looking at clouds from backyard. Started at 1147 local time, and it now 1547.Using ssh wireless to report back to computer inside. I’m just using terminal to see the the file names, getting in and out quickly. Sunset is 1645. I’ll continue for at least an hour after Sunset. Hopefully no break in the action! Thanks for helping.
        Don

        Reply
        • Jim at Fotosyn
          December 16, 2013

          Replicated it here Don. Definitely a problem. Just trying something else out.

          I’d stick with your sequence and then update AFTER it gets dark… the script will run okay as it’s not Midnight. the zero val for d.hour is what seems to be causing the problem.

          Reply
          • Antoine
            January 30, 2014

            Same problem here. Mounted the camera on my dashboard to shoot a timelapse from my roadtrip from Amsterdam to Munich. Unfortunately it stopped near Frankfurt, a 23:59 :-(

            Is there already a solution?

          • Jim at Fotosyn
            January 30, 2014

            Argh damn sorry Antoine. I pushed a new version of the Timelapse stuff up and updated the wget links on the tutorial. Maybe try the new version.
            I will have a look tonight as well and make sure all is working okay with the latest build (at midnight)

          • Jim at Fotosyn
            January 31, 2014

            Checked #raspberrypi #timelapse cam for midnight bug raised in support. Seemed to run okay with latest build

            http://pic.twitter.com/ZRmRBzI55l

  56. Jim at Fotosyn
    December 16, 2013

    Pushed a new version of the script to the repo…

    cd /your-chosen-folder (e.g. Home)
    wget https://bitbucket.org/fotosyn/fotosynlabs/raw/91fb0a22492cc8a2b6ec70d25580785653ecda3c/RaspiLapseCam/raspiLapseCam.py
    

    Thanks Don for bringing this to my attention ^^DON^^

    Reply
    • Don
      December 16, 2013

      Jim,
      OK on the new push. I’ll see it has “logging” in it. Will look at it closer.

      Here is what happened:
      I got 349 jpg’s starting at 1147 and stopping at 1947 (8 hours). Should have been 480. But is is strange. The 1st PIX shows taken at 1147, but next shows at 1330! From then on it doesn’t skip a beat, 1 every minute till 1947 when I pulled the plug. This was on same date, today (LA time) Dec 15. So, I didn’t test what happened going from one day to the next, like the previous day. At least I got almost all of the pictures for this 8 hour period, except the glitch at the beginning.

      Now…the new script…will do what? I think I see. … if d.hour < 99:
      Wow, how come I'm the only one mentioning the camera stopping when the date changed.
      Thanks again, I'll try the new .py
      Don

      Reply
      • Jim at Fotosyn
        December 16, 2013

        Hi Don,

        I sat with the app running from around 2345 last night and indeed, it stopped at midnight.
        The only reason I can think of is that d.hour became equal to zero. Which possibly meant that it was returning as nil, which might seem odd given it had a value (of zero).

        But anyways.

        A quick rework, checking if d.hour < 99 will always return true.

        Checking this at around 0004 this worked okay... given that d.hour would still be equal to zero.

        In response as to why; I guess many ppl don't monitor it as closely and given that it happens in the wee small hours (when timelapse is a bit of a nonstarter if your outside) they just son't see this.
        In many cases it should restart at 0200 but with this fix it will run constantly now. I checked my logs this morning and all was well.

        Cheers!

        Jim

        Reply
        • Don
          December 16, 2013

          Thanks for the update and fix. I’ll try it next shoot time.

          I don’t know Python very well, but on line 58, I see d = datetime.now()
          See the same at line 82. No harm?

          Anyway, made my first PiCam .avi movie, all 14 seconds worth! Kinda cool clouds, even saw the almost full Moon streaking by. Thought it would a bit longer and slower, maybe a minute, but, what do I know. Guess that’s what you get for 349 jpg’s, 1/min. Not sure what to change to slow it down. Using standard Mplayer on Linux Mint. Still movie is neat anyway, even with the damn power wires!
          Don

          Reply
          • Jim at Fotosyn
            December 16, 2013

            Indeed Don – the first datetime.now() creates the folder, at that point and then incrementally after that datetime.now() is used to check and create the time instance when the image was created during that while loop which is in essence the guts of the program running in a cycle.

          • Don
            December 16, 2013

            Very good Jim. I just received a note from Terry R about changing the fps to 12 for a bit longer movie.
            I’ll try it.
            Don

  57. Terry R
    December 16, 2013

    Don If I can help save Jim from answering if you are using mencoder to compile the video make changes to the part fps=24 so 349 divided by 24 gives 14.5 second change to
    12 will give 29 second. I use 50fps a lot on the cacti flower I have used 12 on snails before but 24 is correct as the PAL system used in TV in Uk is between 24 and 25fps

    Reply
    • Don
      December 16, 2013

      Thanks Terry R, I’ll give it a go.

      Don

      Reply
    • Don
      December 17, 2013

      Terry R, What is the “rule of thumb” for fps on candidates for time lapse? You mentioned a few for cacti, snails, etc. It is just cut and try as see what looks best? I used 12 for the clouds, and do get 29 seconds, a little more showtime than 14.

      And snapshots per time, another subject…so many variables!
      Don

      Reply
      • Terry R
        December 17, 2013

        Don The correct PAL format is 24 or 25 fps. I just change it to what I want the video to look like ie a slow moving object like a cacti growing was taken at every 3.5 mins then as it did not look right at 24fps made it 50 fps and got a nice quick action. Taking fast moving clouds then taken a picture every 5 or 10 second then play with the fps starting at 24. As the Raspberry PI does a good job of rendering it can be left overnight to do it’s work on a big job.

        Reply
  58. Tim Conroy
    December 19, 2013

    I have the Rpi camera working fine using : raspistill -o image_%d.jpg -tl 30000 -t 130000 as an example. But, sometimes I get an error message:

    message from syslogd@raspberrypi (here date and time)
    kernel : [8041.510247] Disabling IRQ # 32

    I have looked in the dsmeg.

    Any thoughts

    I am using: Powered hub; wired mouse into HUB
    ; wired keyboard into HUB; Raspberry Camera. SD card class 10 64GB.

    Reply
  59. Don
    December 23, 2013

    Hey Jim. Guess what I did? Added a RTC with battery backup to Pi Cam setup! Now, the jpg files will always show the correct time.
    Don

    Reply
  60. DIY: Timelapse-camera van een R-Pi en een koffieblik - Mancave
    December 23, 2013

    [...] vonden een mooie howto waarin een zekere Jim Moore van een leeg Illy-koffieblik en een Raspberry Pi met cameramodule zijn eigen timelapse-fotocamera [...]

    Reply
  61. Some fun with a webcam |
    December 29, 2013

    [...] really liked this article which showed how to use a Raspberry Pi to create a stunning timelapse video, of course filming in a [...]

    Reply
  62. Chuck
    January 3, 2014

    Got this setup and running, but it seems after the first image is taken, I loose network connectivity. Could it be my power supply not providing enough juice?

    Reply
    • Jim at Fotosyn
      January 4, 2014

      Hmmmmm that’s odd. Is this on the Timelapse setup or BerryCam? Shouldn’t relay on any network gubbins to keep going… perhaps you need to try running it either direct within the Pi or from a terminal using

      sudo python raspiLapseCam.py & < -- The ‘&’ makes sure that it runs in the background…

      Reply
  63. Joseph
    January 5, 2014

    Thanks for the awesome write-up!

    Unfortunately, I have been having some issues getting this to run on its own. I am pretty new to RPi and for some reason cannot get the cron to work. I think this is stemming from an issue I’m getting where just about every file I look to change or open including the raspiLapseCam.py file I get a permission denied, and must do so through sudo in LXTerminal. I feel like there is some type of small configuration thing I am missing because I should be able to edit and delete any files I want when logged in. Any help would be great!

    Thanks again!

    Reply
    • Jim at Fotosyn
      January 5, 2014

      Thanks Joseph!!

      I think if you try to do everything as sudo, including running the Python script this will help. Similarly deleting files or modifying them… for example where you might use…

      pico raspiLapseCam.py
      to edit try
      sudo pico raspiLapseCam.py

      The same goes for your scripts, where you cd into the relent directory… eg. /home use…

      sudo python raspiLapseCam.py &

      If you want to run as user pi (the default logged in for most) then I would make sure that your files are contained within /home/pi which I think would allow you to make changes. It’s probably because you’re a level above the base folder for where you have permissions to write/edit etc…

      Reply
  64. Gijs
    January 10, 2014

    Hi Jim,

    Quick question… I’ve used both berrycam and raspilapsecam, but somehow I can’t make them work together. Is there a way where I could use the raspilapsecam to continuously take pics and use some of the berrycam features to monitor the pics?

    I’m using the rpi as to monitor a construction site, but every once in a while i would like to be able to check it’s progress using the berrycam. (Reason it is in a remote site and i don’t want to bring my laptop everytime i go there…

    Cheers,

    Gijs

    Reply
    • Jim at Fotosyn
      January 11, 2014

      Hi Gijs

      There would be some way to hack the underlying Python script, yourself. I was thinking about doing something similar and integrating it into the UI of BerryCam. I might do that in the next couple months but I am pretty busy on Geló and getting updates for that out at the moment. But a good point and thanks for your email/question!

      Reply
  65. Gary Littlemore
    January 10, 2014

    Jim I’ve got the script running now on bootup, is it possible to have a parameter to run for X amount of seconds and then stop taking images once the time has passed?

    Great script, cheers Gary

    Reply
    • Jim at Fotosyn
      January 11, 2014

      Easy to do Gary!

      I’ll maybe have a look tomorrow and see if I can push up some new code this coming week.

      Jim

      Reply
    • Jim at Fotosyn
      January 11, 2014

      Care to share your boot up script/process?? Thanks!

      Reply
  66. Don
    January 11, 2014

    Joseph,

    Just do: crontab -e # This command opens nano

    The nano editor will open. # An easy Linux editor
    Append what you want. # Follow required format
    Save by doing Ctrl O, then Enter, then Ctrl X # Not Ctrl zero
    Then crontab -l # The letter l.

    # You must do this last step for crontab script to “take”

    Reply
    • Gary Littlemore
      January 18, 2014

      Hi Don,

      Can you explain what the steps are to get the crontab running correctly.

      No matter what I do I can’t get it working.

      Reply
      • Don
        January 19, 2014

        Gary,

        If I do this command on my Home directory:
        crontab -e

        nano is opened with this file below.
        You then enter the comands you want at the bottom.
        Don’t remove any commented out words (with # sign in front)
        It is just an example of how cron works.
        When done with your commands, hit Ctrl o, then Enter, then Ctrl x
        Whatever you put in is saved.
        Be sure to then type crontab -l to make it take effect.
        Type man cron to learn all about the cron function. It is very powerful and used a lot in commercial Linux systems.

        # Edit this file to introduce tasks to be run by cron.
        #
        # Each task to run has to be defined through a single line
        # indicating with different fields when the task will be run
        # and what command to run for the task
        #
        # To define the time you can provide concrete values for
        # minute (m), hour (h), day of month (dom), month (mon),
        # and day of week (dow) or use ‘*’ in these fields (for ‘any’).#
        # Notice that tasks will be started based on the cron’s system
        # daemon’s notion of time and timezones.
        #
        # Output of the crontab jobs (including errors) is sent through
        # email to the user the crontab file belongs to (unless redirected).
        #
        # For example, you can run a backup of all your user accounts
        # at 5 a.m every week with:
        # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
        #
        # For more information see the manual pages of crontab(5) and cron(8)
        #
        # m h dom mon dow command

        Reply
        • Gary Littlemore
          January 19, 2014

          Thanks Don,

          Are any of them commands needed to be run with a ‘sudo’ at the start?

          Reply
  67. Samir Sogay
    January 13, 2014

    Hi Jim,

    Is there a way I can make the script time independent. I do Timelapse 24×7 but using your script, it pauses at midnight.

    Reply
    • Jim at Fotosyn
      January 15, 2014

      Interesting… have you pulled my latest build which addressed an error with times. Possibly change the check from <99 to > -1? Not sure if that’ll work but if it does let me know and I’ll push a new version up to the repo.

      Reply
      • Samir Sogay
        January 16, 2014

        On my new RPi Model A, I have pulled your latest build and it does not have <99. It has "if d.hour:" and I thought this will give an infinite loop, so i put the RPi for timelapsing. After a day I checked the Pi and yet it stopped at midnight. At mignight the d.hour is 0 which stops the while loop. Now I have kept "if d.hour < 24:" and it is working fine as never the while loop becomes 0.

        Reply
  68. Gary Littlemore
    January 16, 2014

    Various people appear to be having problems with different parts of the setup. Will you be re-writing the how-to with the comprehensive solution to all the problems Jim?

    Reply
    • Jim at Fotosyn
      January 16, 2014

      Yeah I probably will at some point, maybe in a Wiki format so it’s easy to maintain and community owned.

      Reply
  69. Gary Littlemore
    January 19, 2014

    Hi,

    I still can’t get this working, so I’ve written every step I’ve taken. I started with a fresh install of Wheezy installed NOOBS.

    Below are the steps, can anyone see where I’m going wrong?

    Log into the Pi with a SSH Client

    mkdir timelapse [Makes a directory of 'timelapse' within the 'pi' folder]

    cd timelapse [Moves into the 'timelapse' folder]

    sudo wget https://bitbucket.org/fotosyn/fotosynlabs/raw/0a5f212958637ce20f502fc579fc28338b33d87e/RaspiLapseCam/raspiLapseCam.py [Downloads the raspiLapseCam.py script into the 'timelapse' folder]

    ls [Confirms the python script has downloaded]

    sudo nano raspiLapseCam.py -e [Opens the raspiLapseCam.py script so you're able to edit default settings]

    I’ve made changes to the laspiLapseCam.py script with the following:

    from:
    ‘folderToSave = “timelapse_” + str(initYear) + str(initMonth) + str(initDate) + str(initHour) + str(initMins)

    to:
    ‘folderToSave = “/home/pi/timelapse/timelapse_” + str(initYear) + str(initMonth) + str(initDate) + str(initHour) + str(initMins)

    from:
    imgWidth = 800 #Max = 2592

    to:
    imgWidth = 1920 #Max = 2592

    from:
    imgHeight = 600 #Max = 1944

    to:
    imgHeight = 1080 #Max = 1944

    from:
    time.sleep(60)

    to:
    time.sleep(12.875)

    Press Ctrl & X [Exit]

    Type Y

    Press Enter

    cd ..

    cd .. [Should now be in the 'home' directory]

    crontab -e [move the cursor to the very end]

    Type ‘@reboot sudo python /home/pi/timelapse/raspiLapseCam.py &’

    Press Ctrl & o

    Press Enter

    Press Ctrl & x

    crontab -l

    Press Enter

    sudo shutdown -h now

    Press Enter

    Reply
    • Peter
      January 19, 2014

      Hi Gery,

      Have you checked the permissions on the python script, it will need execute rights.

      To check try

      $ cd /home/pi/timelapse/
      $ sudo ./raspiLapseCam.py

      To change the permission type:

      $ sudo chmod +x /home/pi/timelapse/raspiLapseCam.py

      Rgds

      Peter.

      Reply
      • Gary Littlemore
        January 19, 2014

        Hi Peter,

        I’ve just had the same thought before I seen your message.

        I ran sudo python /home/pi/timelapse/raspiLapseCam.py and I got the following error:

        Traceback (most recent call last):
        File “//home/pi/timelapse/raspiLapseCam.py”, line 68, in
        os.mkdir(folderToSave)
        OSError: [Errno 2] No such file or directory: ‘home/pi/timelapse/timelapse_201401192114′

        Reply
        • Peter
          January 19, 2014

          Hi Gary,

          The script is trying to write to the working directory, so where you have have changed the script to:

          ‘folderToSave = “/home/pi/timelapse/timelapse_” + str(initYear) + str(initMonth) + str(initDate) + str(initHour) + str(initMins)

          You’re effectly telling it to write:

          /home/pi/timelapse/home/pi/timelapse/timelapse_

          If you remove the leading /home/pi/timelapse/ you should be ok.

          Rgds

          Reply
          • Jim at Fotosyn
            January 19, 2014

            Just joining this one now Gents… ^^ Peter is right as the pathway is relative to the script and not absolute.

          • Gary Littlemore
            January 19, 2014

            Peter you’re a star. that works.

            Thank you.

  70. Gary Littlemore
    January 19, 2014

    That should be:

    Hi Peter,

    I’ve just had the same thought before I seen your message.

    I ran sudo python /home/pi/timelapse/raspiLapseCam.py and I got the following error:

    Traceback (most recent call last):
    File “/home/pi/timelapse/raspiLapseCam.py”, line 68, in
    os.mkdir(folderToSave)
    OSError: [Errno 2] No such file or directory: ‘home/pi/timelapse/timelapse_201401192114′

    Reply
  71. Gary Littlemore
    January 19, 2014

    I’ve got it working thanks to Jim, Don & Peter.

    Below are the steps I’ve taken, using a fresh install of Wheezy via NOOBS.

    Log into the Pi with a SSH Client

    mkdir timelapse [Makes a directory of 'timelapse' within the 'pi' folder]

    cd timelapse [Moves into the 'timelapse' folder]

    sudo wget https://bitbucket.org/fotosyn/fotosynlabs/raw/0a5f212958637ce20f502fc579fc28338b33d87e/RaspiLapseCam/raspiLapseCam.py [Downloads the raspiLapseCam.py script into the 'timelapse' folder]

    ls [Confirms the python script has downloaded]

    sudo nano raspiLapseCam.py -e [Opens the raspiLapseCam.py script so you're able to edit default settings]

    I’ve made changes to the laspiLapseCam.py script with the following:

    from:
    imgWidth = 800 #Max = 2592

    to:
    imgWidth = 1920 #Max = 2592

    from:
    imgHeight = 600 #Max = 1944

    to:
    imgHeight = 1080 #Max = 1944

    from:
    time.sleep(60)

    to:
    time.sleep(12.875) [Takes a picture every 15 seconds]

    Press Ctrl & X [Exit]

    Type Y

    Press Enter

    cd ..

    cd .. [Should now be in the 'home' directory]

    crontab -e [move the cursor to the very end]

    @reboot sudo python /home/pi/timelapse/raspiLapseCam.py &

    Press Ctrl & o

    Press Enter

    Press Ctrl & x

    crontab -l

    Press Enter

    sudo shutdown -h now

    Press Enter

    I hope this helps over people who have a problem getting it running.

    Reply
    • Jim at Fotosyn
      January 19, 2014

      Thanks all and thanks to Peter for taking care of things.

      I’ll write up a more definitive wiki post over on the Repo this week to ensure a better chance of first time success for new users.

      Cheers again… Jim

      Reply
  72. Thijs
    January 20, 2014

    Hey, i am copying your timelapse and crontab bit for my high altitude air balloon tutorial. I will mention this website and keep the disclaimer :D Thanks!

    Reply
  73. Terry R
    January 20, 2014

    A question to everybody on this great blog.
    Has anybody got a direct Wifi to Laptop ot Tablet/phone working for in the field for local access “change times etc”. I have tried a AD HOC without success.
    On my secong tin of coffee it is for the NOIR Camera
    Terry R

    Reply
    • Jim at Fotosyn
      January 20, 2014

      Hi Terry

      First of all thanks for your kind comments and support!
      I am thinking about merging BerryCam and the Timelapse cam into the one app/web app to make this happen. In the case of a web app, it may take the same visual appearance as BerryCam, but run via some JavaScript frontend (thinking Knockout.js ans Durandal).

      I have looked at getting the Pi to join an ad-hoc network created by a device but so far to no avail. I am also thinking about potentially using a 3G dongle on the Pi to give it some connectivity.

      Dunno if this helps.

      Jim

      Reply
      • Thijs
        January 20, 2014

        Hey, i use my android phone, 4.0 to support wifi hotspot. Then put the ssid and passwird in the list. Check the ip adress and use a ssh terminal on your android. I use bitvisessh

        Reply
        • Jim at Fotosyn
          January 20, 2014

          Excellent… I think I’ll take BerryCam and webapp it so there’s a nice UI to make it easier to use. THat way it’ll work on pretty much anything with a web browser and internet connection.

          Reply
    • Peter
      January 20, 2014

      Hi Terry.

      I have my RPi working with a usb Wifi dongle but found the battery runtime fel quite a bit.

      Setting up a ADHOC connection shouldn’t cause any problems, I guess the thing to remember is unless you set a DHCP server on the RPi you will need to assign the RPi and your client laptop a static on the same subnet.

      You can get a RTC from ebay for next to nothing and wouldn’t impact the runtime if it was just the date’s you were concerned about.

      Reply
      • Jim at Fotosyn
        January 20, 2014

        This sounds really interesting Peter… any links you can share for this on devices that work on the Pi?

        I currently use an Edimax dongle which doesn’t soak up too much juice.

        ANybody got 3G dongle ideas??

        Reply
        • Peter
          January 20, 2014

          Hi Jim,

          I will post the config I use when I get home, I also use a Edimax I guess I’m just chasing ever saving possible :)

          Over tips for power saving, as I mentioned before (as triple clones) is to turn off display output and the other setting I found was to turn off the camera LED

          I’ll post both of these later as well :)

          Reply
    • Don
      January 20, 2014

      I added a Real Time Clock (RTC) module from Adafruit to the Time Lapse project. Now my date and time are always correct.

      Reply
  74. Peter
    January 20, 2014

    AD-HOC Wifi:

    Check the name of your wireless device

    $ iwconfig

    Mine is wlan0 (will vary depending on chipset):

    wlan0 IEEE 802.11bg ESSID:off/any

    Edit the interfaces to assign a static IP and ad-hoc SSID

    $ sudo vim /etc/network/interfaces

    auto allow-hotplug wlan0
    iface wlan0 inet static
    address 192.168.1.1
    netmask 255.255.255.0
    wireless-essid MYSSID
    wireless-mode ad-hoc

    You will need to assign your laptop etc a static ip as well, 192.168.1.2 should work ok. Of course this doesn’t add any security but I suspect digital security isn’t too much of a concern when you’re leaving it in a tin on a beach :)

    I was getting some reflection of the camera’s LED bouncing off the inside so I turned it off, to turn off the camera LED you need to edit the config.txt (RPi’s equilavent to a BIOS)

    $ sudo vim /boot/config.txt

    And add the following line at the bottom (or change if it already exists)

    disable_camera_led=1

    You can save roughly 20mA by disabling the HMDI/RCA ports, to disable the display output run

    $ tvservice -off

    I’ve added this to cron so it is turned off on boot

    $ sudo crontab -e

    @reboot tvservice -off
    @reboot python /home/pi/timelapse.py &

    Hope this helps

    Rgds

    Reply
  75. Terry R
    January 20, 2014

    Peter thanks for the reply it sound interesting. I allways run my Pi;s with static IP
    so would not need the DNS server program. I use even no for Lan Odd for WFi ie 192.168.0.2 Lan 192.168.0.3 WiFi with router set to no DNS below 20 gives a range of 9 Pi’s in fixed mode. “no do not have 9″
    I do have a few RTC but not in the coffee tins. I get the date by making sure the coffee tin is connected on the web before leaving the house. The LED is turned OFF all the time.
    Terry R

    Reply
  76. Michel S
    January 22, 2014

    Congratulations to all of you well advanced in the matter.
    I just bought a Raspberry B with he Camera with the project of a timelapse video placed on a seashore site. But I am not out of the woods yet
    I followed exactly the guide and detailed explanations of Gary (January 20) but I don’t see any results.
    When doing :

    cd timelapse
    ls -l
    I have only :

    “total 8
    -rw-r–r– 1 root root 4593 Jan 22 14:59 raspiLapseCam.py”

    Something is wrong or missing in my config…

    Or may be I don’t know to look at the right place ???

    Reply
  77. Michel S
    January 22, 2014

    Thank you Gary
    I confirm
    I did exactly what you said

    Reply
  78. Gary Littlemore
    January 22, 2014

    Hi Michel

    If you’ve done ‘ls’ when in the ‘timelapse’ folder and you see only ‘raspiLapseCam.py’. That is correct.

    You’ve created a new folder within ‘pi’ then doing ‘sudo wget https://bitbucket.org/fotosyn/fotosynlabs/raw/0a5f212958637ce20f502fc579fc28338b33d87e/RaspiLapseCam/raspiLapseCam.py‘ you’ve downloaded the raspiLapseCam.py script.

    Reply
  79. Michel S
    January 22, 2014

    Yes Gary
    I checked the script. It seems OK
    But where should I see the photos and how can I see them ?

    Reply
  80. Michel S
    January 22, 2014

    Wait a moment
    I am a bit stupid
    I did not send the initial command !
    That is I understand : sudo python /home/pi/timelapse/raspiLapseCam.py &
    And now I see some files
    But how the photos can be extracted and displayed ?

    Reply
    • Gary Littlemore
      January 23, 2014

      Hi Michel

      Scroll back up this page and just before the blog comments start Jim has posted the commands needed to turn the .jpg files in to a TimeLapse .avi

      Reply
  81. Michel S
    January 23, 2014

    Thanks Gary
    I found the Jim’s post
    And tried to install mencoder but I received an error message :

    mirrordirector.raspbian.org….
    Unable to fetch some archives…

    However I had run from the start the apt-get update and upgrade..???

    Reply
  82. Michel S
    January 23, 2014

    May be my mistake is that I did not download NOOBS but I directly downloaded RASPBIAN.
    So that I am not able to have the desktop interface with icons and so on ???
    What can I do now ?

    Reply
    • Terry R
      January 23, 2014

      Michel S
      Mencoder is part of mplayer so
      sudo apt-get install mplayer
      and you will have mencoder
      stay away from the desktop all the timelapse I have seen is
      used from the command lone

      Terry R

      Reply
  83. Michel S
    January 23, 2014

    Many thanks Terry
    It works. I have been able to download mplayer.
    But I have another problem when, according to Jim’s post I am doing in the right directory:
    “ls *.jpg > list.txt”
    I receive an error message: permission denied.
    ?

    Reply
    • Jim at Fotosyn
      January 23, 2014

      You probably need to run the command as sudo

      sudo 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

      Reply
  84. Michel S
    January 23, 2014

    Thank you Jim
    I ran the sudo command and receive an error message:
    sudo: mencoder: command not found
    I tried from the timelapse directory
    I had downloaded mplayer without any problem.

    Reply
  85. Michel S
    January 25, 2014

    Hi Jim
    I finally succeeded to download mencoder and got my first Timelapse.avi folder.
    GREAT
    But I am still unable to extract the file or to view it. I am working through Putty SSH with my laptop and Ethernet cable.
    Where is the trick ?

    Reply
  86. Alexandre Perier-Muzet
    January 26, 2014

    Hi, all are you? Thank you Jim for this awsome python script…

    I have two questions :

    - Is it possible to upload photos to a folder on google drive or something else instead of saving it on the sd? If I’m not at home, that’s not the case of my pi model B it have internet on ethernet at home and can take one shot every single minute thank to your script… And if I want I can check the pictures in google drive on my iphone every where with LTE… Could it be possible?

    - I have build a waterproof case with a solar panel, a battery and even an electrical outlet this way I can run the Pi model A for 10 straight hours on battery or more…. I have attached to my raspberry model A a dongle wifi (Edimax EW-7811UN) and turned my pi into a router using the adafruit tuto : http://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software. I solved an error using /etc/default/ifplugd, and it work like a charm. Finally I installed raspiLapseCam.py.

    My problem is : when I use crontab to start raspiLapsecam.py on boot, hostapd and isc-dhcp-server are launch but I can’t see my access point on other laptops.

    If I don’t use crontab and launch raspiLapseCam.py manually with sudo python /home/raspiLapseCam.py & I can see my access point but the script stop after 1 shot

    I also try to launch the script via /etc/rc.local same troubles pictures but no access point or the inverse I don’t remember…

    I also try to use /etc/init.d/ (script start and stop manually but using it and allow it at boot via update-rc.d mynameoffile enable make access point disappear)

    Finally I try to launch the script via sudo nano /etc/inittab (allow auto login) & nano ~/.bashrc to launch the script but no access point and I got pictures

    Before I building the box I try this exact same method on wheezy-2013-12 (novembre / december 2013 i can’t remember) and it work nicely only with crontab… So I would like to know where the problems come from because now I’m on wheezy-2014-01-13 with the latest script and it doesn’t work anymore for unknown reasons (I have no errors in the syslog)

    If anyone has a clue, an idea???

    Reply
    • Jim at Fotosyn
      January 27, 2014

      Thanks Alexandre, and thank you for your comments and comprehensive write up!

      I’d love to see the solar panel option; something self-sustaining would open up a whole host of longer term-fixed cameras; say for wildlife.
      The Google Drive or Dropbox is a brilliant idea too! A frequenly asked question is how to get images off the Pi. In saying that, I am reworking BerryCam to run as a web app from the Pi itself, so the possibility of saving files will be easy from a local computer or device.

      But for bulk images yeah, some form of Cloud storage would be a good shout.

      Interesting points on the ad-hoc network; I am early stages with getting the Pi to act as an access point but will be reporting back and updating in the next few weeks (hopefully).

      Reply
  87. Alexandre Perier-Muzet
    January 26, 2014

    Re, I also try with dnsmasq, dhcp server is running so as hostapd and when I start the script at boot via cron or manually via sudo python wifi hospot dissapear…

    Wierdest bug I ever saw…

    Reply
  88. Alexandre Perier-Muzet
    January 26, 2014

    HEYYYY I found something….

    dwc_otg_hcd_urb_enqueue:515 in syslog = not enough power… (ethernet + hdmi + wifi dongle + bluetooth dongle + raspberry cam eat 530 – 540 mA on a Model B). My power supply was 520mA… Change the power supply to 1A all run well with isc-dhcp-server or dnsmasq. Will make an article DIY style, I will post the link here…

    10h hours search for 30mA ARGGGGGGGGG

    ;-p

    I’m stil looking for help on how can I upload pictures to google drive…

    Reply
  89. Gary Littlemore
    January 26, 2014

    Hi all,

    Once I’ve got the script running happily snapping photos with only a power lead connected to my Pi, other than pulling the plug how else can I get it to shut down safely?

    Can parameters be added to the script to run for X amount of seconds and then to safely shutdown?

    Reply
    • Jim at Fotosyn
      January 27, 2014

      Hi Gary

      I’ve tried a number of options none of which have really gotten round this issue. Currently looking at a means to wire up a button that issues the shutdown command to ensure a safe clean shutdown.

      I am also working on a dual format web app running in backbone JS – so perhaps a virtual switch on the UI would do this.

      Making this installable on the Pi itself (in the form of BerryCam – but with timelapse bolted in) might make this more of an option.

      There are a number of things I am looking at…

      - Ad-hoc wifi on the Pi to make it connected without any network present
      - Embedded web app
      - Dual BerryCam / Timelapse cam functionality using the BerryCam design

      This hopefully will make things a bit easier; and the code more accessible to more people. It’ll all be open sourced.

      Cheers

      Jim

      Reply
      • Alexandre Perier-Muzet
        January 27, 2014

        For the Ad-hoc wifi on Pi and the better way to start, stop the script I will make an article…

        I think the problem come from the crontab, i will probably use /etc/init.d/ for my raspicambox ^^

        Reply
        • Gary Littlemore
          January 29, 2014

          Alexandre, do you have a solution of a better way to start and stop the script?

          Reply
        • Terry R
          January 30, 2014

          Jim I have had lots of problem getting crontab to work properly as the second line was never run. A friend who programs in Linux told me to use a different way and that works fine. I can start and stop my Coffee Tin camera each day at sunrise and sunset it has neen outdooy since 20 december. The way is to make a file with nano first move to the cron.d directory
          cd /etc/cron.d
          then run nano timelapse
          then in the file put the cron jobs you want I normally have the start up and kill command. Today trying the reboot cmd so will know in 24 hours if it works. Must say very pleased with the way it works as I can change start stop times every few days as the day get longer
          I will post the lines tomorrow if they all work.

          Reply
          • Jim at Fotosyn
            January 31, 2014

            This sounds like an excellent Solution Terry! Would be great to see your scripts and I’ll incorporate into the tutorial text.

          • Terry R
            January 31, 2014

            Jim the reboot worked. Once you have a file in the cron.d mine is called timelapse and you can leave it as a text file.
            the commands are in 3 line first time to start the timelapse second to kill the timelapse third to reboot the PI this gives the chance to change the times as the days get longer but 2 line will do the job.
            # next line to stary program running at it’s location
            20 7 * * * root /scripts/jpgtimelapse
            # next line to kill off the program and go to standby
            #13 17 * * * root /usr/bin/killall jpgtimelapse
            # this line to use the reboot cmd used if you changes the time
            29 17 * * * root /sbin/reboot
            This works for me I do not know if it is the correct way but it works.
            Terry

          • Jim at Fotosyn
            January 31, 2014

            Terry, this is fantastic! Thanks so much for sharing! If it’s okay I’ll maybe update my post to allow others to benefit from this great nugget of advice.
            Thanks!!

          • Terry R
            February 1, 2014

            Jim that is fine. Just finished No 2 Coffee Tin last night.
            I have found the plastic storage boxes from CF card or Micro SD card with adaptor to be a good size for the camera mount. I have managed to find some 6mm plastic cut out with a round cutter tool center hole can then be fitted with a 1/4 to 3/8 camera adapter and all stuck to bottom of the tin gives a camera tripod mount.

      • Gary Littlemore
        January 27, 2014

        Cheers Jim,

        I’ve just found also if I pull the plug, meaning not to shut down correctly the next time it boots up it doesn’t start the timelapse running. I have to then perform a shutdown and then when the next start up runs the timelapse kicks in automatically.

        Reply
  90. Jim at Fotosyn
    January 28, 2014

    200 Comments on this post!

    Wow who would have thought it.

    Delighted with the interest that BerryCam and the Timelapse Camera have had and I thank everybody so far for their feedback, suggestions and technical help.

    To celebrate – here are some promo codes for two of my iPhone apps that can be redeemed on the App Store

    - Geló
    F3AEKE749NP4
    9PLYN399TETX
    TJYY6X73RXEX
    YLXNAAT4F3KY
    KHERNKYFKWKP
    3HN7EANW4WKW
    KEAAN7E9TTE9
    46XHEP9M7JF3
    WF6F3WXYRKFA
    ANM9T3LTE9AP

    - Bleach Bypass
    P9XFMLL374HR
    LFPXX9JPPK9K
    R3LHHWJAN6ML
    NTARRWKR9T3E
    R3XJMM93LYKF
    THP39J3XL67T
    KH3EJFXLH3W4
    XJ6LKEE9KTR3
    3ER9HJKEM4WF
    APR66XR7WTKR

    To redeem, simply open the App Store on your iPhone, iPad or iPod.

    Go to the ‘Featured’ tab and scroll down.

    Select ‘Redeem’ and insert a codes from above.

    Once redeemed, that code will be dead and can’t be redeemed again so please do ping in with any codes you’ve used and I’ll score them out. If you use the code on say an iPhone, you can get the app onto other devices by simply downloading from iCloud. You won’t need to redeem another code – so what I am saying is try and keep codes open for others.

    Reply
  91. David
    January 29, 2014

    Shouldn’t it be “sudo crontab -e”? I don’t think you pipe it through nano.

    Reply
    • Jim at Fotosyn
      January 30, 2014

      Yeah just sudo crontab -e

      Reply
      • David
        January 30, 2014

        In my case I don’t need to shutdown first. If I edit crontab via root it’ll start the process right away every time I boot the Pi.

        Reply
  92. Some fun with a webcam |
    January 30, 2014

    […] really liked this article which showed how to use a Raspberry Pi to create a stunning timelapse video, of course filming in a […]

    Reply
  93. Jim at Fotosyn
    January 31, 2014

    Checked #raspberrypi #timelapse cam for midnight bug raised in support. Seemed to run okay with latest build

    http://pic.twitter.com/ZRmRBzI55l

    Reply
  94. Jim at Fotosyn
    January 31, 2014

    Just a quick note to say thanks to everybody for commenting and supporting the Timelapse camera.

    I currently have it posted on Instructables within the Raspberry Pi section. I sure would appreciate any votes if you’ve built and used the camera – or had any interest in the camera.

    Thanks again everybody!

    http://www.instructables.com/id/Simple-timelapse-camera-using-Raspberry-Pi-and-a-c/

    Reply
  95. Gary Littlemore
    February 1, 2014

    I’ve uploaded my first Fotosyn timelapse script video to Youtube.

    http://www.youtube.com/watch?v=o79Fd7YCNts

    Credit also given to Fotosyn.

    Reply
    • Jim at Fotosyn
      February 2, 2014

      Brilliant Gary!! Those clouds are awesome… makes me think that a long-term continuous running RaspberryPi capturing the seasons would be a good option. Just seeing the trees bare branched made me think of that.

      Reply
      • Gary Littlemore
        February 2, 2014

        I’m getting an average of 1.3mb per picture so a big storage would be needed to do a long-term capture. But it’s a great idea.

        Reply
        • Jim at Fotosyn
          February 2, 2014

          Yeah I had a suggestion to look into doing a cloud based storage option. Might be a good option though it might not be great for long term timelapses if there are any outtages.

          Reply
  96. PiperGeorge
    February 3, 2014

    Been wanting to do a timelapse for a while now and after reading your info here I decided it was time to do it. My Raspberry and camera arrived on Friday and spent most of today getting it to work. This is my first real foray into any type of programming so it was a bit of a learning experience. (I do have some programming from back in school about 100 years ago, but I find a lot of those early languages are very similar, so I wasn’t completely in the dark)

    Took me most of today to get everything going and storing the pictures to a USB stick, but it seems to be working perfectly now. Well, almost, it’s not auto starting yet. Something is not quite right there. I’ll work on that some more, I’m sure it’s something simple.

    I want to do some dusk to dawn timelapses so one thing I would like to see is the ability to only take pictures between certain times. The days are starting to get brighter and pretty soon it will be daylight before I get up! So I won’t be able to plug it in in the morning. I guess I can just leave it run and then delete the night pictures

    Thanks for all your work and putting this script up for us, and after reading the 200+ comments, all your work answering questions!!!

    Reply
    • Terry R
      February 3, 2014

      Hi If you look at my post from 31 Jan it shows my cron script that start up just before sunrise and stops at sunset

      Reply
      • PiperGeorge
        February 3, 2014

        Thanks Terry, I will work on it. I’ve taped the camera to the living room window and I’m going to let the program run today to see how everything works. Will work on the auto start/stop tonight

        Reply
  97. Michel S
    February 3, 2014

    RaspberryPi in AFRICA

    http://Vimeo/85646703

    Thanks to you Jim and to all the other contributions, your comments and explanation. That is one of my first timelapse video. It is to control a working site to pull out sand from a sea lagoon in Africa, Atlantic sea shore. Snapshots every 10 minutes and video 1 fps. A lot of adjustments need to be done yet.

    Everything is working smoothly and I got the photos , but when shooting, my SSH screen shows for each photo an error message:
    mmal: ….failed to enablFailed to run camera app.e component:ENOSPC

    mmal: Failed to run camera app. Please check firmware update.

    What do I have to do?

    Reply
  98. Michel S
    February 3, 2014

    Sorry it should be

    RaspberryPi in AFRICA

    http://vimeo.com/85646703

    Reply
  99. Alexandre Perier-Muzet
    February 3, 2014

    If you want to add ad-hoc wifi to your timelapse I just made an article :

    http://anderson69s.com/2014/02/03/raspberry-pi-routeur-edimax-ew-7811un-nano/

    (yeah it’s in french but you just have to follow the pictures and the line of code…)

    And I’m just starting to write the article on my TimeLapse box, don’t worry I will share the link too ;-)

    Reply
  100. Michel S
    February 8, 2014

    Hi Terry
    Nearly everything is working well for me, but in spite of your interesting guides about crontab I am unable to get it working. My purpose is the same as yours getting the camera working from dawn to sunset. I am probably missing something from your explanations ???

    Reply
    • Terry R
      February 8, 2014

      Hi Michel I do not use crontad in fact Iyou have to run the command to clear all crontab jobs sorry I do not know what that is. I put a text file into the directory at /etc/cron.d
      The file I call timelapse and the 3 line I put in are

      15 07 * * * root /scripts/yourprogramnae
      45 17 * * * root /usr/bin/killall yourprogramname
      #29 17 * * * root /sbin/reboot
      Your program name is the program you want to start in the morning
      mine is called “jpgtimelapse” the name it tell’s me the format of picture I am taking.
      So my 3 lines are

      15 07 * * * root /scripts/jpgtimelapse
      45 17 * * * root /usr/bin/killall jpgtimelapse
      #29 17 * * * root /sbin/reboot

      Just setting my second coffeetin up tomorrow on some Orchids that are flowering.

      You must delete any crontab you may have made as they will stop the file in \etc\cron.d working
      Just Googled an it is crontab -r to remove all the jobs

      Reply
  101. Raspberry Pi : Time Lapse | Anderson69s
    February 8, 2014

    […] je n’ai pas écris le code en python qui prend automatiquement les photos, ce sont nos amis de fotosyn.com qui l’ont écrit… Pour l’installer il faut faire […]

    Reply
  102. Michel S
    February 8, 2014

    Hi Terry
    Thank you very much. It’s clear.
    But I don’t understand the last of your three lines. The hash symbol is supposed to be for a comment and 29 17 is earlier than 45 17

    Reply
    • Terry R
      February 9, 2014

      You can use either line 2 just stop the program or line 3 depend if you want to extend the shooting tome as the days draw out by changing the time remove the # and put one befor line #’
      Or you can run just the 2 lines 1 and 3 change the times every few days

      Reply
  103. KeithC
    February 10, 2014

    Jim,
    Thanks for the great project. An absolute beginner with the Pi , I’ve followed the instructions and have just finished my first time lapse of work being carried out in Belfast shipyard. VIMEO . Pity about the rain but it is Belfast!!
    Thanks again Jim and all the other posters.

    Reply
    • Jim at Fotosyn
      February 11, 2014

      Keith – this is brilliant to see and a great subject matter too. I think timelapse was made for cranes… or is it the other way round. Eitherway this is a great video and thanks so much for sharing! I’ll repost your link on Twitter…

      Reply
  104. Alan
    February 16, 2014

    Hi,
    Really keen on doing a time lapse video for my sister who is building a house. One photo per day over 6 months while the house is being erected should do nicely. This would be my first pi project – so is this possible and if so is it too difficult a project to start with? Would it need battery pack replacements too regularly to make it worthwhile?

    Thanks

    Reply
    • Jim at Fotosyn
      February 17, 2014

      Sounds fantastic! I’d love to try something long term like this. In terms of power to the Pi – I reckon it would need to be continuous (mains) power of some sort; although you could probably use power packs to give continued power for a couple of days – but it would start to get tedious flipping out packs every other day or so.

      Reply
  105. Jonathan
    February 22, 2014

    Dear Jim,

    This is the first Pi project I am building with my daughters, and it’s great to follow such clear instructions & to be able to adapt the project for our own version.

    My problem is finding the images once the Pi has taken them! I started the process manually, and watched the Pi taking images at 1m intervals – I could see the Pi saving them into a folder called /timelapse/timelapse20140221 or similar. However, when I go to extract the images, I cannot find anything in the /timelapse directory using ‘ls’ command – I don’t know how to go any further to locate the .jpgs. Any clues as to what I am doing wrong?

    Reply
    • Jim at Fotosyn
      February 22, 2014

      Hi Jonathan this is so good to hear!

      This is one of the main reasons I started this project – to make it relatively easy with a focus of interest to engage kids.

      I’ve heard of your problem before and it might be permissions. In this case if you go into terminal and start a session navigate to /home by typing

      cd /home
      ls

      and if your timelapse folder is there type

      chmod 777 timelapse

      If it’s in another folder (say for example pi) type

      cd pi
      ls

      Check it’s there and then type

      chmod 777 timelapse

      If you can’t find the timelapse folder try

      mkdir timelapse
      chmod 777 timelapse

      making sure that the same pathway is set up in the Python script

      Give it a brief test run taking note of where it’s saving. Check by cd’ing and ls’ing the output folder.

      Hop this helps!

      Jim

      Reply
      • Jonathan
        February 22, 2014

        Hi,

        Thanks for the quick response!

        I tried to chmod the timelapse folder – with the following results (‘operation not permitted’), so tried using the sudo command, with no obvious results. The Pi is definitely taking the images, as I am watching the camera light come on every 60s.

        pi@raspberrypi /home $ ls
        berrycam berryCam.py pi raspiLapseCam.py timelapse
        pi@raspberrypi /home $ chmod 777 timelapse
        chmod: changing permissions of `timelapse’: Operation not permitted
        pi@raspberrypi /home $ sudo chmod 777 timelpase
        chmod: cannot access `timelpase’: No such file or directory
        pi@raspberrypi /home $ sudo chmod 777 timelapse
        pi@raspberrypi /home $ cd /timelapse
        pi@raspberrypi /timelapse $ ls
        pi@raspberrypi /timelapse $ ls
        pi@raspberrypi /timelapse $

        Thank you!

        Jonathan

        Reply
        • Jim at Fotosyn
          February 22, 2014

          Looks like a typo in your sudo cmd — timelpase should be timelapse

          Reply
          • Jonathan
            February 22, 2014

            Hi,

            Yep – spotted that! So, a couple of lines later, I repeated the command with the correct ‘timelapse’ name, but still no good:

            chmod: cannot access `timelpase’: No such file or directory
            pi@raspberrypi /home $ sudo chmod 777 timelapse
            pi@raspberrypi /home $ cd /timelapse
            pi@raspberrypi /timelapse $ ls
            pi@raspberrypi /timelapse $ ls
            pi@raspberrypi /timelapse $

            I am sure this is just lack of familiarity with Unix commands, but any clues gratefully accepted.

          • Jim at Fotosyn
            February 22, 2014

            I’d just double check again as I notice a timelpase above for the chmod error

          • Jim at Fotosyn
            February 22, 2014

            You’d need to re fire the script and see if creates new images. If permissions were an issue, there’s a possibility that no images were saved.

          • Jonathan
            February 22, 2014

            Thank you – I’m off to get a better understanding file structures and permissions. We’ll get this sorted, so thank you for all the help so far!

          • Jim at Fotosyn
            February 22, 2014

            All part of the learning!! Hope you get it sorted and working for you soon and looking fwd to the results

  106. Gary Littlemore
    March 1, 2014

    A nice day today so I thought I’d do another timelapse video, some great cloud moment on this one. Credit given to Fotosyn.

    Reply
    • Jim at Fotosyn
      March 3, 2014

      Gary all credit to you mate!! This is bloody fantastic! Look at them billowing clouds.

      Reply
  107. Terry R
    March 2, 2014

    Hi Jim As a timelapse from the coffee tin failed last week due to the gales my subject got blown down I lost 3 weeks of pictures. So started again indoor with a Orchid if you want a look link is below.
    http://vimeo.com/87929645
    I have today changed the lens to give a closeup and got down to 3″ focal length.
    As another Orchid is blooming I have set up a close up to the center of the flower will see what happens. The out door project was a forsythia tree I had hoped to get it bursting into yellow flower then turning to green leaves.

    Reply
    • Jim at Fotosyn
      March 3, 2014

      You flora timelapse pieces sound fantastic! Shame the rig was lost but I guess spring is still to come and the worst of the winds are behind us!

      Great work on the Orchids… The light flickering really helps give the impression if time passing!

      Reply
  108. PiperGeorge
    March 2, 2014

    Have had this set-up running for about a month now. Wasn’t able to get it to start/stop by itself yet, but that’s not really a concern right now anyway. It’s plugged into the mains so as long as there’s no power failure I’m fine. My goal right now is to do a long term time lapse over a few months of the snow melting from my front yard and the trees starting to get leaves.

    I somehow ended up with an older script so the camera stops working from midnight to 3am. Also not a big deal right now, it makes it easier grouping the pictures into day folders and each day the pictures are all taken at the same time. Might help for editing later on. I have a 32G usb stick and wireless USB plugged into the Raspi so I have a few days worth of storage, and I usually download the pictures each night using an FTP program.

    So far so good!

    Reply
    • Jim at Fotosyn
      March 3, 2014

      This sounds brilliant!! Yep there’s a duff version that was patched a few months back. You could probably wget the new version but as you mention those are hours of darkness anyways. Not much happening.

      So where are you? East Coast USA or Canada? I’ve heard there’s some really crazy weather out there.

      Really looking fwd to your results with this.

      Reply
      • PiperGeorge
        March 3, 2014

        Right smack dab in the centre of Canada … Winnipeg, Manitoba. Long recording breaking cold winter with more than enough snow!!! -36C this morning with windchill of about -45 or so!!!

        Reply
  109. Terry R
    March 7, 2014

    Hi Jim I have just finished a timelapse as stated I have adjusted the camera lens down to about 100mm focal point. I was amazed at the quality of the still pictures taken by the Pi. Taken over 3 days
    http://vimeo.com/88431356
    enjoy

    Reply
    • Jim at Fotosyn
      March 7, 2014

      That is unreal!! Really sharp and lovely depth of field? What kind of adapter were you using for this? Awesome!!

      Reply
      • Terry R
        March 7, 2014

        Jim short answer nothing. It is the coffee tin camera all I did was scrape the glue from top of lens and then screw the lens anti-cloclwise until the subject came into focus when placed 100mm away. Placed on a tripod in my conservatory that faces north.

        Reply
  110. » How to make a time lapse using a Raspberry Pi and Racket Franco Raimondi
    March 9, 2014

    […] calls raspistill for a certain number of times. This is basically the same thing explained here: http://www.fotosyn.com/simple-timelapse-camera-using-raspberry-pi-and-a-coffee-tin/ but using Racket instead of Python and with a few additional […]

    Reply
  111. Jim at Fotosyn
    March 16, 2014

    A quick note for all your Timelapser folks out there!
    http://www.fotosyn.com/coming-soon-berrycam-express/

    Reply
  112. Simon Mc
    March 17, 2014

    Everytime i try to shutdown i get
    sulogin:root account is locked, starting shell
    root@raspberrypi:~#

    Annd the it just reboots to the normal login

    I can run the time lapse directly but stuck at the staring from pwer on

    Reply
  113. Antoine
    March 28, 2014

    How many pictures can you take with full batteries and for how much time pls ?

    Reply
    • Jim at Fotosyn
      March 28, 2014

      I’ll give you an up to date time over the weekend. Running a session outdoors with brand new batteries!

      Reply
  114. sanjay
    March 31, 2014

    hii i installed cron using… sudo crontab -e.. everything works perfectly… however i cannot see my photos taken through camera… where is it storing? i checked all my file manager… please reply at the earliest.. thanks in advance

    Reply
  115. Declan's Blog » Timelapser Project
    April 20, 2014

    […] Simple timelapse camera using Raspberry Pi and a coffee tin […]

    Reply

Leave a Reply