In Cambridge, UK
Bluetooth LE on the Raspberry Pi
The Raspberry Pi 3 has built-in support for Bluetooth Low Energy (BLE). BLE is the technology behind many fitness trackers and smartwatches, and allows small, low-power devices to transmit and receive information from a central computer or smartphone.
This tutorial gets you started with Bluetooth Low Energy using a Texas Instruments SensorTag - these are small, robust, relatively cheap and do interesting things out of the box. You can buy one directly from TI, or in the UK they are available from RS and Farnell.
This page assumes:
- Raspberry Pi 3 Model B (older Pis will probably work with an external Bluetooth 4.0 dongle)
- Raspbian Jessie (April 2017), although later versions will probably work.
- TI CC2650 SensorTag, firmware 1.30 (May 2016) or later
We'll also assume you are familiar with the basics of typing Bash commands using the command line.
Basic installation checks
The Pi 3's built-in Bluetooth adapter is called hci0. You can check it is operating correctly with the command:
This should show something like this:
hci0: Type: BR/EDR Bus: UART BD Address: B8:27:EB:23:E2:A4 ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING RX bytes:1987 acl:0 sco:0 events:91 errors:0 TX bytes:1647 acl:0 sco:0 commands:57 errors:0
If for some reason it is shown as DOWN you can re-enable it with:
sudo hciconfig hci0 up
BlueZ 5.4 build on Raspberry Pi
Standard Wheezy bluez package is 4.99 and doesn't have LE support.
wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.4.tar.xz xz -d bluez-5.4.tar.xz tar xf bluez-5.4.tar sudo apt-get install libglib2.0-dev sudo apt-get install libdbus-1-dev libdbus-glib-1-dev sudo apt-get install libusb-dev sudo apt-get install libudev-dev sudo apt-get install libical-dev sudo apt-get install libreadline-dev ./configure --disable-systemd make sudo make install
Notes: Tests use: 2014-01-07-wheezy-raspbian.zip from http://downloads.raspberrypi.org/raspbian_latest