This demo is featuring use of Raspberry-Pi as a gateway in an alarm system. We connected a camera and accelerometer to the Pi and used Reactive Blocks to make a simple intruder detection application.
Every time vibration is detected, the camera takes a picture and checks if there is a change in the image. If a change is detected, it sends an SMS and an email with an attached image of the intruder.
To make this demo application, we used the following:
How we built it
The Raspbian release has Oracle Java preinstalled, so running Reactive Block applications on Raspbian is very easy. At the top level we ended up with this system:
The top system consists of 8 building blocks; 7 standard blocks and 1 custom made block:
Standard Blocks from the IoT Library
The Grabber block uses the Open Intelligent Multimedia Analysis for Java, OpenIMAJ. When the block is initialized, a separate thread is started to read data from the camera. The thread listens to a command queue. When the block receives a command via the grab pin it will take one picture and deliver it on the image pin.
The Motion detection block also uses OpenIMAJ. A method within this block compares two images and will flag changes in image when motion is detected. The method is very CPU intensive and has to be run in a separate thread. When an image is detected it is signaled on the motionDetected pin.
So lets look closer at the Vibration sensor block that is custom made for this application. It interfaces the accelerometer via the I2 bus on the Raspberry Pi. If you click on the block you can see the detail inside:
You will see that it consists of all standard building blocks from our IoT libraries:
The RPi 12C block, is used to initialize and read data from the accelerometer. It is polled at 10Hz, but vibration has to be continuous for more than 1 second to be detected. The isVibration() method will return true and start a timeout if acceleration of all axes combined is above 1.05 g or below 0.95 g. If detection continues for more than one second, the vibrationDetection pin is fired. The Timeout is handed as a filter to avoid overloading the Pi with too much heavy image processing.
Notification is done with SMS and email. The file with image is attached to the email, and could be attached to the SMS if the service supported that feature.
If you want to make a detection system like this one you can get access to the building blocks used in this project from team reference systems.
You can of course experiment and use a motion detection sensor instead of an accelerometer to detect changes. We have building blocks and example systems for that as well. Download Reactive Blocks to learn more and start developing your own applications with Reactive Blocks. Please feel free to contact me if you are interested.
Posted: 25. August 2014