Skip navigation

BeagleBoard

3 Posts authored by: Frederick Vandenbosch Top Member

In some previous posts, I first set up Bluetooth on the Beaglebone Black and then set up Node-Red to convert the Bluetooth data to MQTT messages. In this third post, I'll be using OpenHAB to receive the MQTT messages, process them and use them for notifications, trending, etc ...

 

OpenHAB

 

Installation

 

The installation of Java and OpenHAB is already covered in detail in one of my posts here on element14. The post can be found here: [AirCare] InTheAir - Week 5: openHAB and MQTT

In order to use OpenHAB with the SensorTag, different items, sitemap, rules, etc ... will be created though. You'll find them in the next paragraphs.

 

Configuration

 

Items

 

From Node-RED, all data is being published to the same topic, so in OpenHAB a master item has been defined to subscribe to the appropriate topic.

Other items have been defined in addition to the master item. They will be assigned with values parsed from the master item, categorising the data in different types such as temperature, humidity, buttons, etc ...

 

The items file contains the following:

 

debian@beaglebone:~$ cat /opt/openhab/configurations/items/sensortag.items


Group All

String SensorTag "SensorTag Raw Data [%s]" <sensortag> (All) {mqtt="<[eclipseIot:fvan-sensortag:state:default]"}

Number SensorTag_Temperature_Ambient "SensorTag Ambient Temperature [%.1f °C]" <sensortag> (All)
String SensorTag_Temperature_Object "SensorTag Object Temperature [%s °C]" <sensortag> (All)
String SensorTag_Humidity "SensorTag Humidity [%s %%RH]" <sensortag> (All)
String SensorTag_Pressure "SensorTag Pressure [%s hPa]" <sensortag> (All)
String SensorTag_Keys_1 "SensorTag Key #1 [MAP(bool.map):%s]" <sensortag> (All)
String SensorTag_Keys_2 "SensorTag Key #2 [MAP(bool.map):%s]" <sensortag> (All)

Number Chart_Period "Chart Period"





 

The screenshot below demonstrates the initial tests, comparing Node-RED's output to OpenHAB's input. A limiter was set in place to prevent flooding of data, limiting to 6 messages per minute per sensor used.

Screen Shot 2015-07-17 at 21.14.59.png

 

Sitemaps

 

The sitemaps file is used to arrange the different items visually, in certain (sub)categories, even including charts. In this example, a chart has been defined for the ambient temperature item, with three possible display periods: hour, day, week.

 

debian@beaglebone:~$ cat /opt/openhab/configurations/sitemaps/sensortag.sitemap


sitemap sensortag label="SensorTag" {
        Frame {
                Text item=SensorTag
        }
        Frame {
                Text item=SensorTag_Temperature_Ambient {
                        Frame {
                                Text item=SensorTag_Temperature_Ambient
                        }
                        Frame {
                                Switch item=Chart_Period label="Chart Period" mappings=[0="Hour", 1="Day", 2="Week"]
                                Chart item=SensorTag_Temperature_Ambient period=h refresh=10000 visibility=[Chart_Period==0, Chart_Period=="Uninitialized"]
                                Chart item=SensorTag_Temperature_Ambient period=D refresh=10000 visibility=[Chart_Period==1]
                                Chart item=SensorTag_Temperature_Ambient period=W refresh=10000 visibility=[Chart_Period==2]
                        }
                }
                Text item=SensorTag_Temperature_Object
                Text item=SensorTag_Pressure
                Text item=SensorTag_Humidity
                Text item=SensorTag_Keys_1
                Text item=SensorTag_Keys_2
        }
}




 

The result is the following:

Screen Shot 2015-07-20 at 11.14.40.png

 

Rules

 

Rules can be used to trigger actions based on certain events. In this particular case, two rules have been defined:

  • Categorise data
  • Temperature alarm

 

The first rule is triggered when the master item defined in the items file is updated to a new value. The rule then parses the content in order to categorise it and assign the contents to the item representing the correct sensor. Using some simple string operations, the useful content is extracted from the incoming data.

 

The second rule demonstrates the use of notifications using Prowl. For testing purposes, I have a notification triggered when the temperature is lower than 50°C. Obviously, this would need to be set to more realistic values, but it is a quick way of verifying the notification mechanism works.

 

To know more about notifications in OpenHAB using Prowl, be sure to check out the following post: http://www.element14.com/community/community/design-challenges/forget-me-not/blog/2014/10/20/cats-forgetmenot--final#jiv…

 

debian@beaglebone:~$ cat /opt/openhab/configurations/rules/sensortag.rules


import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import java.lang.Math
import java.lang.Double
import java.lang.String

var Timer temperature_alarm = null


rule "Categorise data"
when
        Item SensorTag changed
