Book Image

Practical Node-RED Programming

By : Taiji Hagino
5 (1)
Book Image

Practical Node-RED Programming

5 (1)
By: Taiji Hagino

Overview of this book

Node-RED is a free and open source flow-based programming tool used to handle IoT data that allows programmers of any level to interconnect physical I/O, cloud-based systems, databases, and APIs to build web applications without code. Practical Node-RED Programming is a comprehensive introduction for anyone looking to get up to speed with the Node-RED ecosystem in no time. Complete with hands-on tutorials, projects, and self-assessment questions, this easy-to-follow guide will help you to become well versed in the foundations of Node-RED. You’ll learn how to use Node-RED to handle IoT data and build web applications without having to write complex code. Once you’ve covered the basics, you’ll explore various visual programming techniques and find out how to make sample flows as you cover web development, IoT development, and cloud service connections, and finally build useful real-world applications. By the end of this book, you’ll have learned how to use Node-RED to develop a real-world application from scratch, which can then be implemented in your business.
Table of Contents (19 chapters)
Section 1: Node-RED Basics
Section 2: Mastering Node-RED
Section 3: Practical Matters

Node-RED and IoT

Again, Node-RED is a virtual environment that combines hardware devices, APIs, and online services in a revolutionary way on a browser. It provides the following features:

  • Browser-based UI.
  • Works with Node.js and is lightweight.
  • Encapsulates function and can be used as a node (meaning functions are locked in an abstract capsule) .
  • You can create and add your own nodes.
  • Easy access to IBM Cloud services.

In other words, it can be said that this tool is suitable for building IoT-related services, such as data control on devices, and linking edge devices and cloud services. Originally, the development concept of Node-RED was for IoT, so this makes sense.

Now, let's look at the basic structure of IoT so that those who are only vaguely aware of IoT can understand it. It can be said that IoT is basically composed of six layers, as shown in the following diagram:

Figure 1.6 – IoT six layers

Figure 1.6 – IoT six layers

Let's take a look at these in more detail.


The device is a so-called edge device. IoT has various sensors and handles the data that's acquired from them. Since it doesn't make sense to have the data only on the edge device, we need to send that data through the gateway to the network.


This is the network that's required to send the data that's been obtained from the device to a server on the internet. It usually refers to the internet. In addition to the internet, there is also a P2P connection via Bluetooth or serial.


The party that receives and uses the data is the platform. We may also have a database for activating and authenticating things, managing communications, and persisting received data.


This is a layer that analyzes the received data. Broadly speaking, it may be classified as an application. This is the part that prepares the data so that it can be processed into a meaningful form.


An application provides a specific service based on data analysis results. It can be a web or mobile application, or it can be a hardware-specific embedded application. It can be said to be the layer that's used by the end user of the IoT solution.

Now that we have an understanding of IoT, we will examine why Node-RED should be used for it.

Node-RED and IoT

While explaining IoT so far, we've made it clear why Node-RED is suitable for IoT. For example, you can understand why FBP tools that have been developed for IoT survive when used with Node-RED. In particular, the following three points should be taken into account:

  • Since it can be run on edge devices (pre-installed on specific versions of Raspberry Pi OS), it is ideal for data handling at the device layer.
  • Since it can be run on the cloud (provided as a default service in IBM Cloud), it is easy to link with storage and analysis middleware.
  • Since MQTT and HTTP protocols can be covered, it is very easy to exchange data between the edge device and the server processing cloud.

In this way, Node-RED, which largely covers the elements required for IoT, is now used for a wide range of applications, such as web services and chart display, as well as programming for IoT. Also, as of June 2020, if you look at Google Trends for Node-RED, you can see that the number of users is gradually increasing. As such, Node-RED is a very attractive FBP tool:

Figure 1.7 – Google Trends for "Node-RED"

Figure 1.7 – Google Trends for "Node-RED"

A typical edge device that can use Node-RED is Raspberry Pi. Of course, it is possible to use Node-RED on other platforms, but it goes well with Raspberry Pi, which also has a pre-installed version of the OS.

Raspberry Pi OS Supports Node-RED

Node-RED has also been packaged for the Raspberry Pi OS repositories and appears in their list of recommended software. This allows it to be installed using apt-get install Node-RED and includes the Raspberry Pi OS-packaged version of Node.js, but does not include npm. More information can be found at

IBM Cloud is a typical cloud platform that can use Node-RED. Of course, you can use Node-RED on other clouds, but IBM Cloud provides a service that anyone can easily start.

Important Note

Node-RED is available on the IBM Cloud platform as one of its Starter Kits applications in their catalog. It is very easy to start using the flow editor as a web application on IBM Cloud (