Skip to main content

Powering Edge AI for Sensor Reading with RPI and Breakout Garden (EFM, NiFi, MiNiFi Agents)


Powering Edge AI for Sensor Reading with RPI and Breakout Garden (EFM, NiFi, MiNiFi Agents)







Hardware Component List:

  • Raspberry Pi 3B+
  • BMP-280 Temperature, Pressure and Altitude
  • ST7735 0.96 SPI Colour LCD 160x80
  • MAX-30105 Oximeter and Smoke Sensor
  • Sony Playstation 3 EYE USB Web Camera

Software Component List:

  • Raspian
  • Python 3.5
  • JDK 8 Java (Soon Upgrading to JDK 11)
  • Apache NiFi 1.9.2
  • MiniFi Java Agent 0.6.0
  • Cloudera Edge Flow Manager
  • Apache Kafka 2.2

Summary

96410-breakoutgardenarchitecture.jpg

Potential Use Cases:   Tracking Environment in a facility that includes webcam detection, temperature, pressure and smoke.


Our Raspberry Pi 3B+ has a Breakout Garden Hat with 2 sensors and one small display. The display is showing the capture image and is constantly updating. 
We currently run via nohup, but when we go into constant use I will switch to a Linux Service to run on startup.
The Python script initializes the connections to all of the sensors and then goes into an infinite loop of reading those values and building a JSON packet that we send via MQTT over port 1883 to a MQTT Mosquitto broker. MiniFi 0.6.0 Java Agent is using ConsumeMQTT on that port to capture these messages and filter them based on alarm values. If outside of the checked parameters we send them via S2S/HTTP(s) to an Apache NiFi server.
We also have a USB WebCam (Sony Playstation 3 EYE) that is capturing images and we read those with MiniFi and send them to NiFi as well.  We will incorporate TensorFlow lite models into our analysis.
The first thing we need to do is pretty easy. We need to plug in our Pimoroni Breakout Garden Hat and our 3 plugs.
You have to do the standard installation of Python 3, Java 8, MiniFi and I recommend OpenCV. Make sure you have everything plugged in securely and the correct direction before you power on the Raspberry Pi.
Install Python PIP 
Install Breakout Garden Library 
unzip master.zip
cd breakout-garden-master
sudo ./install.sh

NiFi Flow


We Can Query IoT Events As They Stream In



Add ExecuteProcess to Run Our Shell/Python




IoT JSON Data



IoT User



Cloudera Edge Management - Monitoring IoT Events From MiNiFi Agents on Devices


Building an IoT Flow Graphically Is Easy!   It follows the Hadoop Philosophy to stitch these things together.  



Configure Connection to MQTT Broker



MQTT Configuration 2




Cloudera Edge Flow Manager REST API





 Let's Examine those MQTT Messages from Devices









As you see we follow the Hadoop Philosophy of keeping things open, extensible, modular, flexible, transparent, composable, using open data standards, open source, diverse and cloud friendly.  In this way we can always bend to the needs of the user and adapt to any environment, any data, any cloud at any time.   If we need to windowing we could easily add Storm or Flink.   For other streaming use cases we can connect our Kafka topics to Spark Structured Streaming or Kafka Streams for additional processing as needed.    We can public our public schemas from our schema registry as open data standards within our enterprise, our ecosystem or world wide.   Data is meant for sharing and utilizing to build knowledge.   Let's make it happen, from any Edge to any data store to any data cloud to any AI / ML / DS / DL model.

Source:
https://github.com/tspannhw/breakoutgardenhat-spi-minifi

Resources:

Breakout Garden Hat
https://github.com/pimoroni/breakout-garden/tree/master/examples/heartbeat
https://shop.pimoroni.com/products/0-96-spi-colour-lcd-160x80-breakout
https://datasheets.maximintegrated.com/en/ds/MAX30105.pdf
https://shop.pimoroni.com/products/max30105-breakout-heart-rate-oximeter-smoke-sensor
https://github.com/pimoroni/max30105-python
https://github.com/tspannhw/minifi-breakoutgarden
https://shop.pimoroni.com/products/0-96-spi-colour-lcd-160x80-breakout
curl https://get.pimoroni.com/st7735 | bash
https://github.com/pimoroni/st7735-python

Using a Different Configuration of Breakout Garden Sensors
https://community.cloudera.com/t5/Community-Articles/IoT-Series-Sensors-Utilizing-Breakout-Garden-Hat-Part-1/ta-p/249262


TensorFlow
https://github.com/tensorflow/examples/blob/master/lite/examples/image_classification/raspberry_pi/README.md
https://www.tensorflow.org/lite/guide/python
https://github.com/PINTO0309/Bazel_bin
https://github.com/PINTO0309/Tensorflow-bin

sudo apt-get install libatlas-base-dev 

wget https://dl.google.com/coral/python/tflite_runtime-1.14.0-cp35-cp35m-linux_armv7l.whl
pip3 install tflite_runtime-1.14.0-cp35-cp35m-linux_armv7l.whl