Raspberry Pi 3 as an Eddystone URL beacon

Mar 16, 2016

This tutorial will show you how you can take your Raspberry Pi 3 and turn it into an Eddystone URL beacon.

What you will need:

  • A Raspberry Pi 3
  • Power supply for the Raspberry Pi
  • SD card for the raspberry pi

What is an Eddystone beacon:

Eddystone is a protocol specification by Google that allows a Bluetooth low energy device to broadcast one way messages. See https://github.com/google/eddystone. Currently the specification defines three types of messages that can be broadcast: a UID, a URL, or telemetry.

The magic of the Eddystone beacon is on the app side where your phone listens for these broadcast messages and either displays an alert when it detects something or performs some kind of action.

In this tutorial I will show you how to setup your Raspberry Pi 3 to broadcast a URL.

Setting up the Pi

  1. Download Raspbian from https://www.raspberrypi.org/downloads/
  2. Install the Raspbian Image
  3. Find the ip of the raspberry pi with from your laptop/desktop
  4. Log into the Pi (password is raspberry)
    •  $ ssh pi@<the_ip_of_your_pi>
      
  5. Look at the help of the hciconfig command
    •  $hciconfig -h
      
  6. Enable the Bluetooth device
    •  pi@raspberrypi:~ $ sudo hciconfig hci0 up
      
  7. Set the Bluetooth device to “advertise and not-connectable”
    •  pi@raspberrypi:~ $ sudo hciconfig hci0 leadv 3
      
  8. Enter the Beacon Advertising Data
    •  pi@raspberrypi:~ $ sudo hcitool -i hci0 cmd 0x08 0x0008 17 02 01 06 03 03 aa fe 0f 16 aa fe 10 00 03 77 65 62 67 61 7a 65 72 08 00 00 00 00 00 00 00 00
      

Here is a breakdown of the payload

OptionDescription
0x08#OGF = Operation Group Field = Bluetooth Command Group = 0x08
0x0008#OCF = Operation Command Field = HCI_LE_Set_Advertising_Data = 0x0008
17Length. The hexadecimal 17 converts to 23 decimal which is the number of bytes that follow
02Length
01Flags data type value
06Flags data
03Length
03Complete list of 16-bit Service UUIDs data type value
aa16-bit Eddystone UUID
fe16-bit Eddystone UUID
0fLength. The hexadecimal 0f converts to 15 decimal which is the number of bytes that follow
16Service Data data type value
aa16-bit Eddystone UUID
fe16-bit Eddystone UUID
10Frame Type = URL
00TX Power (this should be calibrated)
02 changed to 03
URL Scheme (http:// = 0x02)(https:// = 0x03). See 2016-13-09 edit comments.
77‘w’ in hexadecimal
65‘e’ in hexadecimal
62‘b’ in hexadecimal
67‘g’ in hexadecimal
61‘a’ in hexadecimal
7a‘z’ in hexadecimal
65‘e’ in hexadecimal
72‘r’ in hexadecimal
08.org (.org = 0x08)
00
00
00
00
00
00
00
00

The command above broadcasts my blog’s URL https://webgazer.org.
If you want to advertize a different URL enter the URL of the link that you want to advertize in the link below.

http://yencarnacion.github.io/eddystone-url-calculator/

To detect the Raspberry Pi beacon with an iPhone follow the steps in the video below which outlines how to enable Chrome’s Physical Web extension on iOS https://www.youtube.com/watch?v=gxPcPXSE_O0

On Android, your phone should detect the URL if you have Android 4.3.2 or higher with bluetooth turned on, location turned on, and Chrome location runtime permission turned on. Seehttps://support.google.com/chrome/answer/6239299?hl=en. However, I had to install the Physical Web App from https://play.google.com/store/apps/details?id=physical_web.org.physicalweb&hl=en to make it work.


Edited 2016-13-09

As pointed out in the comments, Google made a change so as to require https in order for chrome to detect the URL Beacon. So in order to fix a change was made in the URL Scheme from http:// = 0x02 to https:// = 0x03.