Re: Motion detection using a Raspberry Pi + camera module + openHAB

3,735 views
Skip to first unread message
Message has been deleted

Ben Jones

unread,
Aug 11, 2013, 8:47:20 PM8/11/13
to ope...@googlegroups.com
I recently got my hands on one of the new camera modules for the Raspberry Pi. I already had a Pi in my garage which I was using with my PiFace binding to control my irrigation systems (this Pi was running a slightly modified python script to access the GPIO pins directly, rather than through the PiFace extension board).

I decided it would be a good place to add some more camera/motion detection to give some extra security in my garage so plugged in the camera module and starting playing.

I came across this thread (http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=45235) which contained a very clever python script for detecting motion. I made some adjustments and updated it so it would periodically read the 'armed' state from openHAB to see if the garage zone was active. If not it would sleep for a second and then re-check. If it detected that the garage zone was armed it would begin checking for motion. Any time it detects motion it then updates the 'motionDetected' item in openHAB and sends me an email with the image taken.

So in order to use this script you need to obviously setup your Pi with the camera module, follow the instructions attached, set all the custom variables etc and run the picam.py script. You also need 'armed' and 'motion' switch items in your openHAB configuration. The idea being you 'arm' the zone based on presence rules etc, and then send XMPP notifications when the 'motion' item is triggered (or whatever other rules you might want).

Thought I would share as it is a very cheap and effective motion detecting system!

BTW - I am currently running all my Pis with readonly file systems to see if it helps with stability as I was seeing SD card corruptions every few weeks. The picam script will email you the image when motion is detected, but it will also save a copy to a folder on the Pi. In my case I have a folder mounted to an NFS share on my home server. This means the Pi can remain readonly.

picam.zip

Kai Kreuzer

unread,
Aug 12, 2013, 3:19:48 PM8/12/13
to ope...@googlegroups.com
Hi Ben,

You are doing cool stuff, wish I had the time for that :-)
In case you ever feel like taking a video from your setup that would be a perfect member for the openHAB YouTube channel!

Regards,
Kai


--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/groups/opt_out.
<picam.zip>

Piotr Betlej

unread,
Aug 12, 2013, 3:31:34 PM8/12/13
to ope...@googlegroups.com
Hi Ben,

in case you would want to go further in your investigation, there is a more sophisticated surveillance tool around:

It worked for me on a AT91SAMG20 SBC with 64MB RAM very well. So it would be suitable for RaPi too, I guess.

Regards

Piotr

Ben Jones

unread,
Aug 12, 2013, 4:53:16 PM8/12/13
to ope...@googlegroups.com
Thanks Piotr. I have come across Motion and did some research. Someone has written a modified version for use on the Pi with camera module (https://github.com/dozencrows/motion/tree/mmal-test) but it is a fairly complex install and is obviously still very early days. The beauty with the script I am using is it is extremely light weight and quick. I will keep an eye on the Motion development and might give it a go one day, but for now the camera is happily sitting in the garage doing its thing.
Reply all
Reply to author
Forward
0 new messages