Wednesday, November 13, 2024

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages

Using Node-RED For IoT And Edge Computing

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.

- Advertisement -

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.

- Advertisement -

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
Software URL Usage
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
NoFloJS noflojs.org JavaScript based flow programming
Netron github.com/lutzroeder/netron Dynamic visualisation
PyFlow wonderworks-software.github.io/PyFlow Visual scripting
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

Node-RED is a specialised package that is installed onto the Node.js platform. The latter is a lightweight but high performance programming environment based on JavaScript. Many packages are available in Node.js for multiple applications, including Internet of Things (IoT), cloud computing, machine learning, data science, and blockchain.

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).

Fig. 1 Node.js platform for a range of applications
Fig. 1: Node.js platform for a range of applications

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).

Fig. 2: Node-RED platform built on Node.js (Source: nodered.org)
Fig. 2: Node-RED platform built on Node.js (Source: nodered.org)

In the installation directory of Node.js, the npm command is used to install Node-RED, as follows:

E:\>cd nodejs
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.

Fig. 3: Installation options for Node-RED (Source: nodered.org)
Fig. 3: Installation options for Node-RED (Source: nodered.org)

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.

Fig. 4: Starting the Node-RED server
Fig. 4: Starting the Node-RED server
Fig. 5: Searching a Wi-Fi package from the NPM repository
Fig. 5: Searching a Wi-Fi package from the NPM repository

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.

Fig. 6: Creating a flow diagram in Node-RED with Wi-Fi interfacing
Fig. 6: Creating a flow diagram in Node-RED with Wi-Fi interfacing

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.

Fig. 7: Creating an IoT scenario for real-time interfacing with MQTT broker
Fig. 7: Creating an IoT scenario for real-time interfacing with MQTT broker

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

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Electronics News

Truly Innovative Electronics

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics