Introduction
One of the most important factors that limit the development of the IoT(Internet of Things) applications is the lack of comfortable means to develop rules for IoT devices interacting with each other. IBM developed an Open-Source tool called Node-RED to solve this problem, which allows you to develop connected objects and many other things with little computer knowledge.
Node-RED is a powerful tool to build the Internet of Things (IoT) applications that use predefined blocks of code, called nodes, to perform tasks. It uses a visual programming approach, which enables developers to link code blocks together.
This solution is convenient as an intermediate to link devices of different types to one another or to an automation system such as DBMS or cloud etc.
Node-RED runs on Node.js and it has been designed to operate on low performance systems such as
- Raspberry pi
- Arduino
- Docker
- Android
Installation of Node-RED
As said, Node-RED runs based on Node.js. We need to install Node.js in order to install Node-RED.
Go to the following link here, and download the Node.js.
Incase if your other OS user, check this article for more about Node.js.
After downloading, Install the software as you do in normal software.
Once you finished installation, Open Command prompt (Win+R -> cmd) or Search for Cmd in Search bar.
After opening, Copy and paste following from the below to cmd.
npm install -g --unsafe-perm node-red
Meanwhile you can install modules with the command, followed by module name in the last
npm install <module_name>
Here I’m installing the dashboard module which is very familiar.
npm install node-red-dashboard
To start the Node-RED type “node-red” in the command prompt.
After running, you will find an IP address like the above. Copy paste the IP address to your web browser.
There are four sections in Node-RED, They are
- Node Section – Different Nodes.
- Flow Area – To drop the blocks in a flow
- Deploy Button – To deploy the flow
- Debug Tab – Terminal or console of the Node-RED
The menu next to the Deploy button contains some additional tools:
- View: Show / hide the grid.
- Import: Allows you to import nodes.
- Export: You can export to the clipboard to a file
- Flows: You can add a new flow, rename, delete the current flow
Different Nodes
Common Nodes
There are 7 base input and output nodes enabled. It covers simple communication structures likely to be used by IoT applications. It ranges from lower-level network protocols like UDP and TCP to higher level HTTP and MQTT publish / subscribe.
Function Nodes
This section node contains functional blocks which does simple functions.
Storage Nodes
It is used for the devices like the Raspberry Pi and focuses on file based processing.
Raspberry Pi nodes
Raspberry pi nodes are designed to connect Raspberry pi and its functions.
Node-RED’s Hello World program
Here, I used the inject node as a input and debug node as output in debug console.
Here I’m changing the payload of the inject node as String and giving it as ‘Hello World’
After Deploying the flow, click the inject node. On the Debug tab, it displays the output.
OK, now lets make something different.
OpenWeather Example
I will make a flow which displays Weather in London using OpenWeather API
Now double click the HTTP request node to change its operation.
Now Deploy and run, You can see the details in the Debug Console.