In this article, we will learn about Node-RED and its importance to the Internet of Things. It was developed in the year of 2013 by IBM Emerging Technology- Nick O’Leary and Dave Conway-Jones. The Node-RED is a visual tool that provides a web-based flow editor that can be used to create JavaScript functions.
So what is Node-RED, and what is the link to IoT?
In 2013, IBM developed this project as an open-source, to connect the hardware and devices to web-based services and software. In this way, the IoT devices are connected and control the real world. The Node-RED is a simple “wiring” of nodes or predefined code blocks to perform the tasks. One happy news is that it doesn’t need huge blocks of codes. No need to waste time running the code. It is a flow-based development tool in which the runtime is built on Node.js. The flows created are stored in JSON. By storing in JSON, we can share, import and export to the real world. An online flow library allows you to share your best flows with the world.
Node-RED Projects
Node-RED | A Visual tool for wiring the Internet of Things |
Node-RED Dashboard | A dashboard UI for Node-RED |
Node generator | Command line tool to generate Node-RED node document and function node’s source. |
Node-RED Command Line Tool | Command-line tool allows you to remotely administer a Node-RED instance. |
Installing Node-RED
The Node-RED can install on windows, on a device like Raspberry Pi, Arduino, Android, and BeagleBone Black. You must be having Node.js in your system. We recommend the use of Node.js LTS 8.x. Users of Node.js 6.x and 4.x should ensure they have the latest updates. Node-RED no longer supports Node.js 0.12.x or 0.10.x
For more information, Click here.
The Connected Nodes and the Flow
The connected nodes consists of the input nodes, the processing nodes, and the output nodes.
Input nodes: It allows you to enter the input data into the flow. They have a grey square on their right side which you can connect to the other nodes. By connecting this node to another node, you can send the input data. You can also connect services like Twitter, Google, serial, web sockets and send those data as inputs to the other nodes. Or else you can manually enter the input data using the node called “inject”.
Output nodes: It allows you to send the data to the outside world, to other services for example twitter. It has a grey square on their left side which they can be connected to either input node or function. If you don’t want to send the data to any services like Twitter or email nodes, you can simply debug those messages by using the tab “deploy” on the top right corner of the editor.
Processing nodes: The processing nodes are used to process the data in which they have one input endpoint and one or more output endpoints. They are used to transform the data types, to write the custom codes and to trigger a message.
The examples of the connected nodes:
- Input nodes: inject, catch, status,
mqtt , etc - Processing nodes: comment, delay, function, switch, change, etc
- Output nodes: debug, link,
tcp ,udp ,websocket ,http request, etc
Hello World – the first flow
The above image depicts an example of a simple flow of “Hello World”. I have signed up a free account using the Sensetecnic FRED cloud service. For more information, Click here.
So coming to the flow, on the left side of the image you can see the input nodes, the output nodes, and the function. Select an input node, in my case I have chosen the “inject node”, drag and place in the center of the workflow. Doubleclick on the node and chose the String option in the drop-down list and enter “Hello World”. On the Topic tab, enter you desired name. I have given as “iot4beginners” in the tab. Since I am not using any processing nodes here, I am directly using the output node.
I have used the debug node and connected with the inject node. Then I have clicked the tab Deploy on the top right corner to deploy the message “Hello World”. The message will be displayed in the sidebar debug. the deploy button is used when a flow has been constructed and ready to be given to the outside world. It will be deployed on the Node-RED system and executed.
Basic Node-RED structure
msg = { payload:”message payload” };
Various Examples of the Node-RED
The Node-RED can be used in weather reports or alerts, sending TCP requests, using Twitter or other social services to control Raspberry Pi, alerts when you are falling off a schedule, etc.