BlueMix Internet of Things Workshop with Texas Instruments BeagleBone and SensorTag

Connecting devices to the Internet of Things

This week I’m in Kenya helping run a developer event in partnership with Strathmore University.

In preparing for the Internet of Things workshop I decided to share some more verbose and detailed instructions on setting up Texas Instruments BeagleBone Black and SensorTag with the IBM BlueMix (IBM Codename: BlueMix) Internet of Things service.

Many thanks to Joshua Carr @Josh_schwaa for guiding me in preparing this workshop.

Part 1 – Collecting and visualising sensor data

In this section we’ll collect data from the world around us using a simple device set up that is useful for prototyping an Internet of Things solution. We’ll use a Texas Instruments BeagleBone as a device gateway to collect data from Texas Instruments SensorTags. The tags relay data to the BeagleBones using Bluetooth Low Energy. The BeagleBones then publish this data using a very efficient Internet protocol – MQTT – to distribute this data across the Internet. A set of pre-prepared cloud applications running on IBM BlueMix, capture, analyse and display this sensor data. These cloud applications are supplied ready to deploy in a Boilerplate template called IBM Internet of Things.

1. Power up the BeagleBone and connect to the Internet

Plug the BeagleBone USB cable into your PC. This provides power as well as a direct way to configure the BeagleBone. Share your PC’s network with the BeagleBone.

To connect your machine over USB to the BeagleBone you first need to install some drivers.

Windows 64 Bit:

Windows 32 Bit:

Next we want to enable your BeagleBone to use your machine’s Internet connection.

First find your network connections. Go to the Control Panel and search for Network Connections.


Make sure you have your BeagleBone attached with the USB cable. Now identify the network connection that represents the BeagleBone. Typically this shows up as a Local Area Connection followed by a number. I already had two Local Area Connections defined, so the BeagleBone showed up as Local Area Connection 3.

Next I recommend you rename this connection to something more useful. I’ve renamed mine to BeagleBone001 because it’s easier to find and 001 because I’m fortunate enough to have a few. Although I’ll probably configure BeagleBone007 next 😉

Next identify the network connection you’re using to connect your computer to the Internet. In this case Local Area Connection since I’m using a LAN right now. Choose Wireless Network Connection if you’re on Wi-Fi.


Now right click and get the Properties for the Internet connection you’re using.

Click on the Sharing tab. Check the box to allow other network users to connect through your computer’s Internet connection. A drop down list should appear. Find your BeagleBone entry and click OK. This grants permission to the BeagleBone to proxy through your computer to reach the Internet.


Now something a little odd usually happens. Windows 7 assigns a static IP address to the BeagleBone. We don’t want that. So go into the network Properties for your BeagleBone.


Click on the IP V4 connection and then on Properties.


And change the settings to Obtain and IP address and DNS server address automatically. Save these changes.


2. Install PuTTY and log into the BeagleBone with PuTTY

The BeagleBone communicates with your PC via SSH. There are several SSH clients but I like PuTTY best.

PuTTY can be downloaded here.

Once you have PuTTY installed, configure a connection to on port 22.

The username is “root”. There is no password by default.

Why That’s the IP Address that all BeagleBone’s start out with. And the BeagleBone uses to talk to your computer over the USB connection.


A command window should appear. Login as root. There is no password by default.


So now you’re into a console for the BeagleBone.


3. Check that the BeagleBone can use your PC’s network

First run this command.

/sbin/route add default gw


Now move to the /etc directory.

cd /etc

Edit the resolv.conf file.

nano resolv.conf

Add this line to the resolv.conf file and save your changes by exiting and saving. This tells the BeagleBone to route Internet traffic using Google’s name server.


Finally ping a Web server to check that the BeagleBone can get a response.


If the networking has been set up correctly you’ll see responses to your pings.

Use Control+C to stop the BeagleBone from pinging.

Note that whenever you drop and resume network connectivity, you’ll need to work through most of these steps again.

Still not connected?

If your pings aren’t getting a response, then your firewall(s) might be getting in the way.

