What is Node-RED? A beginner’s guide

Dzinaishe Mpini
4 min readJan 19, 2023

--

Node-RED

Simply put Node-RED is a general purpose IoT programming tool for connecting together hardware (mostly IOT) devices and online services (APIs included) together (Lea, 2016). Its goal is to simplify the wiring together of hardware and online services through visual programming in which one can connect predefined code blocks (nodes) to perform a task. These nodes include input nodes and output nodes and when wired together they form flows.

It’s a browser based editor that makes it easy to wire together the hardware and online services flows using the range of provided nodes in the palette. It is built on NodeJS, a lightweight JavaScript runtime for building fast and scalable applications. Furthermore NodeJS is event driven hence making Node RED ideal for low code programming of event driven applications (Node-RED, 2021).

Node RED was originally an IBM open source project. IBM kickstarted it in 2013 so as to be able to see their need of connecting hardware devices to online and software services (O’Leary, 2019). Since then it has grown to become a general purposes IoT programming tool with a significant user base and community.

Why Node-RED?

The straight answer to that is Node-RED simplifies wiring together IoT hardware devices and online services and Node RED allows us to do that.

And why not just try to link these things though other means?

Visual programming: For those with limited programming knowledge, when trying to figure logic in applications, Node Red negates the need for programming knowledge as it provides some boilerplate code that you normally need. You do not have to write any code

Rapid prototyping: Node-RED allows you to quickly prototype IoT project ideas manipulating the logic without having to do large chunks of work.

Installing Node-RED

There are a number of different methods to install Node RED and you can catch them on the official documentation here

But I prefer installing from git and that’s the method I will demonstrate in this article.

To install you will need Node.js. For Node-RED 2.x or earlier you need Node.js 12.x or earlier.

  1. Install grunt-cli if you don’t have it

npm install -g grunt-cli

2. Navigate into the directory you wish to install Node RED

cd <path-with-you-wish-to-install-node-in>

3. Clone the repository

git clone https://github.com/node-red/node-red.git

4. Install node models

npm install

5. Build Node-RED

grunt build

6. Runing Node-RED

npm start

7. Copy and paste link in browser

Now check the debug info from your command line interface that specifies the link your Node-RED application is running from. Copy that link and paste it in the browser.

Kick starting a Node-RED project

I am going to demonstrate how Node-RED works through a simple flow that makes an API call to find out the weather in Gweru using open-meteo.com.

I assume you have carried out steps in the installing Node RED steps. In case you had closed the terminal or shut down your computer you only need to repost the last 2 steps. That’s

  1. Navigating into Node-RED directory and running it

cd <path-to-folder-with-node-red-project>

npm start

2. Then copy the link onto your browser

Now here is a bit of information on the screen you are facing;

On your left is the palettes which contains the nodes available for use

On the centre you are facing the workspace. This is where you create your flows. You can have multiple tabs each for your different flows you are currently working on

The sidebar on the right shows the information about your flows, nodes and or the debug window

  1. Now in the browser, from the nodes palette on your left, pick the “Inject” node and drop it on the work space. The Inject node initiates a flow in the app. You can rename it to whatever you want
  2. Next pick the “http request” node from the palette and place it in the work area. From properties rename it to whatever you want and paste the following link: https://api.open-meteo.com/v1/forecast?latitude=-19.452822975582382&longitude=29.815742336544513&current_weather=true
  3. Then pick the “debug” node. Rename it to whatever you want
  4. Finally join these node. In the end you should have something as shown below
Node RED project

5. Now click on the Deploy button. Its red in colour and found on the top right of the screen. This will update with all the flow you have specified so far.

6. Then click on the debug icon (looks like a bug) which is just below the Deploy button. This will help you see all the debug results.

7. Finally click on the button on the “Inject” node. This will result in something displayed on the right results pane .

You can check more advanced usage scenarios and flows from from https://flows.nodered.org/

References

Lea, R. (2019) Node-red: Lecture 1 — a brief introduction to node-red, Node RED Programming Guide. Available at: https://noderedguide.com/nr-lecture-1/ (Accessed: January 9, 2023).

O’Leary, N. (2019) Introducing Node-RED 1.0, IBM developer. Available at: https://developer.ibm.com/blogs/introducing-node-red-version-1-0/ (Accessed: January 9, 2023).

Node-RED (2022) Node-RED. Available at: https://nodered.org/ (Accessed: January 9, 2023).

--

--