Avenue evening

I do like a timelapse.

I recently subscribed to The MagPi magazine, and as a welcome gift received a Raspberry Pi Zero W, official Raspberry Pi case, camera connector cable and a few other bits and pieces. I already had a Raspberry Pi camera module knocking around, and as the case comes with a front that has a hole pre-cut for the camera, this gave me the perfect excuse to lash them all together.

Here’s a full list of parts used in the project:

  • Raspberry Pi Zero
  • Official Raspberry Pi Zero Case with camera connector
  • Camera module
  • ProtoZero board
  • Pimoroni Blinkt!
  • Male GPIO header
  • Female GPIO header
  • Right angle GPIO header
  • 3 tactile buttons
  • Hook up wire
  • Suction cups

I wanted to use buttons to trigger the starting and stopping of the timelapse, and to be able to take a single image, and planned at first to solder wires onto the back of the Pi Zero and hot glue some small buttons onto the case. Then I thought it’d be nice to also include an LED to show if the camera was on or doing something. (Everything is better with LEDs, right?)

This started to seem a little messy, but I remembered that in one of my boxes of bits I’ve a few ProtoZero boards from a Kickstarter a while ago. These are neat Raspberry Pi Zero sized boards with GPIO breakouts and lanes of breadboard-type sockets for components.

Raspberry Pi camera

The Raspberry Pi case comes with different fronts you can swap out. One is plain, with no openings, one has an opening for the GPIO pins and one has a hole and mounting points for the camera module. I needed to use this one, but it meant I had to solder a female header onto the back of the Pi Zero and connect the ProtoZero board onto that upside down. I added a right angle GPIO header to the ProtoZero board which let me add a Pimoroni Blinkt! for lots of LEDs, instead of just one.

Raspberry Pi camera

I was surprised, and relieved, when this rather hacky set up worked and my first attempt at running some code for the camera actually translated button presses into action.

Despite lots of trying, and lots of bad code, I’ve not been able to work out how to make a button interrupt a process and reset the Pi ready for another event, so I changed plans slightly and now have one button to take a single still image, one to start a half hour long capture of 120 images for a short timelapse and the third button to keep on taking pictures for a timelapse until your inelegantly pull the power out.

The Blinkt! lights shine white on booting up to show the camera is ready. When you take a single photo they flash red then reset to white. During a timelapse they display a column of lights counting up to the next image capture and flash red when a photo is being taken, so you’ve some idea when the next picture is due.

Timelapsing

To put the timelapse together I FTP into the Pi, copy the images onto my MacBook and use iMovie to make them into a video.

The code is on GitHub – please comment if you can see improvements or have any ideas for me. I’m not a coder and would love to hear your suggestions. I found the GPIO Zero documentation to be really helpful, especially the recipes, and Alex Ellis‘ blog post was inspiring.

Finally, to secure the case to a window Frederick Vandebosch came up with this case mod just in time, so I ordered some suction cups off eBay and got cracking with my craft knife.

I’m really pleased with how this has turned out – even though it doesn’t have the functionality I intended when I started out I think the project has turned out really well.