If you have Windows Firewall on your machine this step creates a rule that allows the BeagleBone traffic through. You might want to test this by turning Windows Firewall off to see if it works.

Add a new rule by following these steps:

Go to Control Panel -> System and security -> Windows Firewall -> Advanced settings -> Inbound rules -> New rule -> Custom (custom rule)

Press next. In “Protocol and ports” choose protocol type “ICMPv4″ then press on “Customize”, then choose “Specific ICMP types”, check the box “echo request” then OK out of the settings. On the previous panel just choose defaults “Any IP address”, press next, “Allow the Connection”, apply the rule to all of Domain, Private and Public, can call it “Beaglebone Ping Rule” and press Finish.

If you’re using Symantec Endpoint Protection I haven’t worked out how to configure it to allow the BeagleBone traffic through. The only solution I know of is to turn it off. It’ll probably turn itself back on every now and again as well, so if you’re network starts dropping check on it.

Now your BeagleBone is connected to the Internet, let’s download the code we need from Github to connect the SensorTag to the BeagleBone and the BeagleBone to the BlueMix Internet of Things cloud.

4. Install nodejs and clone sample Javascript programs

From the PuTTY window, clone this GitHub project:

git clone

Navigate to this directory:

cd iot-beaglebone/samples/nodejs

Install several node packages using a pre-prepared setup file. This installs several required node packages – async, sensortag, MQTT – using npm.

bash ./

This command will take a few minutes to complete.


5. Start the Bluetooth LE Dongle

If you can’t see a light in the Bluetooth LE dongle use these commands to force it to start. You should set a light appear. The light may disappear later which is normal.

hciconfig hci0 
downhciconfig hci0 up


If the Bluetooth LE dongle doesn’t respond e.g. you get an error like:

Can't get device info: No such device

Then run this command to get the USB port of the BeagleBone to start:

isusb –v

And run this command to enable the Bluetooth service:

systemctl enable bluetooth.service


If the Bluetooth service still does not find the Bluetooth dongle, try:

rfkill list
sudo rfkill unblock 0
hcitool lescan


6. Find out what the MAC address of your SensorTag is

Navigate to this directory on the BeagleBone:


Run this nodejs program and follow the instructions. You should see the SensorTag’s MAC address appear. This is a unique number that identifies the SensorTag and looks similar to this: 1C:BA:8C:A8:72:1A.

node ibm_iot_sensortag_quickstart.js

If you copy this number from the PuTTY command line make sure the nodejs program doesn’t stop before the next step. If it does, re-start it by running the command again. The SensorTag MAC address won’t change.


7. Use the Internet of Things Cloud to visualize data from your SensorTag

Go to

Enter the MAC address of your SensorTag and explore the data it can capture and visualise.

This Web app uses IBM BlueMix and the Internet of Things service to capture, analyse and display the SensorTag data. It uses an open protocol designed for capturing sensor data called MQTT to publish this data from the BeagleBone to the Internet of Things service.

You’ll be able to select from a list of graphs that display the sensor data collected from the SensorTag.


Well done. You have successfully captured a variety of data from the world around you and made this data part of the Internet of Things.

Now let’s learn how to create cloud applications in BlueMix that put this data to work!


IMPORTANT NOTE: How to Power down the BeagleBone

When you’re finished using the BeagleBone don’t pull out the USB cable as this can cause problems. You wouldn’t unplug your computer when you finished using it! Instead either run this command from your PuTTY window:

sudo shutdown -hP now

Or press and hold down the PWR button on the BeagleBone – it’s near the USB port to the right of the RESET button.


Part 2 – Creating Internet of Things applications with BlueMix

Log into IBM BlueMix at

Go to the Catalog and select the Internet of Things Boilerplate.


Notice that the Boilerplate deploys a combination of BlueMix services including:

  • NodeRed – a visual tool for wiring and programming the Internet of Things
  • Time series database – for collecting and archiving Internet of Things data
  • Internet of Things API – for connecting to sensors and devices using protocols like MQTT

 Click on Create Application to deploy the services into BlueMix.


Choose a unique name for your Internet of Things service:

