All of us make use of IoT in one way or the other today, and this usage will only grow in the near future. This article details how Node-RED, a powerful and easy-to-use programming platform, helps in implementing IoT and edge computing.
The Internet of Things (IoT) is omnipresent in today’s world. A few fields where it is dominant are listed below.
Smart health and medical services. Smart ambulances, hospital management, intelligent drug control, etc.
Smart cities. Smart traffic control, smart toll plazas, pollution monitoring, water quality management, self-driven cars, drones, law enforcement, energy conservation, etc.
Personal applications. Smart health gadgets, theft avoidance, controlling home appliances, etc.
Retail sector. Automated checkout, logistics monitoring and management, etc.
Agriculture. Analysis of crops, dynamic water distribution, smart irrigation, farm surveillance, drones for smart farming, agriculture robots, etc.
Many other domains, too, are associated with the field of IoT, especially where intelligent robotic applications are being developed. The Internet of Everything (IoE) is another term used for smart applications, and is the integration of IoT with the cloud and the World Wide Web for the real-time connectivity of devices.
A number of programming platforms are available for working with IoT, IoE, fog or edge scenarios. Hundreds of toolkits, which are very powerful and easy to use for dynamic research, are available as well. A few of these are listed in the Table.
|Platforms and toolkits for IoT and edge computing|
|Node-RED||nodered.org||Flow based programming environment|
|Contiki||contiki-os.org||Microcontrollers, IPv6, IPv4, protothreads, low resource, game consoles|
|FlowHub||flowhub.io||Flow based IoT programming|
|Yet another robot platform (YARP)||yarp.it||Robotic programming|
|OROCOS||orocos.org||Robotic programming and machine control|
|OpenIoT||openiot.eu||Sensing as a service (S2aaS)|
|Zetta||zettajs.org||WebSocket programming, real-time on TCP, reactive programming, low overhead scenarios|
|DSA||iot-dsa.org||Real-time interfacing, inter-device communication, programming on multiple layers|
|IoTivity||iotivity.org||Constrained application protocol (CoAP), IoT programming|
|CupCarbon||cupcarbon.com||Smart city, SCI-WSN simulation, visualisation, 2D and 3D OpenStreetMap, MQTT programming, sensor programming|
|KAA||kaaproject.org||Data analytics, real-time applications, dynamic communications and updates|
Node-RED: A tool for flow based programming of IoT scenarios
Node-RED (https://nodered.org) is a powerful and easy-to-use programming platform for the simulation of IoT scenarios. Fog and edge computing can also be done using flow based programming in Node-RED. Here, high performance structures can be implemented using minimum coding.
Installation and working
To work with Node-RED, the Node.js platform should be installed first, which is available at https://nodejs.org for multiple operating systems like Windows, Mac, and Linux for 32-bit or 64-bit architectures (Fig. 1).
After the installation of Node.js, the Node-RED package can be installed from the node package manager (NPM), which is the repository of packages developed and deployed for the Node platform (Fig. 2).
In the installation directory of Node.js, the npm command is used to install Node-RED, as follows:
E:nodejs>npm i node-red
Node-RED can be installed on multiple platforms, including open source hardware devices, IoT devices, the cloud, or on dedicated servers. Its cloud deployment can be done on IBM Cloud, Microsoft Azure, SenseTecnic FRED, and Amazon Web Services. To work with IoT, fog and edge scenarios, it can be installed on Raspberry Pi, BeagleBone Black, or Arduino. These devices support the interfacing of IoT sensors for multiple applications.
To run Node-RED on a dedicated system, the node-red command is executed to start the server. A local host based IP address with port number is generated, on which the programming for IoT, edge computing, etc, is done.
After starting the server, there are thousands of packages that can be interfaced for multiple applications. To create an IoT or edge scenario, packages related to Wi-Fi, Bluetooth, MQTT, CoAP, weather forecasting, etc, can be installed from the NPM repository.
After the required packages are installed, the flow diagram is created using the left palette of icons. Here, all the packages are visible and can be dragged across the dashboard.
The message queueing telemetry transport (MQTT) protocol is available in the Node-RED palette to help it work with IoT. It is used as an IoT broker for real-time interfacing and communication with sensors. An IoT scenario is created by the file handling module, capturing data from sensors and using the MQTT protocol to interface it with Wi-Fi. After running this scenario on a single click, the results are visible on the right side panel of Node-RED. Similar other structures can be created and deployed for dynamic communication with IoT devices.
Researchers and engineers can create IoT scenarios as per their requirements with the customisation and addition of packages on Node-RED.
Node-RED can interface with Raspberry Pi or Arduino to provide real-time communication with sensors, which can be used for smart agriculture based applications so that farmers can keep track of their fields and crops. Weather forecasting and climate analysis can also be done using such programming platforms.
This article first appeared in January 2022 issue of Open Source For You magazine
Dr Gaurav Kumar is associated with various academic research institutes, where he delivers expert lectures and conducts technical workshops on the latest technologies and tools