After running through the Android (or IOS) App the next step was to manually read and write data from and to the sensor tag.
For this I used a Raspberry PI B running the most current version of Raspbian dated 2015-05-05 downloaded from the Raspberry PI Downloads page and an IOGEAR Bluetooth 4.0 USB Micro Adapter.
Raspbian doesn’t have Bluetooth support loaded. Unfortunately, the version that is currently in the repository doesn’t have a working copy of gatttool. As a result you will need both install Bluetooth using apt-get and build bluez from source.
pi@raspberrypi ~ $ sudo apt-get install --no-install-recommends bluetooth <messages removed to save space> pi@raspberrypi ~ $ sudo service bluetooth status |
Bluez source can be downloaded from https://www.kernel.org/pub/linux/bluetooth/. At the time I am writing this July 3, 2015 the current version is 5.31 which built find on the most recent release of Raspbian.
Follow the commands below to build bluez. While you need to build bluez you don’t need to install what you build. You just need to copy the new version of gatttool to /usr/bin and you should be set to go.
pi@raspberrypi ~ $ sudo apt-get install --no-install-recommends bluetooth <messages removed to save space> Setting up libcap-ng0 (0.6.6-2) ... 100%[======================================>] 1,631,664 756K/s in 2.1s 2015-07-03 20:24:08 (756 KB/s) - `bluez-5.31.tar.xz' saved [1631664/1631664] <messages removed to save space> config.status: creating lib/bluez.pc <messages removed to save space> CC tools/obex-server-tool.o |
There are two tools that you will be using with your write data to the sensor tag.
- hcitool is the primary command line tool for configuring Bluetooth connections. It is used to scan for your sensor tag.
- gatttool is a tool that provides command line access to GATT Services on a Bluetooth Low Energy device.
To scan the sensor tag you will need to make sure that it is advertising. When the sensor tag is advertising there is a green led that flashes. The led can be seen if you turn the sensor tag over. It will is in the right window in the green circle. If it is not flashing then you will need to press the round button on the right side of the sensor tag shown in the yellow circle. If it doesn’t try removing and reinstalling the battery. If that doesn’t work replace the battery.
Image may be NSFW. Clik here to view. ![]() | Image may be NSFW. Clik here to view. ![]() | Image may be NSFW. Clik here to view. ![]() | Image may be NSFW. Clik here to view. ![]() |
Left | Front | Right | Back |
Once you have the sensor tag broadcasting go to your terminal window and type the hcitool command below.
pi@raspberrypi ~ $ sudo hcitool lescan |
After a second you should see your sensor tag print out on your terminal. Once it has you can enter a ^C to stop the scan. For the next step you will need the address of you sensor tag which is highlighted in green above.
Congratulations you have now successfully scanned your sensor tag. Next up reading data from the sensor tag.