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.

Node-RED

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 http://nodered.org/ 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”.

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: http://nodered.org/docs/getting-started/installation.html

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/.

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: https://github.com/sandeepmistry/node-sensortag.

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

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.

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

Screen Shot 2015-07-15 at 20.15.18

Testing

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!

3 thoughts on “Node-RED on Beaglebone Black (with SensorTag 2.0)”

  1. Hi Frederick,

    Great Article!
    I was looking for example solutions with the cc2650stk Sensortags and found this site. Looks very interesting. Do you know if it is possible to get the data from multiple connected cc2650stk sensortags at the same time? Or can you only use this scenario to get the dat from one sensor at a time?

    Please le me know.

    Kind Regards,

    Jeroen

    1. Hi Jeroen, thanks! 🙂

      As I only have a single sensortag to test with, I do not know for sure, but I did read somewhere that the node-red sensortag library only supports using a single sensortag at a time. Hope this answers your question.

      Regards,
      Frederick

Leave a Reply

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