Monday, April 04, 2016

Giving the Pi a little Dirt Time: A Raspberry Pi Powered Garden Cam

We're entering that magical time in the X-Garden where the first tiny hints of life appear. Here's itty bitty Zinnias making a first appearance:

This seems like the perfect opportunity to capture a hyperlapse. After mulling it over, I decided the simplest and most reliable method would be to weatherize my Raspberry Pi, plug it into an all-weather extension cord and a webcam and write a quick script to grab and push photos up to the cloud.

So that's what I did. Here's the Pi getting set for some dirt time:

Yes, that's a double-bagged Pi, with duct-tape providing the weather proof seal. Pretty silly looking, but I think it's just simple enough to work.

Scripting the Pi was truly the easy part. I installed fswebcam an s3cmd and whipped up this tiny shell script to snap and upload photos:


file=/tmp/snap-`date +%Y%m%d.%H%M%S`.jpg

fswebcam -S 120 --no-banner $file
s3cmd put $file $bucket
rm $file

I found the -S 120 was needed or fswebcam would grab a white image. I figure I'll grab lots of images and use ffmpeg to make the hyperlapse itself.

The weak link in all of this is the webcam I'm using. It's an ancient USB model which has horrendous quality. I've since purchased a new one on Amazon and will give that a try once it arrives.

The big question: after our first rain, will the Pi still be ticking? We shall see...


  1. My wonder would be more related to heat? if it is tied up in a bag, where is the heat going? Luckily we are having a cold few days... but this all said... I now have an excellent excuse to buy a Pi... garden tracking :-)

  2. Nick -

    I had the same thought. For now, heat isn't a problem. And I'm glad to report that we came through yesterday's rain storm without issue. But yeah, if I'm going to leave this solution around for or a while, I'll need some answer to the heat question. Any ideas?

  3. Jason Doege8:58 AM

    Assuming you did an OK job sealing things up, your concern will be condensation when temps get cool. I would suggest either venting the enclosure well and in a rain-proof way (which suggests something other than a plastic bag) or toss desiccant in the bag before sealing it up.

  4. Thanks Jason - good call on the desiccant bag.