IoT with Node-Red
How to manage heterogeneous hardware and software environments? How to stay away from the cloud and use a local server? Node-RED provides an elegant solution to merge different IoT devices and services, and stay within a local area network.
Node-RED is based on a graphical interface and rely on three main concepts.
|
The Node-RED GUI consists on three parts, from left to right:
|
The Flow
The flow has three parts, from left to right:
|
|
|
Let's detail each part.
Left, the function checks the incoming message comes from the humidity sensor, reads and sends the value of the thermometer, as the humidity sensor provides both relative humidity and temperature measures. Right, the function reads the temperature from the incoming message and sets the payload to the measure. |
Node-RED offers native support for other services. For example, there is a node for sending e-mails.
Node-RED relies on MQTT, which requires a TCP/IP stack. My first idea was to use a bridge to translate incoming data flows from BLE to MQTT, and to outgoing command flows from MQTT to BLE. Unfortunately, I haven't found an adequate one. Similar question applies to the CC1350 SensorTag, which relies on sub-1 GHz radio. |
The Message
The message is formatted with JSON or JavaScript Object Notation. Note the message includes a time stamp in epoch format.
|
The added green Debug node displays the content of the message on the right pane, either in compact or expanded form.
|
Solution with Three Devices
The project includes the SensorTag CC2650, a BeagleBone Green Wireless and a Android-powered 7" tablet.
|
Solution with Two Devices for Bluetooth
As an alternative, I removed the separate Node-RED local server and independent tablet and host them both on my laptop.
|
The tablet can still connect to the Node-RED server: just provide the IP address of the laptop. |
I tried a similar approach with BLE on an Android-based tablet.
I followed the instructions from Running Node-RED on Android, added the required additional nodes and copied-pasted the flow I've developed earlier. Unfortunately, the SensorTag node requires the Noble node for BLE, which is not available for Android. |
Solution with Two Devices for WiFi
However, the Android-based tablet can run a MQTT server like mosquitto with WiFi.
MQTT is a lightweight protocol for IoT, based on the publish/subscribe architecture. MQTT requires a TCP/IP stack, hence the use of WiFi. A typical MQTT message consists on a topic and a payload. Node-RED supports MQTT natively, making the implementation very easy. The flow is very similar to the previous one, with the MQTT node as input, the switch node as process, and two text displayed on the dashboard as output. |
mosquitto_pub allows to send a message manually, with
|
|
Advanced Features
The Roadmap to 1.0 gives a clear view of future developments and features. Most promising are the split between the IDE and the runtime.
Access to the IDE can now be secured. This is done with either Username/password based authentication or OAuth/OpenID based authentication. |
Release 0.18 includes very interesting new features.
Among others, Node-RED now includes projects. A project consists on a set of flows, with optional encryption, a list of dependencies and version management. Ir requires the git and ssh-keygen tools. |
Changes can be committed locally or remotely.
However, those features need to be enabled manually on release 0.18. |
Node-RED Desktop
Instead of opening a Terminal window to launch Node-RED through command-line and use a separate browser to access the IDE, the Node-RED Desktop combines both.
The application is available for macOS and Windows and relies on Electron. It also packs ngrok to allow access from internet. Additional nodes are managed within the IDE through the Palette configuration menu. Although still in beta, it is very stable. Support is very responsive and minor issues (ticket #2 and ticket #4) were quickly fixed. I hope next release will include the dashboard as well (ticket #3), for example on a separate tab, to get rid of the external browser. |
|
Electron Node-RED
The Electron Node-RED project offers a similar solution, also based on Electron.
Just run three commands to install it. |
|
However, the editor and the dashboard stay within the same but unique window (ticket #4). Similarly, some basic features, like copy-paste, do not work properly (ticket #3).
Once configured, the Electron Node-RED can be turned into an stand-alone application using Electron Packager. |
|
Conclusion
I really like the way Node-RED manages heterogenous hardware and software environments, and offers great flexibility.
The same laptop runs the server and displays the dashboard, or separate BeagleBone Green Wireless runs the server and an independent tablet displays the dashboard. Node-RED is actively developed with a clear Roadmap to 1.0. Similarly, the documentation has been updated with a fresher look. More importantly, the whole configuration stays within the local area network. |
Pros
|
Cons
|
Wrap-Up
|
Posted: 16 Mar 2017
Updated: 17 Mar 2017; 13 Sep 2017; 27 Feb 2018 ; 28 May 2019 ; 19 Aug 2019
Updated: 17 Mar 2017; 13 Sep 2017; 27 Feb 2018 ; 28 May 2019 ; 19 Aug 2019