Note that it may take several minutes for BlueMix to deploy and link all the services. Once your Internet of Things service status turns green on the BlueMix dashboard you are ready to proceed.

From the BlueMix Console open your Internet of Things service.

Here you can see the various BlueMix services.

View your Internet of Things service, but navigating to your service’s URL. You can click on the URL shown under your IoT services name.

At your Internet of Thing service Web URL you will see information on the Node-Red BlueMix service. This visual tool enables you to rapidly build Internet of Things cloud applications in BlueMix.

Click on the large red button to launch the flow editor in your browser.


First let’s check that we’re receiving messages from the SensorTag.

Under Input nodes create an IoT input node by dragging from the pallete to the canvas.


Under Output nodes create a debug output node. Now wire them together by clicking on the grey terminals and dragging the wire between them.

Now, let’s configure the IoT Input node to subscribe to your SensorTag’s data.

Double click on the IoT Input node and enter your SensorTag’s MAC address. You can give this node a name as well if you wish.


Now click the Deploy button to push your Internet of Things application into BlueMix.

Make sure you are showing the Debug window – instead of the Info window – on the right pane, so that you can see the output of the Debug node which will print the output here.

From your PuTTY window, re-run the quickstart javascript program.

cd /iot-beaglebone/samples/nodejs 
node ibm_iot_sensortag_quickstart.js

You should now see similar messages in the Node-Red debug window that you do in the PuTTY window.


This shows that the SensorTag data is being published from the BeagleBone using MQTT into the BlueMix Internet of Things service, and then in turn is being subscribed to by the Node-Red IoT node.


Part 3 – More interesting Internet of Things applications

Now that we have successfully deployed our first Internet of Things cloud application – which admittedly doesn’t do very much – let’s create some more interesting applications.

First let’s create an application that sends an SMS text messages to a Mobile phone with updates on the temperature recorded by the SensorTag.

To create this application we’ll use the Twilio Output node which can send SMS messages. Select this Output node and add it to the canvas.


In order to use the Twilio node we need a Twilio account. If you don’t already have an account, you can quickly and easily set up a trial account now.

To set up your trial Twilio account go to:

Look for the link to Sign up to Twilio. Follow the instructions to set up your trial account. When finished you will be issued with a virtual Twilio number, an account SID and an Authentication Token. You will find these numbers on your Twilio account dashboard.

Back in your BlueMix Node-Red application, configure the Twilio node to use these credentials.

Double click on the Twilio node, and enter your details.


You’ll need to configure a new Twilio service using the Pen icon on the Twilio drop down. Enter the credentials into the screen that appears. You only need to do this once and can re-use this Twilio service definition across other Node-Red Twilio nodes.

If you want to test that the Twilio node is working correctly, add an Inject node and wire it into your Twilio node.


Now configure the Inject node to inject a string and enter the text you want to SMS into the Payload both below.


Now deploy your Node-Red flows. You’ll get warnings about the other nodes we haven’t configured yet – just ignore this. Each time your click on the Inject nodes button (the blue rounded box attached to the left of the Inject node), it should send an SMS to the number you configured in the Inject node message payload.

Ok – So now the SMS is working, let’s use the SensorTag data to send the SMS messages.

To do this we need to add some logic to test the temperature being measured against our threshold. To add this logic we’ll use the Function node. Drag and add a Function node to the canvas. We’ll add some Javascript to this in just a bit.


Our SensorTag is publishing sensor data every 5 milliseconds. We don’t want to send SMS messages that often! Rather than modify the rate the SensorTag publishes data (because other applications may still want the data this frequently) let’s introduce a delay into our flow that ignores all but 1 message every minute. This will limit the frequency of SMS messages that we send to every 60 seconds.

Add the delay node to the canvas.


Let’s configure the delay node now, so that we don’t forget later. If we did forget, Node-Red will attempt to send an SMS message ever 5 milliseconds and this will cause issues!

Edit the delay node and set the rate limit to 1 message per minute. Check the box to drop intermediate messages as we don’t want these.


Next, wire all our nodes together so that the output from the SensorTag subscription feeds into the delay node, then the function node, which in turn feeds the Twilio node. Also wire the debug node so that the function node is also feeding it along with the IoT node.

Your flow will look something like this:


Now let’s use the function node to write some Javascript to test the temperature against a threshold.

Edit the function node and paste in this Javascript.

//set the temp thresholds
var hotTemp = 28;
var warmTemp = 22;

//obtain the current temp of the SensorTag
var tagTemp = msg.payload.d.objectTemp;

//convert the temp into a number
var tagTempNum = parseFloat(tagTemp);

var degText = " degrees C: ";

//create the SMS messages to send
var hotText = "SMS :" + tagTemp + degText + "It's Hot!";
var warmText = "SMS :" + tagTemp + degText + "Just nice and warm";
var coolText = "SMS :" + tagTemp + degText + "It's cool";

//test the current temp against the thresholds and
//set the message payload to the SMS message content
if (tagTempNum >= hotTemp) { msg.payload = hotText; }
else if (tagTempNum >= warmTemp) { msg.payload = warmText; }
else { msg.payload = coolText; }

return msg

 This function uses msg.payload.d.objectTemp to retrieve the current temperature published by the SensorTag.

msg is the data being inserted into the function node from the IoT node that feeds it.

d.object is the JSON structure used by the nodejs program on the BeagleBone that is publishing the SensorTag data into the BlueMix Internet of Things service.

We convert this string into a number and compare it against our values for hot, warm and cool temperatures (I’m creating this workshop in Africa so the values are much higher than for my native England!)

Finally we set the payload of the message the function node outputs to the string we want to send via SMS. The Twilio node will then use the msg.payload value as the content of the SMS message it sends.

Now deploy your nodes. Remember to also start the nodejs program that publishes the SensorTag data. From your PuTTY window, run the quickstart javascript program.

cd /iot-beaglebone/samples/nodejs 
node ibm_iot_sensortag_quickstart.js

Check the debug panel and you should see a steady stream of SensorTag temperature data as before.

However this time you should also get one SMS text to your phone every 60 seconds or so with the current temperature.

Remember to stop the SensorTag data flowing or your phone will fill up with messages, or alternatively remove the wire input to the Twilio node and re-deploy to cease sending texts.

Part 4 – A Challenge

Try to create an Internet of Things application that acts as a motion sensor alarm so that you’ll receive an SMS message wherever the SensorTag is moved.

Remember first to remove the wires from your Temperature flow so that it won’t interfere with the next application.


You can use a nice new canvas for this app. To create another sheet click on the large plus sign at the top right of the canvas.

Hint: msg.payload.d.accelX, msg.payload.d.accelY and msg.payload.d.accelZ data changes when the SensorTag is moved. Take care not to create a flow that sends you hundreds of SMS messages!


Further Reading and References

Device Recipes for the BlueMix Internet of Things service:

Node-Red documentation:

Some nice tutorials and guides on BeagleBone:

Useful article on setting up Ethernet connection for your BeagleBone:

Some useful articles setting up Internet sharing for my Windows 7 laptop:

And for Linux users:

Setting up Bluetooth on the SensorTag:

Information on the Magnetometer that can turn the SensorTag into a metal detector:


5 thoughts on “BlueMix Internet of Things Workshop with Texas Instruments BeagleBone and SensorTag

  1. anorman says:

    Great workshop Ben, successfully connecting data to the Quickstart Data Dashboard and can see all the values. I’m struggling with the new Bluemix service to get the data flowing in Node Red as per the second part?

    – Registered the Device and created an API key
    – Set up the Device and API in Bluemix IoT J7 service
    – Started App and Node Red and set up IoT node with MAC address and debug node and deployed the flow

    Alas, no data in the debug node….any ideas what I’ve missed?

  2. It was great work Ben. I actually attended the event, it was great. We got to learn so many things in a very short time span.

    Ben, would you mind including an introduction stating prerequisites and required knowledge? That way someone would know what to expect.

    Otherwise Bluemix services are pretty neat. Thanks Ben

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s