then
        var state = SensorTag.state.toString()
        var output = ""


        if(state.contains("ambient")) {
                output = state.substring(state.indexOf('"ambient":')+10,state.indexOf('}'))
                SensorTag_Temperature_Ambient.postUpdate(output)


                output = state.substring(state.indexOf('"object":')+9,state.indexOf(','))
                SensorTag_Temperature_Object.postUpdate(output)
        }
        else if(state.contains("pressure")) {
                output = state.substring(state.indexOf(':')+1,state.indexOf('}'))
                SensorTag_Pressure.postUpdate(output)
        }
        else if(state.contains("humidity")) {
                output = state.substring(state.indexOf('"humidity":')+11,state.indexOf('}'))
                SensorTag_Humidity.postUpdate(output)
        }
        else if(state.contains("right")) {
                output = state.substring(state.indexOf('"right":')+8,state.indexOf('}'))
                SensorTag_Keys_1.postUpdate(output)

                output = state.substring(state.indexOf('"left":')+7,state.indexOf(','))
                SensorTag_Keys_2.postUpdate(output)
        }
end


rule "Temperature alarm"
when
        Item SensorTag_Temperature_Ambient changed
then
        var state = SensorTag_Temperature_Ambient.state as DecimalType

        if(state < 50.0) {
                if(temperature_alarm == null) {
                        pushNotification("<api key>","Ambient temperature", "too low: " + state)
                        temperature_alarm = createTimer(now.plusMinutes(1)) [|
                                temperature_alarm.cancel
                                temperature_alarm = null
                        ]
                }
        }
end




 

Here's a screenshot demonstrating the data being categorised properly:

Screen Shot 2015-09-12 at 12.42.15.png

 

And some screenshot of the notifications being received on my phone:

IMG_0017.PNGIMG_0019.PNG

 

Transform

 

It is also possible to transform the data in the visualisation layer of OpenHAB. For example, the buttons return a true/false state. More meaningful would be to have the state reported as pressed or released.

By creating a bool.map file in the transform folder and reference it in the items file, this can be done quickly. The file contains one translation per line. In the GUI, "true" will be replaced by "pressed" and "false" by "released". The "-=-" is there to avoid OpenHAB reporting translation errors when no data has been received yet.

 

debian@beaglebone:~$ cat /opt/openhab/configurations/transform/bool.map


-=-
true=pressed
false=released




 

Persistence

 

Finally, persistence is what defines which data to store and with which type of storage (MySQL, RRD4J, ...). Persistence is required when using charts.

 

debian@beaglebone:~$ cat /opt/openhab/configurations/persistence/rrd4j.persist


Strategies {
        everyMinute : "0 * * * * ?"
        everyHour : "0 0 * * * ?"
        everyDay : "0 0 0 * * ?"


        default = everyChange
}


Items {
        * : strategy = everyChange, everyMinute, restoreOnStartup
}




 

 

Conclusion

 

This concludes this short series of post on how to retrieve data from a SensorTag via Bluetooth, convert it to MQTT using Node-RED and persist/monitor/trend it using OpenHAB.

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

 

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

 

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 http://127.0.0.1:1880/
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.png

 

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.

 

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 http://127.0.0.1:1880/
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.png

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.pngScreen Shot 2015-07-15 at 20.57.09.png

 

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.pngScreen Shot 2015-07-16 at 20.10.39.png


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!

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

photo (22).JPGphoto+1.JPG

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.

 

debian@beaglebone:~$ sudo apt-get update
debian@beaglebone:~$ sudo apt-get upgrade



 

Bluetooth

 

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

 

debian@beaglebone:~$ sudo apt-get install bluetooth











 

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

 

The following extra packages will be installed:
  bc bluez bluez-alsa bluez-cups bluez-gstreamer cups cups-client cups-common cups-filters cups-ppdc dc fonts-droid fonts-freefont-ttf foomatic-db-compressed-ppds foomatic-db-engine foomatic-filters ghostscript ghostscript-cups hpijs hplip hplip-data libart-2.0-2
  libcupscgi1 libcupsdriver1 libcupsfilters1 libcupsimage2 libcupsmime1 libcupsppdc1 libescpr1 libgs9 libgs9-common libgutenprint2 libhpmud0 libijs-0.35 libjbig2dec0 liblcms1 libpaper-utils libpaper1 libpoppler19 libsane-hpaio libsensors4 libslp1 libsnmp-base libsnmp15
  mscompress poppler-data poppler-utils printer-driver-all printer-driver-c2050 printer-driver-c2esp printer-driver-cjet printer-driver-escpr printer-driver-foo2zjs printer-driver-gutenprint printer-driver-hpcups printer-driver-hpijs printer-driver-m2300w
  printer-driver-min12xxw printer-driver-pnm2ppa printer-driver-postscript-hp printer-driver-ptouch printer-driver-pxljr printer-driver-sag-gdi printer-driver-splix python-imaging python-pexpect python-renderpm python-reportlab python-reportlab-accel samba-common
  samba-common-bin smbclient ttf-freefont
