Keep Tab On Home Security With A Webcam And Twitter

Worried about someone breaking into your house in your absence? Or just need to keep a tab on who enters your room while you are away? Well, all you need is a webcam, a linux PC/laptop and a twitter account. And you are set for real time updates through twitter about all that goes on at your abode behind your back (can even receive a text message/sms on your phone). Keep reading for the very simple setup you need.

1.) Download and install “motion” on your computer. For ubuntu users, this is as simple as running

2.) Setup your motion configuration file. (Usually at /etc/motion/motion.conf). There are quite a lot of options available. You might want to tweak it a lot according to ur needs later on but the most important ones that you can begin with are (leave the rest untouched for now):

2a.) Add/edit the option “target_dir” to point to the directory where you want to save the images of the event when motion is detected.

2b.) Add/edit the option “locate” and set it to “on” so that you get a nice square box around the detected moving object/person.

2c.) Add/edit the option “webcam_port” and set it to, say, “8000”. Motion includes a mini http server so now, you can use it to view the actual images of the happening when you get the update and check for false alarms.

3.) Now, comes the most important part, about getting the update.

motion has an option called “on_motion_detected” and here you can specify any command or program that you want to run when motion is detected. To get the update on your twitter account, use one of the following three methods with this option.

3a.) Using curl. If you have curl installed in your system, then you can use the following value for the on_motion_detected option:

3b.) Using wget. If you don’t have curl, you can even use wget for this. Use the following value:

3c.) Using my perl script. If you don’t have curl as well as wget, you can even use my perl script (attached below) for this. The value will now be:

  1. Now connect your webcam and start motion (Just type “motion” on command line and press enter). Wait for someone to break in, or just roam around in front of the camera yourself and have fun as you receive a message on your phone about the “motion”.

PS: For receiving a text message on your phone, you’ll need to turn on the “Device Updates” option in your twitter account, otherwise you need to open the twitter web page to check the status.

The script: Twitter Updating Perl Script

Let me know if you put this to some other exciting uses or have any questions about the method described above.

See also