This is a quick guide showing how to install Node-RED on a Raspberry Pi. We tested this installation on Raspberry Pi OS (32-bit) and Raspberry Pi OS (64-bit).
Prerequisites
Before proceeding:
- You need a Raspberry Pi board
- You should have a Raspberry Pi running Raspberry Pi OS (32-bit or 64-bit).
- You should be able to establish an SSH connection with your Raspberry Pi.
Installing Node-RED on Raspberry Pi
Having an SSH connection established with your Raspberry Pi, enter the following to install Node-RED:
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
Node-RED is installed by default on the Raspberry Pi OS (32-bit). However, it is recommended to run the previous command to install the required packages and update it to the most recent version. You’ll get a message informing you about this. Press Y and press Enter to accept.
Node-RED is not installed by default on Raspberry Pi OS (64-bit).
Then, you’ll be asked: “Would you like to install Pi-specific nodes?” Press Y and Enter.
It will take a few minutes to install Node-RED. In the end, you should get a similar message on the Terminal window:
Configure Node-RED Settings
After installing, it is recommended to configure initial options and settings. Run the following command:
node-red admin init
- Press Enter to create a Node-RED Settings file on /home/pi/.node-red/settings.js
- Do you want to set up user security? Yes.
- Enter a username and press Enter (you need to remember it later).
- Enter a password and press Enter (you need to remember it later).
- Then, you need to define user permissions. We’ll set full access, make sure the full access option is highlighted in blue and press Enter.
- You can add other users with different permissions if you want. We’ll just create one user for now. You can always add other users later.
- Do you want to enable the Projects feature? No.
- Enter a name for your flows file. Press Enter to select the default name flows.json.
- Provide a passphrase to encrypt your credentials file. Learn more about what is a passphrase.
- Select a theme for the editor. Simply press Enter to select default.
- Press Enter again to select the default text editor.
- Allow Function nodes to load external modules? Yes.
Node-RED configuration was successful. All settings are saved on settings.js.
Start Node-RED
Run the following command to start Node-RED:
node-red-start
You should get a similar message on the Terminal:
Access Node-RED
Node-RED runs on port 1880. To access Node-RED open a browser and type the Raspberry Pi IP address followed by :1880. For example:
192.164.1.106:1880
You’ll get access to the Node-RED login page. Login with the username and password you’ve set previously.
Now, you have access to Node-RED. You can start building your flows.
Autostart Node-RED on boot
To automatically run Node-RED when the Pi boots up, you need to enter the following command. This means that as long as your Raspberry Pi is powered up, Node-RED will be running.
sudo systemctl enable nodered.service
Now, restart your Pi so the autostart takes effect. The next time the Raspberry Pi restarts, Node-RED will be already running.
sudo reboot
If, later on, you want to disable autostart on boot, you can run:
sudo systemctl disable nodered.service
For more information about the installation process, check the official documentation.
Wrapping Up
Congratulations! You successfully installed Node-RED on your Raspberry Pi. Now, you can start building your Home Automation System. Using MQTT with Node-RED is a great option to gather data from several sensor nodes and send commands to actuators. You can also resend your sensor data to InfluxDB and have a history of your data saved on a database.
You may also like reading:
- Install InfluxDB on Raspberry Pi
- ESP32: Getting Started with InfluxDB
- What is MQTT and How It Works
- Install Mosquitto MQTT Broker on Raspberry Pi
Thanks for reading!
Thanks. It works perfectly.
Probably a great article but… what is Node-RED and why we need it (or not). I don’t think mentioning some usefulness of it at the end is the right way. I got it, you have to keep it short and to the point on how to install it. In this case a link to external source would be more than enough.
Hi.
Next week, we’ll be publishing two getting started guides about Node-RED.
Regards,
Sara
hi
i installed v17 nodered, but now i have the following issues? can you help please>
pi@raspberrypi:~ $ node-red-start
bash: node-red-start: command not found
pi@raspberrypi:~ $ sudo apt-get update
Hit:1 https://deb.nodesource.com/node_17.x buster InRelease
Hit:2 https://dl.yarnpkg.com/debian stable InRelease
Hit:3 http://raspbian.raspberrypi.org/raspbian buster InRelease
Hit:4 http://archive.raspberrypi.org/debian buster InRelease
Reading package lists… Done
pi@raspberrypi:~ $ sudo apt-get install –reinstall nodered
Reading package lists… Done
Building dependency tree
Reading state information… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nodered : Depends: npm (>= 5.8)
E: Unable to correct problems, you have held broken packages.
pi@raspberrypi:~ $
Hey Guys, got a problem with this one. I’ have an older version running on a Rpi2b, and just aquired a 3b and planned to use it as a backup. Things have changed since the first one, like Node Red being on node-red 3.2 with the security features, so when I get through the admin init stage, and type node-red-start in the terminal window, I get “bash: node-red-start: command not found”. Not sure where to go with that?
Hi, I tried to install node-red on my Raspberry 5 but I get this warn when I start node-red
31 Mar 12:27:08 – [info] Node-RED version: v3.1.8
31 Mar 12:27:08 – [info] Node.js version: v18.20.0
31 Mar 12:27:08 – [info] Linux 6.6.20+rpt-rpi-v8 arm64 LE
31 Mar 12:27:09 – [info] Loading palette nodes
31 Mar 12:27:10 – [info] Settings file : /home/bruno/.node-red/settings.js
31 Mar 12:27:10 – [info] Context store : ‘default’ [module=memory]
31 Mar 12:27:10 – [info] User directory : /home/bruno/.node-red
31 Mar 12:27:10 – [warn] Projects disabled : editorTheme.projects.enabled=false
31 Mar 12:27:10 – [info] Flows file : /home/bruno/.node-red/start
31 Mar 12:27:10 – [info] Creating new flow file
31 Mar 12:27:10 – [warn] Encrypted credentials not found
31 Mar 12:27:10 – [info] Server now running at http://127.0.0.1:1880/
31 Mar 12:27:10 – [info] Starting flows
31 Mar 12:27:10 – [info] Started flows
I do not understand why it says Encrypted credentials not found. Moreover if I enter the command sudo reboot it seems not to be executed since the green cursor is not followed by the usual bruno@raspberrypi5: However if I type Pi5_IP_address:1880 the node-red dashboard opens Could you help me ? Thanks
Hi, great article thanks.
After a few years it’s time to upgrade nodered, npm etc etc on a raspberrypi 3b.
Do you have any articles on how to do that please?