BeagleBone Black

The BeagleBoneBlack already has Node.js baked into it’s OS, so some of these tips are optional.

Note: we are soon deprecating Node v0.8 support - these instructions only apply to the Debian versions of BeagleBoneBlack.

Upgrading Node.js (Optional)

You need Node.js v0.10.x which should be installed by default on the BBB so this step is optional. To update Node.js on BBB - checkout the instructions halfway down this page

In particular the lines about adding an updated repo to /etc/apt/sources.list

sudo sh -c "echo 'deb [arch=armhf] wheezy main' >> /etc/apt/sources.list"
sudo sh -c "echo '#deb-src [arch=armhf] wheezy main' >> /etc/apt/sources.list"

Then update the packages

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install npm --reinstall

Before you start

Make sure the local time is set correctly. The Beaglebone Black does not have a battery backed real time clock so needs to be set on every boot in order for software certificates date checks to be valid.

ntpdate -b -s -u

Installing Node-RED

The easiest way to install Node-RED is to use node’s package manager, npm:

sudo npm install -g --unsafe-perm  node-red

Note: the reason for using the --unsafe-perm option is that when node-gyp tries to recompile any native libraries it tries to do so as a “nobody” user and often fails to get access to certain directories. This causes alarming warnings that look like errors… but only sometimes are errors. Allowing node-gyp to run as root using this flag avoids this - or rather shows up any real errors instead.

For alternative install options, see the main installation instructions.

BBB specific nodes

There are some BBB specific nodes now available in our node-red-nodes project on Github.

These give you direct access to the I/O pins in the simplest possible manner. The easiest way to install them is direct from npm

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

Starting Node-RED

Due to the constrained memory available on the BBB, it is advisable to run Node-RED with the node-red-pi command. For details and other options such as auto-starting on boot, follow the Running Node-RED instructions.

Using the Editor

Once Node-RED is started, assuming you haven’t changed the hostname, point a browser to http://beaglebone.local:1880.

First Flow - Hello World

To run a “hello world” flow that toggles the USR2 and USR3 LEDs, copy the following flow and paste it into the Import Nodes dialog (Import From - Clipboard in the dropdown menu, or Ctrl-I). After clicking okay, click in the workspace to place the new nodes.


Click the deploy button and the flow should start running. The USR2 and USR3 LEDs can be manually set on or off using the Inject node buttons.

Advanced functions

For experts, the bonescript module can be made available for use in Function nodes.

To do this, update settings.js to add the bonescript module to the Function global context - to do this :

When you run node-red it will print the location of settings.js like

[info] Settings file  : /usr/local/lib/node_modules/node-red/settings.js

Edit this settings.js file - you may need to be administrator or sudo to do this. And there we need to uncomment the bonescript library line.

functionGlobalContext: {
    // os:require('os'),
    // jfive:require("johnny-five"),
    // j5board:require("johnny-five").Board({repl:false})

The module is then available to any functions you write as

An example flow that demonstrates this is below :

[{"id":"3c3a39ec.c3c5c6","type":"inject","name":"on","topic":"","payload":"1","repeat":"","once":false,"x":226,"y":498,"z":"345c8adc.cba376","wires":[["6d418357.92be7c"]]},{"id":"f9ade3.ff06522","type":"inject","name":"off","topic":"","payload":"0","repeat":"","once":false,"x":226,"y":538,"z":"345c8adc.cba376","wires":[["6d418357.92be7c"]]},{"id":"919022c7.6e6fe","type":"inject","name":"tick","topic":"","payload":"","repeat":"1","once":false,"x":226,"y":438,"z":"345c8adc.cba376","wires":[["7783db44.887c24"]]},{"id":"ec2495b6.13db68","type":"debug","name":"","active":true,"x":666,"y":478,"z":"345c8adc.cba376","wires":[]},{"id":"7783db44.887c24","type":"function","name":"Toggle USR3 LED on input","func":"\nvar pin = \"USR3\"\nvar b =;\ncontext.state = context.state || b.LOW;\n\nb.pinMode(pin, b.OUTPUT);\n\n(context.state == b.LOW) ? context.state = b.HIGH : context.state = b.LOW;\nb.digitalWrite(pin, context.state);\n\nreturn msg;","outputs":1,"x":446,"y":458,"z":"345c8adc.cba376","wires":[["ec2495b6.13db68"]]},{"id":"6d418357.92be7c","type":"function","name":"Set USR2 LED on input","func":"\nvar pin = \"USR2\";\nvar b =;\n\nb.pinMode(pin, b.OUTPUT);\n\nvar level = (msg.payload === \"1\")?1:0;\nb.digitalWrite(pin, level);\n\nreturn msg;","outputs":1,"x":446,"y":518,"z":"345c8adc.cba376","wires":[["ec2495b6.13db68"]]}]