Tutorial: install Node-RED on Raspberry Pi

The use of Node-RED in home automation

Yesterday, we proceeded to the installation of the broker Mosquitto MQTT on Raspberry Pi. An easy installation which, as we explained to you, will allow us to go further in the daily use of our home automation software. Whether it is Home Assistant, Jeedom, Domoticz or even Homey, another tool can be particularly interesting: Node-RED. So we will in turn install Node-RED on Raspberry Pi.

Node-RED, what is it?

Node-RED is a "low code" programming tool which allows you to connect hardware devices, APIs and online services very easily using a very easy-to-use graphical interface. As the name suggests, it was developed in JavaScript and built on Node.js to run at the edge of the network on low-cost hardware such as the Raspberry Pi, but also in the cloud (at IBM Bluemix, AWS or Microsoft Azure).

Concretely, Node-RED uses a method of graphic programming based on flows allowing program without code, or almost. This is because it uses predefined blocks of code called « node » - node in French - which it suffices to link together to constitute a program. It therefore allows you to very quickly create functional applications, whether or not you are a developer, using simple flows.

“To sum up, you put knots, you tie them together, and voila! "

Like the Homey Flows, the creation of flows Node-RED is very easy, not to say childish, since it is done in drag & drop (drag and drop in French). In short, you put knots, you link them together, and voila! Those who have knowledge of code will obviously be able to go further, but those who do not will still be able to do a number of very interesting things… We will of course come back to this.

Installer Node-RED on Raspberry Pi OS

As you have followed with the greatest attention our previous tutorials of automation DIY, we will assume that you have already installed Raspberry Pi OS, ex-Raspbian, on your nano-computer.

If this is not already the case, we invite you to consult the dedicated tutorial:

TO READ :
Raspberry Pi OS tutorial: installation always easier with Imager

SSH connection

We are going to use a simple terminal under Windows 10. You can obviously do the same under macOS or Linux.

Press Windows + R and type cmd in the command prompt.

In the terminal, enter:

ssh [email protected] (replace the Xs with the IP of your Raspberry Pi)

Installation

To start the installation of Node-RED and its dependencies, just use this little script available on GitHub:

bash <(curl -sL https://raw.githubusercontent.com/node-red / linux-installers / master / deb / update-nodejs-and-nodered)

Validate with the enter key and answer "yes" with "y" to all the questions:

Wait a bit, our Raspberry Pi is not a war lightning, theinstallation of Node-RED takes a few minutes.

When finished, you should see this:

Use Node-RED on Raspberry Pi OS

Automate startup

Let's launch now Node-RED:

node-red-start

Before discovering its interface, since we are going to use Node-RED in home automation, we want it to launch automatically when we start our Raspberry Pi.

To do this, we need this command:

sudo systemctl enable nodered.service

To connect to Node-RED with a browser

Phew, we're done with our terminal and we're now going to use a graphical interface with our favorite browser:

192.168.XX.XXX:1880 (IP of your Raspberry Pi)
Well done ! In addition to running a Mosquitto MQTT broker, your Raspberry Pi now allows you to use Node-RED, a software as simple as powerful which will allow us to create automations galore. Whether for Home Assistant or for Homey Pro, we will soon see how to use it to customize our home automation dashboards. Yep, who has never dreamed of a magnificent dashboards? This will be the program of our next tutorial automation DIY. Stay tuned!
Fascinated by Alexa since the day I received it in beta test, I gradually became passionate about the subject, before deciding to go further by creating a site with Jean-Christophe. An activity that allows me to quench my thirst for new technologies and share my discoveries about the nicest of communities: Les Alexiens.