Created on 05-15-201701:37 AM - edited 08-17-201901:00 PM
- Here is a small demo how to flex MiNiFi+NiFi on a Raspberry Pi to detect Motion and send alerts to your phone via SMS, also on your SMS reply it will trigger sound ALARM [Basically to shoo away an intruder]. You can do it from where ever you have cell phone reception.
- Here you can view the screen recording session that Demonstrates how it works!
Raspberry Pi 3, a PIR motion sensor and a speaker connected to it. Details on how to connect PIR Motion Sensor to Raspberry Pi can be found in url under references.
Assuming you already have latest version of HDF/NiFi and Minifi downloaded on your Mac and Pi. Else
GenerateFlowFile processor triggers every 5seconds to execute a python script pirtest.py as below using an ExecuteStreamCommand proceesor, result is sent to NiFi running on my local machine via Remote Process Group.
pirtest.py script looks like below:
import RPi.GPIO as GPIO
GPIO.setup(11, GPIO.IN) #Read output from PIR motion sensor
if i==1: #When output from motion sensor is HIGH
print "Intruder detected",i
b) Play Panic Alarm on SMS trigger from NiFi
listenHTTP processor hosts and listens for any incoming flowfile, when arrived next processor ExecuteStreamCommand executes a python script alarm.py as given below which trigger a panic alarm sound to be played. I used mpg123 to play the alarm sound, you can install it on your raspberry pi using below command:
An InputPort receives MotionSensor output from MiNiFi, RouteOnAttribute processor verifies the output and send it to a ControlRate processor only if motion is detected. Control rate processor ensures your phone is not flooded with alerts. putEmail processor is configured to send SMS to my phone.
b)Check for ALARM request and send signal to MiNiFi
ConsumeIMAP processor checks for new ALARM request in a specified folder in my mailbox, when received, triggers a flowfile. RouteOnContent processor verifies the new mail and route it based on sender and content, feeding it to a PostHTTP processor connecting to listenHTTP on MiNiFi triggering ALARM.