There's nothing better than Guys' Night, an evening of gaming or movies in my basement media room. The only trouble is when we (invariably) order pizza, because I can't hear the doorbell from there. The solution: an inexpensive DIY digital surveillance system tied to Twitter.
We started with Linux, which could be customized to include just the parts needed to run the camera. Then we installed a camera-management app, ZoneMinder, that can record video frames and compare them to detect motion. Throw in an old video-capture card and a $50 camera, and we've got a pro-quality video surveillance rig. Better still, when the system detects motion at the door, the software posts messages to Twitter, texting my phone (for free!) that the pizza has arrived.
Make a Pizza Cam
Time: 14 Hours
Rescue an old PC
It'd be easy to set up any number of modern services to accomplish some sort of basic monitoring – assuming you have the spare case for a modern PC and related gear. But for something this frivolous and fun we sought to construct it as much as possible from low-buck rescued gear. So we found a nine-year-old 1 GHz PIII with 256 meg of RAM lying around the closet. Before it was abandoned, it was an office desktop.
Install Your Favorite Flavor of Linux
The key to the low-buck program: selecting an operating system that doesn't hog so much of the PC's resources that it can't still run the camera. Though there are tons of options available-–check Wikipedia for a great comparison of what's available–-we chose Gentoo.
Best of all, Gentoo is free. You can download an ISO file of Gentoo's "rescuecd" – a boot disc that lets you try out the operating system and install it on your rescued PC.
Some Linux geeks dislike Gentoo because its installation package forces you to include or exclude every single driver and bit of functionality. But this works to our advantage, as we can remove virtually everything. The options you select will depend on your PC, but just remember to keep it as slim as possible.
Zoneminder is a free, open source camera control application which will allow you to view your camera's output via a web browser – plus record and perform other tasks upon motion detection. And since Zoneminder detects motion by comparing each frame to the next, you won't need any special equipment.
Zoneminder requires the Apache web server as well as the MySQL database server. These are also free and easily obtained from their respective homesites – or better yet directly via the Gentoo emerge command.
Buy and install a camera and (if needed) capture card
We scored a small infrared camera at CompUSA complete with mounting bracket and 100' of wire for $50. It can't see very far with just its tiny infrared LED lights, so it's no night-vision wiz. But it handles twilight very well, and my porch light provides plenty of light to deliver a great picture at night.
Since our camera terminated in a standard composite video connection, I also picked up an inexpensive capture board. Almost any capture board will work, but when you've found a good deal on a board it never hurts to do a Google search or two to see if anyone else has run into issues with it. You'll also save yourself cash by buying an older capture board; you don't need the functionality of new ones, and you're more likely to find Gentoo drivers for boards that've been around for a while.
Zoneminder can also work with a number of webcams, including some wireless models. So if you have an old one sitting around, you might consider using it instead.
Regardless, you'll want to plug in the camera and test it before you pull a lot of wire. I ended up using almost all of the provided 100' to run the wire out from an upstairs office equipment closet into the attic, out a vent under the edge of the roof, down a gutter, and across to the front of the house.
Write a script (or use ours)
Inside Zoneminder you have the option to create "event filters." While you can use this feature to archive old video files, you can also use it to run a script. Just define your event and add the location and filename of your script in the "Execute command on all matches" field.
Note that you can't pass parameters in this field, which means that your script won't know a lot about the specific event.
To keep us from restarting the server over and over again, we wrote a single script called zm-walkway-event.sh that calls others (download them all here).
You can then create secondary scripts to take whatever action you'd like on motion detect. We started with a simple tweet using this script:
As you can see in the code, you can choose to either Tweet publicly or to send a direct message. If you want to Tweet to a normal stream privately, just create an account for your house and set it to protect its updates. Then send follow requests from your normal account and any others you'd like to see the updates.
I decided to give this a shot, bought all the necessary parts, and I had a spare computer. I incurred some troubles throughout, but I managed to solve them. I now have a camera (mounted to the side of my house) that monitors almost my entire driveway, all thanks to this tutorial. The only problem I am having at the time is getting the whole twitter thing setup with zone minder. When I try to run the scripts (provided in the article) i cant seem to get them to run properly without errors. This could completely be my fault, as I am often wrong and definitely no pro at linux. I was wondering if the author, Chuck, if you would - and have the time - to maybe aid me in getting them to run properly. I could always go to a programming forum elsewhere if it is too much a hassle. Anyways, the errors I get when trying to run the tweetme.sh script are as follows:
: not found 2
: not found 7
: not found 9
tweetme.sh line 21, Syntax error: end of file unexpected (expecting "then")
the first three are probably due to the variable being null, as i didnt run the other script first, but the last (sytnax error) i am not sure how to solve, any help would be greatly appreciated? any pointers as well.
at any rate, this was a great tutorial :) thank you very much.
I think this is a fantastic idea. Particularly if your home is large and going up and down stairs can be such a time consuming and unnecessary movement, particularly when we are eating pizzas and watching the game. Our body is our temple and we must rest it! Seriously, I do believe the age of computing is beginning to go beyond a healthy use. Security is a necessary evil in the modern society and a camera can be useful, however lets not loose sight of the need to move our limbs and exercise our bodies. I do like the idea of using old equipment to good use as described here, at least the machines are not being sent to the tip to further add to the excess consumer waste.
I would like to clear this up for anyone who doesn't know.
"tweetme.sh line 21, Syntax error: end of file unexpected (expecting "then")"
means that he had an
"if" without a "then"