Posts: 3
Joined: Sun Jan 25, 2015 3:43 pm

Need to pick the collective brains here

Sun Jan 25, 2015 4:20 pm

Sorry for the long post.

I want to do a project and am a little stuck.
It seems like it would be possible, but I`m trying to wrap my head around it, and hoping I can get some help.

I have a Pi B+ and the camera board.

I want to do a very long timelapse to give to my mom on her birthday in May, and then I`m going to run it for a whole year after that.

We planted a little evergreen tree at our family cottage in memory of my brother that passed away last year.

I want to set up the Pi to take a picture of the tree, say every minute for an extended period (lets say 3 weeks) because we don`t go to the cottage every weekend. :(

I only need the picture during daylight hours, so say 7AM to 7PM.

I figure if I use a 64GB USB stick, I think I`d have plenty of room for pictures if we don`t get there for a while.

The Pi will be indoors with the camera attached to the window looking right out at the tree, so it`ll be plugged in, but the power at the cottage goes out from time to time, so I need it to restart by itself whenever power is restored if that happens, without overwriting any of the pictures it has already taken.

I`ll be using my computer to compile the images into the timelapse, so I don`t need the Pi to do that.

BTW I know the tree won`t grow that fast, but I may get a bird or small animal in the picture so I think it would be cute, that`s why the pictures are so frequent.

I can figure out how to set a timelapse using Raspbian, but not just during the day, and I don`t need a ton of pictures of darkness. Also if the power goes off, I`m not sure how to let the Pi know what the time is (i know there`s no built in RTC) and there`s no internet access at the cottage, so if I have to take the night pictures then just delete them later that`s okay too.

I haven`t figured out how to get the Pi to write the pictures to the USB stick directly yet, but I`m sure I can figure that one out with some more searching and reading.

Any help on how to make this happen would be greatly appreciated.

Also, please don`t get too technical, I`m only 13. :)

Posts: 149
Joined: Sat Dec 27, 2014 10:54 am

Re: Need to pick the collective brains here

Sun Jan 25, 2015 4:46 pm

Having the pi networked allows it to get and keep time.

read up on crontab for timed tasks...

Posts: 3553
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Need to pick the collective brains here

Sun Jan 25, 2015 5:57 pm

Adding a realtime clock isn't difficult and will help when you come to sorting lost of images into date order.

Take a look at Motion. It can save timelapse and will detect motion in the image, so if you want to catch birds or animals that might work for you. It should name files uniquely for you.

There is a project using Build Root and Motion that might be interesting, ... lit=motion that starts up automatically at boot (and starts fast)

but you could use NOOBS / Raspbian. and add startup commands.

User avatar
Posts: 147
Joined: Fri Jan 13, 2012 4:27 pm
Location: Haute-Vienne, France

Re: Need to pick the collective brains here

Mon Jan 26, 2015 10:22 am

I have a similar application running using the excellent picamera library in Python.
The program is started by cron each night and loops until it is light enough.
It then uses scp to copy each image to another server where the images are assembled into a video each night.
Once the light level drops below a defined point. The Python program terminates.
It is not very elegent and could be improved - but it works.

Code: Select all

import time
import os
import picamera
import Image
import ImageStat
import io

with picamera.PiCamera() as camera:
        camera.resolution = (1280,720)
        lux = 0
        while lux < 20:
                stream = io.BytesIO()
                camera.capture(stream, format='jpeg')
                image =
                print "Too Dark..."
        i = 1
        for filename in camera.capture_continuous('img{counter:04d}.jpg'):
                print('Captured %s' % filename)
                os.system('/usr/bin/scp -q %s [email protected]:/timelapse/' % filename)
                if i == 3000:
                i = i + 1
                if max(stat.mean) < 20:

Posts: 3
Joined: Sun Jan 25, 2015 3:43 pm

Re: Need to pick the collective brains here

Tue Jan 27, 2015 9:46 pm

I got it mostly working, thanks for all of your replies.

I used this: ... offee-tin/
and I am using an /etc/init.d script to get it going.

I have one problem

If I shut down or reboot the Pi everything works perfectly, however, if power is removed while the Pi is running then restored (to simulate a power failure) the Pi restarts but the timelapse camera doesn't.

Is there any way to fix this?

User avatar
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: Need to pick the collective brains here

Thu Jan 29, 2015 1:34 pm

I've used /etc/rc.local as a means of auto running apps on startup - not as clean as the init.d approach, but simpler and may be worth trying to see if it works after power cycling. See ... for more detail.

However there are risks - see the section on when NOT to use rc.local on this page: ... -rc-local/

Have you looked in the dmesg log file (or others in /var/log) to see if there are any messages relating to the failure of your script to start correctly?

Return to “Camera board”