Skip to content

Getting Started With Bluetooth LE SensorTag on Linux

Günter Obiltschnig edited this page Oct 28, 2018 · 7 revisions

This page describes how to get started with Bluetooth LE and the TI SensorTag on a Linux device (including a Raspberry Pi).

Bluetooth support in macchina.io requires the bluepy-helper executable that's part of the bluepy project.

Prerequisites

$ sudo apt-get update
$ sudo apt-get install libssl-dev
$ sudo apt-get install bluetooth
$ sudo apt-get install build-essential libglib2.0-dev libdbus-1-dev

Building macchina.io

$ git clone https://github.com/macchina-io/macchina.io.git
$ cd macchina.io
$ make -s -j2 DEFAULT_TARGET=shared_release

Building bluepy (for bluepy-helper)

$ cd ..
$ git clone https://github.com/macchina-io/bluepy.git
$ cd bluepy/bluepy
$ make
$ sudo cp bluepy-helper /usr/local/bin/

Enabling Bluetooth

$ sudo hciconfig hci0 up

Search for a TI SensorTag

$  sudo hcitool lescan
LE Scan ...
C4:BE:84:72:C5:06 (unknown)
C4:BE:84:72:C5:06 CC2650 SensorTag
^C

Enable TI SensorTag in macchina.io Configuration

Edit macchina.io/server/macchina.properties and add the following lines:

#
# Bluetooth LE/SensorTag
#
btle.bluez.helper = /usr/local/bin/bluepy-helper
sensortag.sensors.1.address = C4:BE:84:72:C5:06

The SensorTag address must match the address discovered with sudo hcitool lescan.

Run macchina.io

$ export MACCHINA_BASE=/path/to/macchina.io
$ export LD_LIBRARY_PATH=$MACCHINA_BASE/platform/lib/Linux/armv7l:$LD_LIBRARY_PATH
$ cd macchina.io/server
$ bin/Linux/armv7l/macchina

Note: in the export LD_LIBRARY_PATH command, replace armv7l with the proper hardware architecture of your system (e.g., x86_64).

The sensors from the SensorTag should now be visible in the Sensors & Devices app in the web user interface.