Motion Detection Alarm System with Java & Reactive Blocks – Deploy on Raspberry Pi & Send SMS
With a standard USB camera you can build a reliable motion‑sensing alarm that runs on any Java SE‑enabled machine, including the Raspberry Pi. Using Reactive Blocks, a visual Java programming tool, you can assemble a fully‑functional application that captures images, detects motion, and sends an SMS alert via Twilio—all without writing a single line of code.
This tutorial walks you through the complete setup, from hardware to software, and shows how the application can be deployed on a Pi or any other Java SE environment.
What You’ll Need
- Raspberry Pi Model B+ running Raspbian OS
- USB camera (any common model works)
- Ethernet cable (or Wi‑Fi)
- Display and keyboard for the Pi
- Windows or macOS workstation with JDK installed
- Reactive Blocks (free Eclipse plug‑in for open‑source projects)
The bundled Motion Detection project includes two ready‑to‑run applications: the full Alarm System and a lightweight Test Motion Detection demo. In this guide we’ll focus on the Alarm System.
Step 1 – Install Reactive Blocks
Download and install Reactive Blocks from https://bitreactive.com/installation/. The plug‑in is free for open‑source projects and integrates directly into Eclipse.
Step 2 – Import the Sample Application
Open the Reactive Blocks perspective and select the Blocks view. Click Import → Reference Applications and choose Motion Detection. A Google account is required for the first time to access the block library and tutorials.
The imported package contains the Alarm System and a test harness; we’ll use only the Alarm System for this tutorial.
Step 3 – Understand the Top‑Level Architecture
The diagram below shows the application’s top‑level flow. It comprises seven blocks: five from the IoT library and two custom blocks created specifically for this project.
- Grabber – captures images from the USB camera via OpenIMAJ.
- Image to File – writes the captured image to disk.
- Periodic Timer – triggers a regular tick to start the capture cycle.
- Buffer Eager – ensures only one message is queued for the SMS block, preventing overload.
- SMS Send – dispatches an SMS through Twilio.
- ReadConfig – loads configuration values from
motiondetection.ini. - View – displays the image on screen.
The Periodic Timer acts as the engine, emitting a tick that drives the Grabber. The Grabber launches a dedicated thread that listens for a grab command, takes a single frame, and forwards it via the image output. The Motion Detection block, also built on OpenIMAJ, compares consecutive frames in a separate thread. When a change is detected, it fires a motionDetected signal, which triggers the SMS workflow.
All custom Java methods are accessible by clicking on the light‑blue boxes in the editor, giving you insight into the underlying logic.
Step 4 – Configure SMS Delivery
Open config/motiondetection.ini (found under br.ref.motiondetection in the Project Explorer) and enter your Twilio credentials. If you prefer another provider, you can replace the Twilio block with the ready‑made Clickatell block or switch to email/Cloud notifications using the available SMTP, AirVantage, IBM Bluemix, or Xively blocks.
Running the application without SMS enabled is also straightforward—simply leave the Twilio block disconnected.
Once configured, deploy the application on the Pi: Java SE is pre‑installed on Raspbian, so you can launch the .jar directly or via a system service for continuous monitoring.
For deeper insights, consult the Motion Detection Alarm System documentation.
Manufacturing process
- Designing Fail‑Safe Control Systems for Safety and Reliability
- Intrusion Detection Systems: Protecting Your Network with Smart Alerts
- Secure Home Monitoring with Home Assistant on Raspberry Pi: Motion, Alarm, and Video Capture
- Build a DIY Infrared Motion Sensor for Raspberry Pi – Step‑by‑Step Guide
- SERENA: A Custom Arduino Mega 2560 Alarm System with TFT LCD Touchscreen
- Evaluating Alarm System Security with Arduino and RF Modules
- Advanced Arduino Collision Warning System – Visual & Audio Alerts for Vehicle Safety
- Build a Gesture & Motion Detector with PIR Sensor & Arduino Nano
- Build an Arduino Security & Alarm System – Step-by-Step Tutorial
- IoT-Powered Gas Detection System: Enhancing Safety in Hospitality and Industrial Settings