IoT Prototype: Light Monitoring with NodeRED Components in Predix
NodeRED is an open source IoT tool that helps to reduce development efforts when working with hardware, APIs, and services. However, how long exactly would it take to build something tangible? What if we used it with a PaaS?
Our team has created some NodeRED components for GE Predix when working on a prototype for a light monitoring system. Here is a detailed account of the project, including its source code, data flow, hardware details, etc.
Description of the prototype
The prototype models an industrial light monitoring system based on an ambient light sensor, which is a simple photoresistor.
The device identifies the level of lighting conditions; the data is then processed and sent into Predix by Raspberry Pi. From there, a NodeRED app forwards the information to Dashboard Seed, which draws a graph—showing how lighting conditions change over time.
Each component is relatively independent, so the system can be easily scaled and adapted for larger enterprise use cases. This may include managing lighting conditions within manufacturing facilities, greenhouses, farms, etc.
The prototype is powered by three GE Predix services:
- Time Series, a component for managing time series data
- User Account and Authentication, Cloud Foundry’s multi-tenant identity management service
- Dashboard Seed, a set of UI modules for building industrial monitoring apps
For this prototype, I used the Universal Starter Kit for Raspberry PI. The device is Raspberry Pi 3:
- CPU: 4×ARM Cortex-A53, 1.2 GHz
- RAM:1 GB LPDDR2 (900 MHz)
- Networking: Ethernet, 802.11n wireless
- Bluetooth: 4.1 Classic, Bluetooth Low Energy
- Storage: microSD
- GPIO: a 40-pin header, populated
Raspberry Pi is connected to a board with a photoresistor and a two-channel analogue-to-digital converter (ADC), which converts analogue signals from the photoresistor into digital signals.
The back-end is made up of three components:
On Raspberry Pi, we have a C app that reads light values from ADC, using the I²C protocol, and saves them to a file.
A NodeRED app deployed to the same Raspberry Pi reads from the file and converts everything into a format supported by Predix Time Series. After that, it ingests the data directly into Time Series.
- We’ve also configured another NodeRED flow that provides a way to query the Time Series Service and receive data in a format supported by Predix’s UI Chart components.
The UI app draws a chart based on the data. It is powered by Predix Seed and uses Predix’s UI Chart components. Data is updated dynamically through a method available in Predix’s UI. See these links for the source code of the chart app: chart.js and chart.html.
This prototype is another proof that NodeRED really does save a considerable amount of effort, whether you are working with software or hardware. Using Predix’s Chart and our NodeRED components, I was able to build an end-to-end application, design the circuit, and set up the hardware in under 12 hours. Most of this time was spent on the hardware, the circuit, and the low-level application in C. Dashboard Seed has a steep learning curve, but with due experience, creating charts based on data from Time Series should not take too much time.
On the downside, Time Series has shown a significant latency in our use cases. Data becomes visible in 3–5 minutes after being ingested. The response latencies average at several seconds and can reach 10 seconds. Hopefully, this is temporary and performance will be improved in the coming months.
Related: Collecting Time Series Data with Predix (a Golang API Wrapper Included)
About the author: Ilya Drabenia is a Technical Lead at Altoros. He has broad experience in building software architectures, including design and development of complex solutions. Ilya is passionate about microservices, domain-driven design, as well as scalable and parallel algorithms. He also holds an MSc degree in Computer Science. See his profile on GitHub.
For more IoT and GE Predix posts, subscribe to our blog or follow @altoros.