Sunday, July 23, 2017

Scan For Bluetooth Enabled iBeacons Via A Raspberry Pi IoT Device

Scan For Bluetooth Enabled iBeacons Via A Raspberry Pi IoT Device

Lately I’ve been working a lot with iBeacons and Raspberry Pi Internet of Things (IoT) devices.  I’ve been building an office monitor for logging foot traffic around the office.  I planted a few Raspberry Pi devices around the office and distributed some Gimbal iBeacons to a few of my coworkers so I could determine what part of the office experiences the most heat.
While Raspberry Pi 3 devices come with integrated bluetooth, Raspbian Linux is not configured to support BLE scanning.  There are a few packages that must be installed to make BLE scanning possible.
We’re going to see what is necessary to scan for BLE iBeacons using a Raspberry Pi with Raspbian Linux installed.
To be clear, you can actually scan for bluetooth devices with the latest version of Raspbian, but it isn’t enough out of the box.  Instead, we need to install a few things.
We’re going to be using Raspbian Linux.  If you don’t already have it set up, check out a tutorial I wrote previously on the subject.  Assuming your Raspberry Pi is already up and running with Raspbian, execute the following:
BlueZ is a very popular Linux bluetooth stack and it includes tools like hcitool and hcidump.  The goal with these tools is to scan for LE data in the background and dump the data into a script.
With the appropriate tools installed, iBeacons can be scanned and dumped like the following:
The above commands are only a part of the puzzle.  The data dumped by hcidump isn’t anything nice to work with.  Instead, we can take a look at a very popular parsing tool released by Radius Networks.
If you downloaded the tool, execute it like the following:
The script will output the UUID, major, minor and power for any iBeacon that was found.  I’m personally using the Radius Networks script to pipe the iBeacon information into another application that will record it.


With the price of iBeacons and Raspberry Pi devices being so low, it makes developing with the two more enjoyable.  To scan for iBeacon devices with a Raspberry Pi, you need the BlueZ tool set and the convenient Radius Networks command line script.  There are many other ways to scan for proximity beacons on a Raspberry Pi, for example Python, but that is a story best saved for another day.

No comments: