Running Node-RED on a BeagleBone board

Install

If you want the latest Node-RED 1.x, then you’ll need to use the Debian (10) Buster image from beagleboard.org – and then fully upgrade to the latest version.

sudo apt update && sudo apt full-upgrade

Currently, Debian (10) Buster is only available as an SD card image.If you wish to flash the image to eMMC, edit the file /boot/uEnv.txt and uncomment this line

cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh

The image can then be flashed to the eMMC like any “flash” image on the BeagleBoard website. To do this, insert the SD card with the BeagleBone powered off, hold down the S2 button and power on. Once the LED starts flashing, release the button. Flashing will take 5 to 25 minutes. The BeagleBone will power down at the end of this process, the SD card can be removed and the BeagleBone will now boot from the eMMC.

All 4GB images of BeagleBone boards come with Node-RED pre-installed and set up to start automatically, so all you have to do is launch a browser and point it to your BeagleBone port 1880.

The 2GB console version of BBB suitable for flashing older eMMC versions is not recommended, but can be installed by following the manual installation instructions below.

running

View Node-RED logs

sudo journalctl -f -u node-red -o cat

Stop Node-RED

sudo service node-red stop

Start Node-RED

sudo service node-red start

Set Node-RED to start automatically on every boot

sudo systemctl enable node-red.service

Also prevent it from running automatically on startup

sudo systemctl disable node-red.service

upgrade

The latest Debian images already have Node-RED and Node.js installed – the easiest way to upgrade is to use the built-in upgrade tool:

sudo apt update

sudo apt upgrade nodejs bb-node-red-installer

This should also restart the Node-RED service – but you will need to refresh all open browser sessions.

If you are using the 2017 Debian 9.2 version, you may need to run sudo apt full-upgrade first.

Note: Do not use the Raspberry Pi/Debian upgrade script (update-nodejs-and-nodered) as it will reinstall Node.js and Node-RED in different locations and will conflict with and break existing systemd configuration files.

Configuration

The Beaglebone is configured by default to run Node-RED as root. Therefore the configuration files are located in the /root/.node-red directory and you need root permissions (sudo) to edit them. For example, this is where you need to edit the settings.js file.

Beaglebone also has a systemd service, /lib/systemd/system/node-red.socket which automatically starts Node-RED when it sees a connection attempt. By default this is port 1880 – but if you want to change it you need to change it here as well as in the settings.js file.

Beaglebone specific nodes

There are some Beaglebone specific nodes that give you direct access to I/O pins in the simplest way. The easiest way to install them is directly from npm.

To install manually, run the following command:

sudo npm install -g –unsafe-perm beaglebone-io johnny-five node-red-contrib-gpio

Palavras-chave: gateway industrial

Contactar-nos