Pibeacon Ibeacon With A Raspberry Pi
Pibeacon Ibeacon With A Raspberry Pi
Pi
Created by Kevin Townsend
https://learn.adafruit.com/pibeacon-ibeacon-with-a-raspberry-pi
Overview 3
• What You'll Need
• Acknowledgement
What is a 'Beacon'? 4
•
• How Does it Work in Pratice?
Compiling Bluez 5
• Check if you already have Bluez
• 1. Install Required Libraries
• 2. Download Bluez
• 3. Unzip and Compile Bluez
• 4. Insert the USB Module and Reset
Testing it on iOS 10
This learning guide will show you how you can take your Raspberry Pi (or almost any
Linux-based device with a bit of poking and prodding) and turn it into an Beacon node
using our Bluetooth 4.0 USB Module (http://adafru.it/1327) and the open source Bluez
stack.
Acknowledgement
A big thanks to Tony Smith at The Register for putting together his tutorial () on
configuring Bluez to transmit Beacon data!
What is a 'Beacon'?
'Beacons' are based on Bluetooth Low Energy (part of the new Bluetooth 4.0
standard), and at it's heart is a way to advertise location specific data one-way, or
provide basic indoor navigation via individual Beacon nodes.
The way it works is actually very simple. Any BLE device typically advertises a certain
amount of data to let other devices (like your phone) know that they exist and they're
available. The advertising packet that these devices send out might include
information like key services offered by the device, a human-readable short devices
name, etc.
Beacons take this short advertising frame, and appends a custom payload in the
"Manufacturer Specific Data" field which includes a unique 128-bit UUID to identify
companies or unique entities, as well as two 16-bit values ('Major' and 'Minor', or
whatever you'd like to call them) that allow you to differentiate specific stores/
premises (Major) and individual Beacon nodes (Minor).
That's basically it. All the rest of the magic is on the app side where your phone
listens for these advertising frames, and when it detect something it estimates the
distance to the node and displays some sort of alert.
It's terribly simple, but that's probably what makes it so interesting and also so
inexpensive to implement!
For example, the following is a valid iBeacon payload (separators added for clarity
sake):
02 | 15 | E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 | 00 00 | 00 00 | C8
The only other missing piece is that, following the Bluetooth standard, the
Manufacturer Specific Data needs to be preceded by the Company Identifier (). The
company identifier for Apple, for example, is 0x004C, which we'll use for the example
above.
Compiling Bluez
In order to use your Raspberry Pi to send out Beacon data in the advertising frame,
we'll need to install a few open source tools, mainly Bluez
and then
You may need to type the above code in to make it work rather than doing a
copy/paste, or manually remove a superfluous line feed between lines
2. Download Bluez
sudo mkdir bluez
cd bluez
sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.11.tar.xz
If everything is properly configure you will see your Bluetooth 4.0 USB Module like
this:
If you're using the compiled bluez, add tools/ before each call to hciconfig
Then run the hciconfig tool again and you should see that the device is marked as UP
and RUNNING:
hciconfig
Testing it on iOS
To test that this actually works you'll need an iOS 7 based iPad/iPhone/iPod Touch,
and a Beacon application.
Start the app up, going into 'Listen' mode, and you should see a screen similar to the
capture below, where the range will go in and out depending on your proximity to the
node: