Webcam security system

I have a suspicion that people are partying in my apartment when I'm not home. To put this theory to the test, I bought a Raspberry Pi. I installed the Arm flavor of Arch Linux and loaded up the open-source package motion.

The loop works as follows: every 60 seconds a python script checks for my phone in my router's connected devices list. If my phone is there (and on my wifi), it does nothing. If it is not there, it makes sure the motion package is running. When motion is running, if it notices movement on the webcam, it triggers another python script which sends me an e-mail with the current webcam snapshot as an attachment. It does this upon motion first detection, not constantly, so I don't continuously get e-mails.

webcam sample

Obviously there is some more work I could do with tuning the motion sensing settings, waiting to send the images, providing a live webcam feed, etc, but I haven't gotten around to doing any of it. The total cost of the project was about $50 ($42 for the Raspberry Pi, $9 for the webcam).

My code can be found at

my hardware setup