Node-RED is a programming tool for connecting hardware devices, APIs, and online services in new and interesting ways. It provides a browser-based editor for linking flows using a wide range of nodes in the palette, where the flows can be deployed to its runtime in a single-click.
It was developed using Node.js taking full advantage of event-driven, non-blocking model. It has a light-weight and browser oriented user interface. This light-weight nature makes it ideal to run on low-cost hardware or devices such as Raspberry Pi, BeagleBone Black, and so on, and in the cloud such as Amazon Web Services (AWS), Microsoft Azure, and so on.
The three major features of Node-RED are:
- Browser-based flow editor
- Built on Node.js
- Online flow library for social development
In this blog, we will explain about installing Node-RED on Windows machine.
Download the following from the provided links for your platform:
- Node.js – https://nodejs.org/en/download/current/
- NPM – https://www.npmjs.com/package/npm
- Node-RED – https://nodered.org/
The best and easiest way to install Node.js is to use Node’s Package Manager (NPM).
To install Node.js, perform the following steps:
- Download the latest version of Node.js from the link: https://nodejs.org/en/download/current/
- Install Node.js
- Check the version of Node.js and NPM
Note: If you have already installed Node.js in your system, ensure that you have installed the latest version of it.
To install Node-RED, use the below command:
npm install -g --unsafe-perm node-red
Creating Node-RED Dashboard
To create Node-RED dashboard, use the below command:
npm install node-red-dashboard
To start Node-RED, use the below command:
To enter Node-RED web workflow, copy the local host IP with Port and access via browser.
Understanding Node-RED Components
Before starting Node-RED flow creation process, let us know the name of the components and its uses.
The components of Node-RED are:
- Node library
- Visual Editor: Current Flow
Creating Node-RED Flow with Dashboard
In this section, we are going to create a simple flow with inject and debug nodes to check debug output. The following nodes are used:
- Inject Node (Time stamp) – To inject messages into a flow
- Function Node (Random number) – To generate and pass each message
- Debug Node (Message payload) – To display payload of the message or entire message
- Chart Node – To visualize data in the form of charts
A simple random data generator is used for visualization.
To create a Node-RED flow, perform the following:
- On the left pane, drag the inject (timstamp), function (Random number), debug (msg.payload), and chart nodes and drop it on editor.
- Wire all the nodes as shown in the below diagram:
- Open the inject node and set the time intervals.
- Open the function node and provide the random data generator code as shown in the below diagram:
- Open the chart node and set chart properties such as label names, colors, and so on.
- Deploy the flow and check the debug node.
- On successfully printing msg.payload random numbers, check the visualization dashboard.
Viewing Node-RED Dashboard
On successfully creating the process, check the visualization dashboard for real-time streaming data. A sample line chart dashboard output was created as shown in the below diagram:
In this blog, we discussed about quickly installing Node-RED on Windows and creating Node-RED flow to generate random values so as to create dashboard chart. Similarly, you can also install Node-RED on Linux, Mac OS, and so on, and create some complex flows and data collect from endpoints and Internet of Things (IoT) devices.
- Getting started with Node-RED:
- Getting Started with Node-RED on Raspberry Pi:
This post first appeared on Front-end Code Review & Validation Tools | Treselle Systems, please read the originial post: here