Friday, 3 January 2014

PiCam Home Security


Hi Guys,
 

Wanted to tell you lot about the PiCam I got for Christmas and the endless fun I've had programming it.
 

If you don't know, by Pi I mean Raspberry Pi, not π <<< that kind of pi! If you didn't know, a Raspberry Pi
is not something you eat, it is a microcomputer, about the size of a credit card. (For more, visit raspberrypi.org)

 

The PiCam can be used for many different things, but one of the main ones is a motion sensing camera. (Here is the tutorial on how to do it! 
http://www.pcpro.co.uk/features/386086/make-a-motion-sensing-camera-with-the-raspberry-pi) How this works is that every half second or so, the PiCam takes a low res picture, and compares it to the previous one. If they are different, it will take a higher res picture, and save it. If you are interested, here is the code for it:
https://raw.github.com/ghalfacree/bash-scripts/master/picam.py 
(This is the file you wget if you are using proper Unix, not xwindows)
 

Then I found a tutorial on how to put Dropbox on the Pi: 
http://raspi.tv/2013/how-to-use-dropbox-with-raspberry-pi

This bit is a bit time consuming, but it is worth it.
Basically, you have to create your own "app" on the Dropbox site, and sync it onto your Pi.
I was then able to put a three line chunk of code into my picam.py, and zing! The pi would automatically upload the picture to my computer, and it would say this:








Pretty cool, huh?
 
Then I had to edit the grubby files deep down in /home/pi/etc to make it to run the program on boot, so that you wouldn't have to use a keyboard, it would just start when you plugged it in.
This is the tutorial that worked best for me:
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=7192
 

You have to make the pi auto - login, that involves a complex bit of code inside /etc/inittab, then you need to edit .bashrc to make it boot to picam.py.
Hopefully then, when you plug it in, you won't need a screen or keyboard, it will just run. You can always break out of it too with Ctrl+C.
 

All in all, this is a great project to build with around about 6 man hours (well, kid hours really)
 

Hope this post has helped!

No comments:

Post a Comment