Suggested packages:
  cups-bsd cups-pdf xpp hplip-cups openprinting-ppds cjet foomatic-db-gutenprint ghostscript-x hplip-gui hplip-doc system-config-printer gutenprint-locales liblcms-utils lm-sensors slpd openslp-doc snmp-mibs-downloader fonts-japanese-mincho fonts-ipafont-mincho
  fonts-japanese-gothic fonts-ipafont-gothic fonts-arphic-ukai fonts-arphic-uming fonts-unfonts-core psutils hannah-foo2zjs tk8.4 tix gutenprint-doc hpijs-ppds magicfilter apsfilter python-imaging-doc python-imaging-dbg python-renderpm-dbg pdf-viewer
  python-egenix-mxtexttools python-reportlab-doc cifs-utils
Recommended packages:
  foomatic-db
The following NEW packages will be installed:
  bc bluetooth bluez bluez-alsa bluez-cups bluez-gstreamer cups cups-client cups-common cups-filters cups-ppdc dc fonts-droid fonts-freefont-ttf foomatic-db-compressed-ppds foomatic-db-engine foomatic-filters ghostscript ghostscript-cups hpijs hplip hplip-data
  libart-2.0-2 libcupscgi1 libcupsdriver1 libcupsfilters1 libcupsimage2 libcupsmime1 libcupsppdc1 libescpr1 libgs9 libgs9-common libgutenprint2 libhpmud0 libijs-0.35 libjbig2dec0 liblcms1 libpaper-utils libpaper1 libpoppler19 libsane-hpaio libsensors4 libslp1
  libsnmp-base libsnmp15 mscompress poppler-data poppler-utils printer-driver-all printer-driver-c2050 printer-driver-c2esp printer-driver-cjet printer-driver-escpr printer-driver-foo2zjs printer-driver-gutenprint printer-driver-hpcups printer-driver-hpijs
  printer-driver-m2300w printer-driver-min12xxw printer-driver-pnm2ppa printer-driver-postscript-hp printer-driver-ptouch printer-driver-pxljr printer-driver-sag-gdi printer-driver-splix python-imaging python-pexpect python-renderpm python-reportlab
  python-reportlab-accel samba-common samba-common-bin smbclient ttf-freefont
0 upgraded, 74 newly installed, 0 to remove and 0 not upgraded.
Need to get 47.8 MB of archives.
After this operation, 144 MB of additional disk space will be used.
Do you want to continue [Y/n]? y











 

Dongle

 

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

photo (21).JPG

 

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.

 

debian@beaglebone:~$ lsusb
Bus 001 Device 003: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub








 

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.

 

debian@beaglebone:~$ sudo hcitool dev
Devices:
  hci0 00:1A:7D:DA:71:0F








 

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

 

debian@beaglebone:~$ sudo hcitool lescan
LE Scan ...
B0:B4:48:B8:23:01 (unknown)
B0:B4:48:B8:23:01 CC2650 SensorTag
...








 

Create connection to SensorTag, using previously scanned address.

 

debian@beaglebone:~$ sudo hcitool lecc B0:B4:48:B8:23:01
Connection handle 69



 

gatttool

 

gatttool is a tool used to interact with BLE devices.

 

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

 

debian@beaglebone:~$ sudo gatttool -b B0:B4:48:B8:23:01 -I
[  ][B0:B4:48:B8:23:01][LE]>








 

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

 

[  ][B0:B4:48:B8:23:01][LE]> connect
[CON][B0:B4:48:B8:23:01][LE]>








 

Request the characteristics of the device.

 

