Cisco : Getting to “Hello, World” with the Low-Code Platform, Node-RED
In 1980, if I told you that you could program without writing code, you would have thought I was insane. But hello, it is 2022 now. The low-code/no-code revolution is real, and it’s time we all put it to work. Today I want to talk about how one low-code platform, Node-RED, is revolutionizing the job of programming Internet of Things services and devices.
Node-RED is a low-code, open source, browser-based programming platform which lets you create logical flows by connecting different Node-RED nodes (functional blocks) together.
I started my journey with Node-RED after stumbling upon some great IoT and home automation projects that use Node-RED running on a Raspberry Pi. One of my favorites was a home security project: The creator set up a camera in his home to detect people (intruders) and send off an alarm when it senses something. He built the machine learning application using TensorFlow.js and Node-RED. It was not as complicated as you might think. Node-RED makes assembling an IoT application like this very straightforward.
That’s one real benefit of a low-code platform like Node-RED: You can just drag and drop blocks of functions and connect them together graphically to create your applications. Just as importantly, the power of this platform is its capability to host and control myriad protocols, for various hardware and software modules, and to weave them together as needed to create something bigger. And all this along with making it simple to visualize the programmatic flow on a single screen.
Node-RED’s building blocks
Inside Node-RED’s graphical interface, a “node” is a well-defined, self-contained piece of functionality which allows you to set its properties. Nodes are given some data upon which they work; their output is a message in the form of a JavaScript object. You connect nodes together to form your code flow. In simple terms, it lets you draw your code in the form of a flow.
Each node is an independent function which can be connected to other nodes to form an application. You create programs by connecting these nodes. The nodes handle a lot of the mechanics. For example, to summon an API in your code, you do not have to know the HTTP libraries or web services. All you need is the node function for the HTTP service, and to connect it to your flow.
The best part about Node-RED is that it abstracts the underlying code to give the developer a high-level view of what the Node can do. But it is not a complete black box! Anyone can publish their own nodes or work with node authors to add desired features to one. Node-RED has over 3,000 nodes in its inventory today, and the inventory is growing. There is also a supportive developer community to help you when you are stuck.
Hands-on: Let’s build something
Installing and setup for Node-RED is simple. But it’s a rich system and there is a learning curve to it.
This blog post will point you to the initial installation steps, where to go after that, and then on to creating your first basic Node-RED flow. Let’s get started!
Pre-requisites
We are going to install Node-RED on a local system. Before installing, make sure you have Node.js and npm (a package manager for Node JavaScript programs) installed in your system. You can check this by running command `node -v` in your terminal. It should print the node version if already installed in your system. If not, then you can download the latest version from nodejs.org.
Installation
You can find your OS/platform specific install instructions on the Node-RED Getting Started page. Node-RED can run on a local PC or Mac, a device like a Raspberry Pi, in a container on a server you control, or on a cloud service. I am assuming you will install it on a local system, like a PC.
Once it’s installed, start the program by typing `node-RED` in the terminal. Node-RED uses port 1880 by default. So, once it’s up and running, open a browser tab on the same computer and go to `http://localhost:1880 `. That will open up the Node-RED graphical user interface (GUI)
The Node-RED Cheat Sheet
Here’s a map to quickly identify the tools and components which you will see in the GUI.