Community Articles
Find and share helpful community-sourced technical articles.
Labels (2)


- 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

Get Latest version of MiNiFi :

# wget

Get Latest version of MiNiFi ToolKit:

# wget

Get Latest version of NiFi:

# wget

Untar the files and start NiFi on your local machine and MiniFi on your Raspberry Pi


Flow on MiNiFi Download the flow Pi-MiNiFi-FLow.xml and convert it to YAML format which MiNiFi uses (before you deploy make sure you have your local NiFi URL for RPG rather than what I have in there)

# /root/minifi-toolkit-0.1.0/bin/ transform Pi-MiNiFi-FLow.xml minifi-0.1.0/conf/config.yml

Flow Looks like below:


Flow Explained:

a) Poll for Sensor output and Sent it to NiFi

GenerateFlowFile processor triggers every 5seconds to execute a python script as below using an ExecuteStreamCommand proceesor, result is sent to NiFi running on my local machine via Remote Process Group. script looks like below:

import RPi.GPIO as GPIO
import time
import os
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 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:

# sudo apt-get install mpg123 script looks like below:

import os
os.system('mpg123 /root/alarm.mp3')

Flow on NiFi

Download the flow MiNiFi-MotionSensor-SMS-Alert+Response.xml and deploy it after updating your custom hostnames and other details details. It looks like below:


Flow Explained:

a)Receiving Sensor Alert from MiNiFi and send SMS

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.

Now you its time to try out!!


Raspberry Pi and PIR Motion Sensor article I followed



My GitHub Article


Jobin George

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.
Version history
Last update:
‎08-17-2019 01:00 PM
Updated by:
Top Kudoed Authors