Introduction: Timelapse Camera Birdhouse With Google Drive, Lodge-style
In this instructable, we'll make a timelapse camera using a Raspberry Pi and stick it in a snazzy lodge-style birdhouse. You choose the time-interval for each timelapse photo, and the photos are automatically uploaded to Google Drive for access anywhere. You'll do a bit of woodworking, a dash of programming (python), some Linux-fu (cron), and learn Google Drive's API. Let's get started.
Step 1: Planning - Materials & Cost
Here's what you'll need:
- Raspberry Pi (any version)
- Compatible camera (we used this)
- USB wifi-dongle (we used this)
- Wood (~12" x 48" in total)
- Wood stain & seal
- Power-drill & drill bits
- Chop-saw, skill-saw, or table-saw
- A regular ol' door-hinge
If you already have the tools laying around, you're looking at about $50-70 in cost. If cost is a factor, you could get that down a bit further by going with an Arduino instead of a Raspberry Pi.
Going solar-powered or battery-powered seemed like fun early on, but it's a bit impractical when you consider the power utilization over time (months, years). Plugging it in to the wall makes the most sense if you have an outdoor outlet.
Step 2: Cut Cut Cut, Clamp Clamp Clamp
The design is pretty simple. I opted for 12" x 9.5" roof-panels, meeting at a 45 degree inside angle at the top. You'll have to do some maths to flush the sides of the bottom piece, but I believe in you.
Make sure you drill the opening and the camera hole on the front piece before you start gluing. I used a 1/4" bit for the camera hole and wiggled it a bit to make it large enough to accommodate the lens. Be gentle, yet firm.
It helps to cut a jig and use it to clamp the front and back to the bottom (pictured). The joints might need a little sanding to get everything flush.
Step 3: A Few Minor Details
Depending on the hinge you use, you'll likely need to make some last-minute adjustments to get everything lined up. We had to file some of the back panel to make room for the inside screws.
Staining is pretty straight-forward. If you opt for eyelets along the top as we did, you can hang it over some newspapers. Some light sanding and a single coat seemed to do the trick.
You'll also need to file a notch for the power cable on the back panel (pictured) if you are plugging this in to the wall.
For some really lame interior weatherproofing, I stuck the whole thing in a ziplock. An interior shelf is on the TODO list, which would have the added benefit of giving birds their own bedroom separate from the Pi.
Step 4: Pi-camera & Google Drive
Now the fun part. Since the Pi has a wifi dongle, I recommend giving it a static IP and using SSH to manage it through the rest of these steps.
- I've added the code for the camera and drive integration to github here: https://github.com/dunds/timelapse . The script has one dependency: a client_secrets.json file from your Google Drive API.
- While logged in to your Google account, navigate to: https://console.developers.google.com/apis . From here, you can enable Google Drive and manage API credentials.
- Click the "credentials" tab and select "Create credentials->OAuth Client ID". Use "other" as the type. Your newly created credential will have a download link to the far right (pictured). Name it client_secrets.json and stick it in your timelapse directory.
- Run "python timelapse.py" from the timelapse directory. The first time you run this, you'll be guided through a process where Google validates your application with a security token. Look at you, authenticating securely to Google Drive. What a boss.
- Last step is to add an entry to cron to schedule this script to run daily. Here's what my crontab looks like:
pi@raspberrypi:~/timelapse $ cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # 15 14 * * * pi cd /home/pi/timelapse/ && python timelapse.py
Step 5: Wrapping Up
All done! The Pi will snap a photo once daily which will be automatically uploaded to your Google Drive account. Hang it with a view of something nice and start thinking about your next project.
We have a be nice policy.
Please be positive and constructive.