Waterproof Raspberry Pi Powered Wifi DSLR Webcam for Time Lapses

by aderewecki in Circuits > Raspberry Pi

6842 Views, 94 Favorites, 0 Comments

Waterproof Raspberry Pi Powered Wifi DSLR Webcam for Time Lapses

1D8A9849.jpg

I'm a sucker for watching sunsets from home. So much so that I get a bit of FOMO when there's a good sunset and I'm not home to see it. IP webcams yielded disappointing image quality. I began looking into ways to repurpose my first DSLR: a 2007 Canon Rebel XTi that still takes decent photos. This Instructable covers building:

  • a waterproof Pelican Case enclosure
  • Raspberry Pi camera trigger and wifi uploader
  • simple web server to access the images from the web

There are several existing guides that show how to build a waterproof enclosure for time lapses, but they tend to focus on a set up that can survive In The Wild for 3-4 months. Because this project is at my house, the parameters are slightly different: power and wifi are both available. Not needing to worry about power freed my time to concentrate on utilizing the wifi to upload a new photo to the web every minute instead of pulling them off the card manually (as is common in more traditional long timelapse setups).

Note: this project was built in September 2017, and the Instructable draft soon after. The camera ran for a very solid 4 months until a power surge burned the Pi. I found the draft today and thought it still might be a fun read for folks.

Raspberry Pi Captures Images and Uploads Them to the Web

1D8A9835.jpg

This aspect had the most unknowns for me, so I started with here.

Initially, I connected my Rebel via USB to an extra laptop and used gphoto2 to capture images programatically. gphoto2 allows you to capture images in JPEG or RAW and transfer them immediately to the host computer after capture, which is important to quickly upload the photo to the web.

My proof of concept was a simple nodejs script for my Mac Mini that captured images once a minute and uploaded them to Amazon S3. To reach outdoors from the Mini, I bought the longest USB cord I could find--but it wasn't feasible. While I had heard that a Raspberry Pi would be useful for something like this, I didn't have much experience using them. I installed Raspbian and crossed my fingers and checked on gphoto2 support for the Raspberry Pi -- full support!

The next iteration called for a wifi-enabled Raspberry Pi to replace the Mac Mini completely. In broad strokes:

  1. Download the latest Raspbian image
  2. Insert a micro SD card and unmount it (`diskutil unmountDisk /dev/disk2`)
  3. Use `dd` command line utility to write the image to the card (`sudo dd if=2017-09-07-raspbian-stretch.img of=/dev/disk2 bs=4m` -- takes 30-60min)
  4. Touch `/ssh` on the file system to enable SSH on boot (detailed guide to SSH / Wifi)
  5. Install gphoto2 using the Raspberry Pi install script (takes 60-90 minutes)
  6. Set a cron job to run once a minute and use gphoto2 to capture a photo
  7. Use curl in that same cron job to upload the photo to a simple server running on Heroku

The cron config is very simple:

# m h  dom mon dow   command
* * * * * bash /home/pi/capture-upload.sh 2&1 >> /home/pi/cron.log
#!/bin/bash
# capture-upload.sh

set -e
gphoto2 --auto-detect --capture-image-and-download --force-overwrite
curl -F "image=@capt0000.jpg" <a href="https://user:pass@potrerohillcam.herokuapp.com/upload">https://user:pass@potrerohillcam.herokuapp.com/upload</a>

While the original proof of concept handled uploading to S3, I decided it was far easier* to simplify what the Raspberry Pi was in charge of and kick the S3 and post-processing steps to a simple web server running on Heroku. This curl command takes the captured image and posts it to that server.

* by easier, I mean I was sick of waiting for packages to compile on the Pi.

Camera in Weatherproof Pelican Case

1D8A9822.jpg
1D8A9829.jpg
1D8A9828.jpg
1D8A9821.jpg
1D8A9820.jpg
1D8A9825.jpg
1D8A9832.jpg
1D8A9834.jpg
1D8A9826.jpg
1D8A9843.jpg
1D8A9840.jpg

Now that the the camera/RPi solution was reliably able to take photos and upload them, I began working on a case that will keep all the electronics safe in the rain.

Load the photos one-by-one and hover over the outlined white box for a description of the part/step.

Real World Setup

1D8A9845.jpg
1D8A9848.jpg
1D8A9846.jpg

The final step was mounting the Pelican case on my back railing and verifying that everything worked.