Node-RED is a development tool installed by default on the Raspbian distribution, the official Linux distribution of the Raspberry Pi. If you have decided to run your Orange Pi under Armbian, here’s how to install Node-RED. For this article, I installed Node-RED on Armbian and an Orange Pi Lite (Wi-Fi version).
Install Node-RED on Armbian
Installing Node-RED is now much easier with the installation script. Initially intended for the Raspbian distribution of the Raspberry Pi, it works perfectly on the Armbian distribution of Orange Pi. Log in SSH or open a Terminal and run the installation script by executing this command. The operation lasts about 15 minutes.
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
This can take 20-30 minutes on a Pi 1 - please wait. Stop Node-RED ✔ Remove old version of Node-RED ✔ Remove old version of node.js ✔ Install node.js for Armv6 ✔ Node v6.11.0 Npm 3.10.10 Clean npm cache ✔ Install Node-RED core ✔ 0.16.2 Install extra nodes ✔ Install serialport node ✔ Npm rebuild existing nodes ✔ Add menu shortcut ✔ Update systemd script ✔ Update update 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 Thu 22 Jun 14:42:28 UTC 2017 - Finished Thu 22 Jun 15:00:14 UTC 2017
Start Node-RED on startup with PM2
There are several ways to start NR automatically on Mac (or Windows). Here I suggest you use PM2, a process manager for Node.js. The advantage is that this solution works on all platforms. Convenient, if you ever have the urge to develop on Raspberry Pi.
sudo npm install -g pm2
If you no longer know the Node-RED path, run this command
which node-red
On macOS, it should be in /usr/local/bin/node-red .
To run NodeRED, run this command PM2
pm2 start /usr/local/bin/node-red -- -v
The configuration is saved and automatic start is activated
pm2 save pm2 startup
A short video to see how to do
Installing Node-RED on Armbian – Depreciated method
The installation of Node-RED on Orange Pi (or Raspberry Pi) is different from other Linux distributions (how to install on Ubuntu 16.04 LTS) since it will have to install everything from the sources. Here’s how to do it step by step.
We start by doing some housekeeping in the package manager
sudo apt-get remove -y nodered nodejs nodejs-legacy npm sudo apt-get autoremove -y
Then we install Node-RED from the source code
curl -sL https://deb.nodesource.com/setup_4.x | sudo bash -
Now the necessary dependencies: Node.js, Python, Build
sudo apt-get install -y build-essential python-dev nodejs
Before going any further, we can check the installed versions
$ npm -v 2.15.11
$ node -v v4.6.2
This complies with the Node-RED specifications (here).
Clean the npm cache and run the Node-RED installation. Attention, it is quite long, several minutes on an Orange Pi Lite because everything must be compiled for the ARM processor (Allwinner H3 @ 1,2GHz). I encountered a crash during this stage. I just restarted the command after reboot.
sudo npm cache clean sudo npm install -g --unsafe-perm node-red
Finally we install the scripts that will start and stop Node-RED
sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/nodered.service -O /lib/systemd/system/nodered.service sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-stop -O /usr/bin/node-red-stop sudo wget https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/node-red-start -O /usr/bin/node-red-start
All you have to do is activate the Node-RED service to enable it to start when Armbian starts.
sudo sed -i -e 's#=pi#=orangepi#g' /lib/systemd/system/nodered.service sudo chmod +x /usr/bin/node-red-st* sudo systemctl daemon-reload
It only remains to create the directory of operation of Node-RED.
mkdir .node-red cd .node-red
You can add the node-red-admin module.
sudo npm install -g node-red-admin
Here is a list of articles to go further with Node-RED
- Xiaomi Mijia Honeywell Smoke Detector Test with Domoticz, Emergency Notification with PushOver
- Test Zigbee2MQTT gateway. Part 2, include Xiaomi Aqara or Mijia accessories to Domoticz with Node-RED
- #Test Zigbee2MQTT project, hack of the Xiaomo Aqara Smart Home Gateway. Part 1: assembly, demo with Node-RED, 3D printed case [update]
- Install Node-RED on Raspbian Jessie Lite on a Raspberry Pi Zero W
- Node-RED + MQTT + ESP8266: how to drive an articulated PTZ system in WiFi
- Orange Pi: test of the OPI.GPIO package for Node-Red (node-red-contrib-opi-gpio)
- Orange Pi (Armbian): replace the GPIO by an Arduino/Firmata, Node-RED and Johnny-Five
- Use Node-RED to create a gateway between MySensors and Blynk (local server)
- Getting start with MQTT Mosquitto Broker on Raspberry Pi, Windows, macOS and Linux [update]
- ESP Easy + MQTT + Node-RED: bi-directional communication, dashboard
- Dashboard for IoT with Node-RED. Part 2: Gauges, Graphs, Notifications, HTML
- Secure Node-RED with Nginx and OpenSSL on Ubuntu 16.04
- Node-RED: installation and configuration on Ubuntu 16.04 LTS
- Node-RED (Tutorial): saving MySensors measurements on InfluxDB
- Create a dashboard for IoT with Node-RED. Part 1: button, list, switch, slider, form, input field
- Node-RED: install, uninstall easely modules with Palette Manager
- MySensors v2: decode/send messages with Node-RED
- Node-RED: How to integrate a connected object developed with MySensors v2 library
- Installing Node-RED on macOS or Windows, auto startup with PM2
- Getting start with Node-Red: Installation and discovery on Raspberry Pi 3 (or 2)
Source:
The installation procedure proposed in this tutorial is extracted from the installation script developed by Brian Weet https://gist.github.com/brianweet/a055f344f57cd485dc8b91cd18523002
Updates:
[06/28/2017] – installation using bash script
- Install Home Assistant (HASS) on an Orange Pi running under Armbian
- IoT development based on Orange Pi, Arduino (Firmata), Nodejs, Blynk and Johnny-Five
- Blynk + Node.js + Johnny-Five: drive a Pan-Tilt PTZ SG90 kit on Orange Pi with an Arduino / Firmata
- Start programming with Node Js and Johnny-Five: IoT and robotics based on Arduino, Raspberry Pi, Orange Pi
- Orange Pi: test of the OPI.GPIO package for Node-Red (node-red-contrib-opi-gpio)
- Orange Pi (Armbian): replace the GPIO by an Arduino/Firmata, Node-RED and Johnny-Five
Yeah, but no. Didn’t work for me.
Hello Asterion. Can you give us more information about your configuration and versions (armbian, nodejs…). Thank’s
Armbian debian server from:
https://dl.armbian.com/orangepizero/Debian_jessie_default.7z
apt-get would fail when attempting to install nodejs so I used the binary install from:
https://nodejs.org/dist/v6.11.0/node-v6.11.0-linux-armv7l.tar.xz
Downloaded node-red then the usual way through npm.
Runs fine from command line.
So, I will have to look at the service scripts I assume? They might need tweaking.
Error reported when using systemctrl start nodered.service is:
? nodered.service – Node-RED graphical event wiring tool.
Loaded: loaded (/lib/systemd/system/nodered.service; disabled)
Active: failed (Result: start-limit) since Wed 2017-06-14 09:34:56 CEST; 2s ago
Docs: http://nodered.org/docs/hardware/raspberrypi.html
Process: 1366 ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS (code=exited, status=217/USER)
Main PID: 1366 (code=exited, status=217/USER)
Jun 14 09:34:55 house systemd[1]: Unit nodered.service entered failed state.
Jun 14 09:34:56 house systemd[1]: nodered.service holdoff time over, schedu…t.
Jun 14 09:34:56 house systemd[1]: Stopping Node-RED graphical event wiring …..
Jun 14 09:34:56 house systemd[1]: Starting Node-RED graphical event wiring …..
Jun 14 09:34:56 house systemd[1]: nodered.service start request repeated to…t.
Jun 14 09:34:56 house systemd[1]: Failed to start Node-RED graphical event …..
Jun 14 09:34:56 house systemd[1]: Unit nodered.service entered failed state.
Ok. Can you give me the npm and node versions please. Did you try to follow the steps of the tutorial before? You must also install build-essential and python-dev
Okay, I spotted one problem caused by the block copying of the service commands above, for the node-red-start script the wget finishes silently but was not copying the file to /usr/bin as it had random characters in URL and file name (substituting spaces). I tidied that up.
However, error message is now:
? nodered.service – Node-RED graphical event wiring tool.
Loaded: loaded (/lib/systemd/system/nodered.service; disabled)
Active: failed (Result: start-limit) since Wed 2017-06-14 13:54:19 CEST; 5s ago
Docs: http://nodered.org/docs/hardware/raspberrypi.html
Process: 2737 ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS (code=exited, status=217/USER)
Main PID: 2737 (code=exited, status=217/USER)
Jun 14 13:54:18 house systemd[1]: Unit nodered.service entered failed state.
Jun 14 13:54:19 house systemd[1]: nodered.service holdoff time over, scheduling restart.
Jun 14 13:54:19 house systemd[1]: Stopping Node-RED graphical event wiring tool….
Jun 14 13:54:19 house systemd[1]: Starting Node-RED graphical event wiring tool….
Jun 14 13:54:19 house systemd[1]: nodered.service start request repeated too quickly, refusing to start.
Jun 14 13:54:19 house systemd[1]: Failed to start Node-RED graphical event wiring tool..
Jun 14 13:54:19 house systemd[1]: Unit nodered.service entered failed state.
Nope, added build-essential an python-dev, reinstalled node-red. Still same problem. I also noted the step to create .node-red with mkdir is not necessary as it is created by the build. As for below, it looks like this post is out of date given the movement in npm and node versions.
Well, I have to re-install with the latest versions of npm and nodejs. On the other hand, everything works very well with the versions indicated in the article. I made several tutorials with this configuration. As soon as I have a little time, I update the article. If you find the solution before me, do not hesitate to contact me. Thank you very much.
Cheers. I will keep at it.
SOLVED. I just used PM2 as suggested from node-red site.
What got me going was the following (from root):
npm install -g pm2
whereis node-red
node-red: /usr/local/bin/node-red
pm2 start /usr/local/bin/node-red –node-args=”–max-old-space-size=128″ — -v
pm2 save
pm2 startup
export PM2_HOME=”/root/.pm2″ # because I installed in root otherwise PM2_HOME=”/root/{user}/.pm2″
reboot #takes a while after rebooting but it should come up
Hi Asterion. I just updated the article. I used the new install script to install Node-RED. It works like a charm. He takes care of everything. Like you, I installed PM2 to automatically launch Node-RED at startup. It’s much simpler. Everything is done in 15 ‘on my Orange Pi Lite! See you soon i hope. Christophe
npm -v
3.10.10
node -v
6.11.0
On my orange pi zero or PM2 I had to use this syntax:
pm2 start node-red
then the save and the the startup command. Followed by the additional command PM2 spat out which in my case was:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi –hp /home/pi