element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
BeagleBoard
  • Products
  • Dev Tools
  • Single-Board Computers
  • BeagleBoard
  • More
  • Cancel
BeagleBoard
Blog BLE on Beaglebone Black (with SensorTag 2.0)
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join BeagleBoard to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fvan
  • Date Created: 15 Jul 2015 1:17 PM Date Created
  • Views 3094 views
  • Likes 4 likes
  • Comments 7 comments
  • bluetooth
  • ble
  • RoadTest
  • sensortag
  • beagleboneblack
  • bbb
  • iot
  • simplelink
  • cc2650
Related
Recommended

BLE on Beaglebone Black (with SensorTag 2.0)

fvan
fvan
15 Jul 2015

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.

imageimage

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

image

 

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.

  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 10 years ago +1
    Great. I have paired my tag with the dongle of the Cypress PSoC4/PRoC4 BLE kit. I don't have the programmer for the SensorTag, so I've only be able to poll data and enable notifications.
  • fvan
    fvan over 10 years ago in reply to nikhilbadami

    When browsing for my dongle, I searched for reviews and found people had used the one I picked with Raspberry Pi and the likes, so I was confident it would work on Linux.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to nikhilbadami

    You do need a dongle that works with Linux.  It also needs to be Bluetooth Smart or Bluetooth Low Energy (different terms, but same protocol).  The BT 4.0 spec states that devices can use BLE, Bluetooth "Classic", or both protocols.  To keep the power requirements to a minimum the SensorTag requires BLE.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • nikhilbadami
    nikhilbadami over 10 years ago

    Hey I was just wondering if you specifically looked for a dongle that worked with linux or just one that works with Bluetooth 4.0? The dongle I got is not recognized by my beaglebone.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fvan
    fvan over 10 years ago in reply to jonkey

    I tested with the device name using "[CON][B0:B4:48:B8:23:01][LE]> char-read-hnd 0x3"

    If you know the handle of what you would like to read, it should just be a matter of replacing the hex value in the command above?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jonkey
    jonkey over 10 years ago

    This is a great tutorial, I was wondering if you were able to get any actual readings from the sensortag sensors. When I try to write to a handle using the gatttool I get an error that say "A valid handle is required"

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube