The current webcam looking at the flight line. |
In July, our webcam went offline. Usually, this is a relatively minor annoyance caused by a need to reset the computer. The system we had is admittedly a hack of sorts, cobbled together using a donated Mini-ITX computer, Windows XP and a Logitech 9000 webcam. I was actually surprised by how hardy the system was. At first, the computer ran both the webcam and our weather station (more details here) but after several years, it became unstable and I switched the weather station over to a spare Sheeva Plug embedded Linux computer and a weather program called Meteoplug. It's worked very reliably since then.
When the computer finally gave up the ghost, I decided that there was no need for a full Windows installation simply to run a webcam. Between the security issues, the updates, and the cost, I saw no reason to get another full blown computer simply to take a picture and upload it to the web server.
The webcam computer. No moving parts, small, under 5 watts. Perfect. |
I chose instead to use a $45 embedded Linux computer called a Raspberry Pi. The Pi is perfect for this application because it is inexpensive, has no moving parts, uses a regular SD card for storage, and draws less than 5 watts of power. It even has an hdmi output and runs a desktop GUI. Amazing.
The Pi is a hobbyist's experimental computer and runs Debian Linux. I started by trying a program called Motion and it worked perfectly. I'd been very worried I'd have to muck with numerous settings just to find the webcam, but I plugged it in and it started working right away. However, I did have to monkey with the settings to switch it to take a single photo every 2 minutes. The program is actually much more powerful than that -it can detect motion, upload a timelapse, notify you, etc. The array of options is actually a bit dizzying.
I then entered a loop where I tried to use the auto-upload feature of Motion to send a photo to our server, but ran into problems troubleshooting that, and further, with permissions on the files even to get it to do something as simple as starting up when the system reboots (in case of power failure).
In the end, an epic misinterpretation of the wput command is what burned up most of my time and troubleshooting the problem at the glider field just wasn't working. I had to get a webcam (thanks Wade!) and take the setup home so I could spend some quality time with it.
I finally ended up using a simpler program called fswebcam. There are plenty of tutorials for how to set this up for the Pi. Here's the two that helped me most: http://blog.davidsingleton.org/raspberry-pi-webcam-a-gentle-intro-to-crontab/ and http://www.r3uk.com/index.php/38-tech-tips/software/100-webcam-capture-using-fswebcam. I owe both of those bloggers a lot. There are a number of other tutorials out there, so your mileage may vary.
I've used Linux enough to know my way around it a bit, but it is such a struggle to get it to do the simple stuff sometimes. I spent the majority of my time on this project A) trying to get the wput command to work properly; B) trying to get CRON to startup Motion automatically on reboot. Because I never solved the startup issue with Motion (although I knew what the problem was), I switched to fswebcam. (Hint: if you want to use Motion for your install, make sure you are aware that it installs as ROOT rather than user and install accordingly! Otherwise, you run into all kinds of problems reading the config file, writing the images, and just starting up the service. You have been warned.)
No matter, it is FINALLY up and running now and feeding a beautiful picture to the server, just like it did before the original computer broke down. Phew!