How To: Install Node-Red on a Raspberry Pi

For this project I began with a brand new Raspberry Pi with a fresh Raspbian install.   See “Setting up your new Raspberry Pi”.

Although Node-RED and node.js comes delivered standard on the Raspbian NOOB SD Card operating system, I decided to uninstall and reinstall the most current versions of tbese systems.   To do so is recommended on the Node-RED website.

To uninstall and reinstall, enter the following command in your terminal session:

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

This process will take roughly 15 minutes to complete.   Note: Once you have used this script to upgrade, then you cannot use apt-get to upgrade the pre-installed version of Node-RED.  To update Node-RED you will need to use the following command:

update-nodejs-and-nodered

To start Node-RED, enter the following command in the terminal window of a SSH connected device:

node-red-start

Note: closing the window (or ctrl-c) does not stop Node-RED running. It will continue running in the background.

To stop Node-RED, run the command

node-red-stop

To see the log, run the command

node-red-log

Edit configuration file to set up User ID/Password

cd ~/.node-red
sudo npm install -g node-red-admin
node-red-admin hash-pw

Enter password and <enter>.   An encrypted hash value will be provided.   This value will need to be entered in the file called settings.js.   Edit this file now by entering the following command:

sudo nano ~/.node-red/settings.js

Make the following changes to this file by uncommenting and changing the following:

 // Securing Node-RED
 // -----------------
 // To password protect the Node-RED editor and admin API, the following 
 // property can be used. See http://nodered.org/docs/security.html for details.
adminAuth: {
 type: "credentials",
 users: [{
 username: "paul",
 password: " <paste the hash string received earlier here > ",
 permissions: "*"
 }]
 },
 // To password protect the node-defined HTTP endpoints (httpNodeRoot), or
 // the static content (httpStatic), the following properties can be used.
 // The pass field is a bcrypt hash of the password.
 // See http://nodered.org/docs/security.html#generating-the-password-hash
 httpNodeAuth: {user:"paul",pass:" <paste the hash string received earlier here > "},
 //httpStaticAuth: {user:"user",pass:"$2a$08$zZ blah blah"},

I used the following command to cause Node-RED to run when the Pi boots up:

sudo systemctl enable nodered.service

 

Steps for installing SQLite:

The following command is used to install sqlite DBMS system.  The ‘npm install” step takes a considerable amount of time to complete.   Be patient.

cd ~/.node-red
npm install node-red-node-sqlite

Steps for installing zwave:

Install libudev
sudo apt-get update
sudo apt-get install libudev-dev -y
Install open-zwave
 
cd ~
git clone https://github.com/OpenZWave/open-zwave.git
cd open-zwave/
sudo git fetch
sudo make -j 4
sudo make install
Check that ozw is installed correctly by running example program
 
cd open-zwave
./MinOZW
Update the Environment Variable and add to /etc/environment
export LD_LIBRARY_PATH=/usr/local/lib
sudo sed -i '$a LD_LIBRARY_PATH=/usr/local/lib' /etc/environment
Install openzwave-shared & node-red-contrib-openzwave
npm cache clear
sudo npm install -g openzwave-shared
cd ~/.node-red
npm install node-red-contrib-openzwave

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.