Abusing the Raspberry Pi Reset Header. Time-lapse Camera project

Recently I had the need to produce time-lapse videos for very long periods of time. That is not a big deal when you can use a nearby power source, but I would like to have an autonomous time-lapse camera that can run several hours. So I decided to build it with my Raspberry Pi.

I played with the reset header included in the second revision of the Raspberry PI Model B some time ago. During that experiment I noticed that, whenever the board is powered off, it goes into a "stand by" mode. In other words it does not really switch off. The second finding for those test was that a Reset button will restart the board from that mode.

So I though it could use that "feature" to build a time-lapse camera, specially for cases where the lapse between pictures will be long and the images need to be acquired for long periods of time. The idea is to boot the board, take the picture and then power it off. After that a microcontroller will reset the board, and the process will start over again.

Actually it would be better to fully cut the power but I didn't had any transistor hanging around rated for the current required, so I got stuck with the reset button idea which is not that bad, as we will see in a moment.

In order to make this work, the first problem to solve is booting the board quickly, otherwise the method won't make any sense. For that I used the buildroot package (http://buildroot.uclibc.org/) to produce a minimal filesystem (see http://papermint-designs.com/community/node/289 for more details). Using the buildroot filesystem and the stock Raspbian kernel the system boots up in roughly 5 seconds. Then we need to load the uvcvideo module, launch the image capture application, sync the filesystem and poweroff. The whole cycle takes around 18 secs. That is the minimal time-lapse we can use with this system.

Including the uvcvideo driver in the kernel should save some time but I haven't try that yet. The uvcvideo was taken from the standard Raspbian distribution, together with the modules.dep files under /lib/modules. That completes the minimal filesystem.

This is the buildroot configuration file in case you want to build your own filesystem and you want a starting point.

[ Download .config ]

Second step is to install a video image capture application. The fswebcam program is a common choice among Raspberry users, so it was my first try. It uses standard GNU autotools so cross-compilation is straightforward. However, fswebcam depends on libgd for image annotation, and I was too lazy to start cross-compiling dependencies so I took the basic video streamer that comes with picoFlamingo and quickly modify it to just capture an image and dump it to a file.

Here you can find the my pf_cap application.

[ Download pf_cap ]

If you are interested in the source code for this application, check the apps directory on the picoFlamingo package (http://www.papermint-designs.com/picoflamingo/download.html) and try to change it yourself. Be free to send me a note if you need some little help ;).

You need to compile this with whatever toolchain and configuration you used to create your buildroot filesystem.

Note that I was too lazy to even check if libgd is included in the buildroot package list... and know what?. It is :). So you can easily try fswebcam if you prefer.

Now we just need to add a script in /etc/init.d to load the uvcvideo driver, then launch our application and finally shutdown the machine. I used an intermediate script for the latest two steps but in principle you can perform these actions wherever you prefer.

This is the /init.d/S60shot script

# Start the network....

case "$1" in
        echo "Loading video driver and starting application"
        modprobe uvcvideo
        echo -n "Stopping Shot (doing Nothing)..."
        "$0" stop
        "$0" start
        echo "Usage: $0 {start|stop|restart}"
        exit 1

exit $?

This is capture script:


cd /root/tl

echo "Capturing picture...."
/root/pf_cap -f 1 
echo "Done"

This completes the software. Every time the board boots up, captures an image, dumps it in the SD-card and shuts down.

The hardware for this project is very simple. I'm using an ATiny85 to reset the Raspberry Pi, every X seconds. Right now the period is hardcoded in the ATiny85 firmware so you need to reflash the microcontroller to change it. This is something to improve :).

The Raspberry is powered through the GPIO pins using a small board that contains the ATiny85, some components and two leds, one to indicate that the system is powered up and another that lights whenever the board is about to
be reset. I use a 2N2222 transistor to reset the board. This is how the board looks like (top and bottom)

Raspberry Pi Time-lapse camera. Expansion Board Top viewRaspberry Pi Time-lapse camera. Expansion Board Top view

Raspberry Pi Time-lapse camera. Expansion Board Bottom viewRaspberry Pi Time-lapse camera. Expansion Board Bottom view

In principle setting P6-1 to GND and back to 3.3V should work OK. So using a GPIO pin from the ATiny should work as far as we power it with 3.3V, which, in the simplest case requires two resistors and takes more space than one transistor. On the other hand the ATiny will consume less power at 3.3V so probably it would worth to try (version 2.0?).

The microcontroller firmware is really simple:

void setup() {
  // initialize the digital pin as an output.
  pinMode(0, OUTPUT);

void loop() {
  digitalWrite(0, HIGH);   // set the LED on
  delay(1000 * 2);          // wait for a second
  digitalWrite(0, LOW);    // set the LED off
  delay(1000 * 30);        // wait for a second
Basically the program short cut the reset pins for 2 seconds, then release them and waits for 30 seconds to repeat the process. This is the hardcoded lapse time. I used the Arduino IDE for this with the MIT extensions for ATTiny and flashed it with a Pocket programmer. This is a picture of the improvised programming setup. ATtimy85 being programmed with a Pocket ProgrammerATtimy85 being programmed with a Pocket Programmer To finish here is a video of the system working using a display so you can follow the process. The small TV is actually not required but convenient for illustration purposes. I had tried the system with a 4500mAH battery and the system was able to run for 11 hours. Which is not bad. It is actually the double of the time I get with the same battery without powering down the system between photos. cheers The picoFlamingo Team


Thanks for this. I'm

Thanks for this. I'm planning to shutdown my raspberry pi at night and get a picaxe microcontroller to wake it up in the morning and couldn't figure out how to do it until I finally found this article.

Raspberry PI support for Buildroot

By the way, Buildroot includes support for Raspberry Pi since some time ago. Just type

make rpi_defconfig
make menuconfig