November 06, 2024

Node-Red quick install

Updated 2024-11-06 !

Node-Red(NR) is Flow-based programming for the Internet of Things

This post isn't made as a complete install guide, there are several, just some links to the best information I have found.

The best thing is that even if you don't are a skilled programmer, but like logic flows, you can make really advanced things. It's pre-installed on some Raspberry Pi(RPi) distributions.


Introduction
Node-Red V 4.0 is released, 20 July 2024, and since earlier there are some nice videos at Youtube.

Another good, but old, Youtube tutorial with a twist of MQTT is found here.

The "bricks" of NR is Nodes. Nodes is black-boxes with a certain function with, almost always, an input and output.

Nodes connected together make a flow, and as usual with "Open source" software many people have contributed. In NR there is several prebuilt Nodes and flows.

SignalK have Node-Red as a plugin, which should be used instead !

Installation
In my case NR is installed on a RPi, start with "
sudo apt update", but it could be installed on several other hardware platforms.

If you use RPi and have used a distribution without NR preinstalled I really recommend the installation script which is used both in a new install and for an update.

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

It does a lot of things and can be run again to keep your NR installation updated. In later versions the install will also run 
sudo node-red admin init to add the settings. Check an example setup below.

Start
Continue with command

sudo systemctl enable nodered && sudo systemctl start nodered

which will make NR autostart at power on and failures. Check status with

sudo systemctl status nodered

(After an update just use sudo systemctl restart nodered)

If you just want to start, without an autostart, just use node-red-start.

To check the NR log use 

node-red-log


Update
As said above update of NR is made by the same script as the install. Sometimes Nodes are updated and check this via "Menu => Manage Palette => Nodes" list. 

Access
Once the installation is made, and NR is running, point a browser at

http://your_host:1880/

where "your_host" is the name or IP adress where NR is running. If NR is running on the same device where you use the WEB-browser, change to name localhost or IP 127.0.0.1

The GUI URL, if node-red-dashboard is installed, is


http://your_host:1880/ui/

Test an application
If you would like to start up NR with something simple and useful I have written a post where your Internet speed is measured in selected interval. Or check out how the RPi is running.

Other NR posts
Here you find the other NR posts on this site.

Init


Node-RED Settings File initialisation

Running Node-RED update for user pi at /home/pi on debian


This can take 20-30 minutes on the slower Pi versions - please wait.


  Stop Node-RED                      

  Remove old version of Node-RED     

  Remove old version of Node.js          

  Install Node 20.18.0-1nodesource1     v20.18.0   Npm 10.8.2

  Clean npm cache                    

  Install Node-RED core                 4.0.5

  Move global nodes to local          -

  Npm rebuild existing nodes         

  Install extra Pi nodes              -

  Add shortcut commands              

  Update systemd script                                                     


Any errors will be logged to   /var/log/nodered-install.log

All done.

You can now start Node-RED with the command  node-red-start

  or using the icon under   Menu / Programming / Node-RED

Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880


Started :  Mon 11 Nov 16:18:22 CET 2024 

Finished:  Mon 11 Nov 16:22:18 CET 2024

 

**********************************************************************************

 ### WARNING ###

 DO NOT EXPOSE NODE-RED TO THE OPEN INTERNET WITHOUT SECURING IT FIRST

 

 Even if your Node-RED doesn't have anything valuable, (automated) attacks will

 happen and could provide a foothold in your local network

 

 Follow the guide at https://nodered.org/docs/user-guide/runtime/securing-node-red

 to setup security.

 

 ### ADDITIONAL RECOMMENDATIONS ###

  - Remove the /etc/sudoers.d/010_pi-nopasswd file to require entering your password

    when performing any sudo/root commands:

 

      sudo rm -f /etc/sudoers.d/010_pi-nopasswd

 

  - You can customise the initial settings by running:

 

      node-red admin init

 

  - After running Node-RED for the first time, change the ownership of the settings

    file to 'root' to prevent unauthorised changes:

 

      sudo chown root:root ~/.node-red/settings.js

 

**********************************************************************************

 

Node-RED Settings File initialisation

=====================================

This tool will help you create a Node-RED settings file.


Settings file · /home/pi/.node-red/settings.js


User Security

=============

Do you want to setup user security? · No


Projects

========

The Projects feature allows you to version control your flow using a local git repository.


Do you want to enable the Projects feature? · No


Flow File settings

==================

Enter a name for your flows file · flows.json

Provide a passphrase to encrypt your credentials file · 


Editor settings

===============

Select a theme for the editor. To use any theme other than "default", you will need to install @node-red-contrib-themes/theme-collection in your Node-RED user directory. · default

Select the text editor component to use in the Node-RED Editor · monaco (default)


Node settings

=============

Allow Function nodes to load external modules? (functionExternalModules) · Yes


Settings file written to /home/pi/.node-red/settings.js

No comments:

Post a Comment

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !