BLE on Beaglebone Black (with SensorTag 2.0)

This post is part of my RoadTest review for the TI CC2650STK SimpleLink IoT SensorTag. As I plan to use the BeagleBone Black for data collection, I thought I’d blog about how to get BLE to work on it first.

Here we go …

Preparing the BBB

Before we jump to setting up BLE on the BBB, we require an operational BBB with internet connection. The full setup of the BBB using Debian can be found in one of my earlier posts: [AirCare] InTheAir – Week 2: Preparing the Beaglebone Black

It covers the following topics:

  • preparing the SD card with Debian
  • expanding the filesystem, making use of the full SD card’s available space
  • setting up network connectivity using wifi
  • connect a touchscreen display

Setting up Bluetooth

Update

I hadn’t use my BBB for a while before setting up the bluetooth, so the first thing I did was to update the software.

Bluetooth

Once the BBB’s software was up-to-date, I installed the bluetooth software.

This resulted in a lot of packages being installed, for a total of 144MB of additional disk space.

Dongle

photo (21)I got myself a cheap BT dongle from Trust, paying special attention to support for Bluetooth 4.0 (BLE).

Plugged in the dongle in the BBB’s USB port and check if the device was detected properly. If you have more than one USB device to connect, you may need a powered USB HUB to connect them all simultaneously.

Tools

With the software installed and the dongle plugged it, it’s time to look at the software tools used to get some data from the SensorTag.

hcitool

hcitool is used to configure Bluetooth connections and send some special command to Bluetooth devices.

First, check hcitool detects your bluetooth dongle.

Perform a scan to find out the SensorTag’s address.

Create connection to SensorTag, using previously scanned address.

gatttool

gatttool is a tool used to interact with BLE devices.

Use gatttool in interactive mode to send commands to the previously scanned address.

Connect to the SensorTag, notice how the prefix changes from “[ ]” to “[CON]”.

Request the characteristics of the device.

Request the device name using the proper characteristic, by handle.

The response is hexadecimal. To make it human readable, it needs to be converted to ASCII. This can be done using some command line magic.

(The above command is probably far too complicated for what I’m trying to achieve, so if any command line wizard is reading this, please help improve my magic …)

Or using Python for example.

Conclusion

There you have it, BLE on the BBB. I was able to connect to the SensorTag and retrieve it’s name. Once I’ve identified the other characteristics, I’ll be able to take in the data I want and keep a history of it.

Leave a Reply

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