Node-RED on Beaglebone Black (with SensorTag 2.0)

In my previous post, I was able to retrieve data from the SensorTag 2.0 on the Beaglebone Black using command line tools such as “hcitool” and “gatttool”. For this post, I’ll be setting up Node-RED to collect the SensorTag data automatically and make it available for other applications to process or store.


What is Node-RED? Node-RED is a tool used to wire together different devices, APIs or online service in a visual way.

The website is located at and contains a wealth of information on how to install and use Node-RED on different operating systems and devices.

Install Node-RED

Node-RED requires Node.js to be installed. Fortunately for me, this is the case by default on the Beaglebone Black. Just to be sure, I tried to install Node.js using “apt-get”.

debian@beaglebone:~$ sudo apt-get install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version.
nodejs set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

As expected, Node.js is already installed and is even reported to be at the latest version.

Installing Node-RED is very easy and only takes a couple of minutes. The command can be found on the Node-RED website:

debian@beaglebone:~$ sudo npm install -g --unsafe-perm node-red

Once installed, Node-RED can be run using the “node-red-pi” command. This will start the application, which can then be accessed using a webbrowser at http://device_ip:1880/.

debian@beaglebone:~$ node-red-pi

Welcome to Node-RED

15 Jul 19:45:03 - [info] Node-RED version: v0.11.1
15 Jul 19:45:03 - [info] Node.js version: v0.10.25
15 Jul 19:45:03 - [info] Loading palette nodes
15 Jul 19:45:12 - [warn] ------------------------------------------
15 Jul 19:45:12 - [warn] Failed to register 1 node type
15 Jul 19:45:12 - [warn] Run with -v for details
15 Jul 19:45:12 - [warn] ------------------------------------------
15 Jul 19:45:12 - [info] Settings file : /usr/local/lib/node_modules/node-red/settings.js
15 Jul 19:45:12 - [info] User directory : /home/debian/.node-red
15 Jul 19:45:12 - [info] Flows file : /home/debian/.node-red/flows_beaglebone.json
15 Jul 19:45:13 - [info] Server now running at
15 Jul 19:45:13 - [info] Creating new flow file
15 Jul 19:45:13 - [info] Starting flows
15 Jul 19:45:13 - [info] Started flows

Screen Shot 2015-07-15 at 19.45.55

Install node-sensortag

In order to have support for the TI SensorTag in Node-RED, a new node needs to be installed. Before being able to install it though, it is required to have the bluetooth development files installed first. More information on the SensorTag node can be found on its GitHub page:

debian@beaglebone:~/.node-red$ sudo apt-get install libbluetooth-dev

Once done, it should be possible to install the SensorTag node without issues.

debian@beaglebone:~$ cd ~/.node-red
debian@beaglebone:~/.node-red$ sudo npm install sensortag

When that is installed, Node-RED has to be run as “root” or with “sudo” in order to access the Bluetooth system calls. And because Node-RED is run as a different user, it is recommended to specify the path to the user directory where the SensorTag node was installed.

debian@beaglebone:~$ sudo node-red-pi -u /home/debian/.node-red/

Welcome to Node-RED

15 Jul 20:14:27 - [info] Node-RED version: v0.11.1
15 Jul 20:14:27 - [info] Node.js version: v0.10.25
15 Jul 20:14:27 - [info] Loading palette nodes
15 Jul 20:14:37 - [warn] ------------------------------------------
15 Jul 20:14:37 - [warn] Failed to register 1 node type
15 Jul 20:14:37 - [warn] Run with -v for details
15 Jul 20:14:37 - [warn] ------------------------------------------
15 Jul 20:14:37 - [info] Settings file : /usr/local/lib/node_modules/node-red/settings.js
15 Jul 20:14:37 - [info] User directory : /home/debian/.node-red
15 Jul 20:14:37 - [info] Flows file : /home/debian/.node-red/flows_beaglebone.json
15 Jul 20:14:37 - [info] Server now running at
15 Jul 20:14:37 - [info] Creating new flow file
15 Jul 20:14:38 - [info] Starting flows
15 Jul 20:14:38 - [info] Started flows

The SensorTag node should be available in the Node-RED GUI.

Screen Shot 2015-07-15 at 20.15.18


As a first test, I connected the SensorTag node directly to a debug output. This allowed me to confirm the Bluetooth connection between the SensorTag and the Beaglebone Black was properly set up without any manual intervention and that Node-RED was able to capture the data.

Screen Shot 2015-07-15 at 20.48.38 Screen Shot 2015-07-15 at 20.57.09

I started with a few parameters, tested a bit, and then enabled the others. As you may be able to see from the screenshots above, all that was required to set it up was to:

  • drag the necessary nodes in the sheet, in this case: sensortag & debug
  • enter the MAC address of the sensortag
  • select which parameters to report on
  • press the “deploy” button in the top right corner

It doesn’t get any more simple than this! You can see the debug data in the column on the right.

After a successful first test, I added a second, more useful output: MQTT. This allows me to publish the SensorTag data to a MQTT broker and topic of my choice.

Adding the MQTT output is simple:

  • drag the MQTT node in the sheet
  • connect it to the SensorTag node
  • configure a broker and topic
  • deploy

Screen Shot 2015-07-16 at 19.47.13 Screen Shot 2015-07-16 at 20.10.39

Using MQTTLens, I was able to subscribe to the topic and visualise the published data. It works! This is of course only a very simple example meant to demonstrate some basic features, and does not take any security into account, as all the data is just published on the internet for anyone to see. So keep that in mind if you plan to try this out.

In my next post, I’ll be collecting the data to build historical data that can be used for trending, processing, … Until then!

© Frederick Vandenbosch, 2014-2021. Unauthorised use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Frederick Vandenbosch with appropriate and specific direction to the original content.