[CON][B0:B4:48:B8:23:01][LE]> characteristics
[CON][B0:B4:48:B8:23:01][LE]>
handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0006, char properties: 0x02, char value handle: 0x0007, uuid: 00002a04-0000-1000-8000-00805f9b34fb
handle: 0x0009, char properties: 0x20, char value handle: 0x000a, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x000d, char properties: 0x02, char value handle: 0x000e, uuid: 00002a23-0000-1000-8000-00805f9b34fb
handle: 0x000f, char properties: 0x02, char value handle: 0x0010, uuid: 00002a24-0000-1000-8000-00805f9b34fb
handle: 0x0011, char properties: 0x02, char value handle: 0x0012, uuid: 00002a25-0000-1000-8000-00805f9b34fb
handle: 0x0013, char properties: 0x02, char value handle: 0x0014, uuid: 00002a26-0000-1000-8000-00805f9b34fb
handle: 0x0015, char properties: 0x02, char value handle: 0x0016, uuid: 00002a27-0000-1000-8000-00805f9b34fb
handle: 0x0017, char properties: 0x02, char value handle: 0x0018, uuid: 00002a28-0000-1000-8000-00805f9b34fb
handle: 0x0019, char properties: 0x02, char value handle: 0x001a, uuid: 00002a29-0000-1000-8000-00805f9b34fb
handle: 0x001b, char properties: 0x02, char value handle: 0x001c, uuid: 00002a2a-0000-1000-8000-00805f9b34fb
handle: 0x001d, char properties: 0x02, char value handle: 0x001e, uuid: 00002a50-0000-1000-8000-00805f9b34fb
handle: 0x0020, char properties: 0x12, char value handle: 0x0021, uuid: f000aa01-0451-4000-b000-000000000000
handle: 0x0023, char properties: 0x0a, char value handle: 0x0024, uuid: f000aa02-0451-4000-b000-000000000000
handle: 0x0025, char properties: 0x0a, char value handle: 0x0026, uuid: f000aa03-0451-4000-b000-000000000000
handle: 0x0028, char properties: 0x12, char value handle: 0x0029, uuid: f000aa21-0451-4000-b000-000000000000
handle: 0x002b, char properties: 0x0a, char value handle: 0x002c, uuid: f000aa22-0451-4000-b000-000000000000
handle: 0x002d, char properties: 0x0a, char value handle: 0x002e, uuid: f000aa23-0451-4000-b000-000000000000
handle: 0x0030, char properties: 0x12, char value handle: 0x0031, uuid: f000aa41-0451-4000-b000-000000000000
handle: 0x0033, char properties: 0x0a, char value handle: 0x0034, uuid: f000aa42-0451-4000-b000-000000000000
handle: 0x0035, char properties: 0x0a, char value handle: 0x0036, uuid: f000aa44-0451-4000-b000-000000000000
handle: 0x0038, char properties: 0x12, char value handle: 0x0039, uuid: f000aa81-0451-4000-b000-000000000000
handle: 0x003b, char properties: 0x0a, char value handle: 0x003c, uuid: f000aa82-0451-4000-b000-000000000000
handle: 0x003d, char properties: 0x0a, char value handle: 0x003e, uuid: f000aa83-0451-4000-b000-000000000000
handle: 0x0040, char properties: 0x12, char value handle: 0x0041, uuid: f000aa71-0451-4000-b000-000000000000
handle: 0x0043, char properties: 0x0a, char value handle: 0x0044, uuid: f000aa72-0451-4000-b000-000000000000
handle: 0x0045, char properties: 0x0a, char value handle: 0x0046, uuid: f000aa73-0451-4000-b000-000000000000
handle: 0x0048, char properties: 0x10, char value handle: 0x0049, uuid: 0000ffe1-0000-1000-8000-00805f9b34fb
handle: 0x004d, char properties: 0x0a, char value handle: 0x004e, uuid: f000aa65-0451-4000-b000-000000000000
handle: 0x004f, char properties: 0x0a, char value handle: 0x0050, uuid: f000aa66-0451-4000-b000-000000000000
handle: 0x0052, char properties: 0x1a, char value handle: 0x0053, uuid: f000ac01-0451-4000-b000-000000000000
handle: 0x0055, char properties: 0x0a, char value handle: 0x0056, uuid: f000ac02-0451-4000-b000-000000000000
handle: 0x0057, char properties: 0x0a, char value handle: 0x0058, uuid: f000ac03-0451-4000-b000-000000000000
handle: 0x005a, char properties: 0x12, char value handle: 0x005b, uuid: f000ccc1-0451-4000-b000-000000000000
handle: 0x005d, char properties: 0x08, char value handle: 0x005e, uuid: f000ccc2-0451-4000-b000-000000000000
handle: 0x005f, char properties: 0x08, char value handle: 0x0060, uuid: f000ccc3-0451-4000-b000-000000000000
handle: 0x0062, char properties: 0x1c, char value handle: 0x0063, uuid: f000ffc1-0451-4000-b000-000000000000
handle: 0x0066, char properties: 0x1c, char value handle: 0x0067, uuid: f000ffc2-0451-4000-b000-000000000000







 

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

 

[CON][B0:B4:48:B8:23:01][LE]> char-read-hnd 0x3
[CON][B0:B4:48:B8:23:01][LE]>
Characteristic value/descriptor: 53 65 6e 73 6f 72 54 61 67 20 32 2e 30








 

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.

 

debian@beaglebone:~$ echo -e $(echo -e " 53 65 6e 73 6f 72 54 61 67 20 32 2e 30" | sed 's/ /\\x/g') | awk '{printf "%s\n", $_}'
SensorTag 2.0




 

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

 

debian@beaglebone:~$ python
Python 2.7.3 (default, Mar 14 2014, 17:55:54)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "53656e736f7254616720322e30".decode("hex")
'SensorTag 2.0'




 

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.