Website Logo. Upload to /source/logo.png ; disable in /source/_includes/logo.html

Chris Meier

Software Developer and Co-founder of FoodChain

Turning Your Raspberry Pi Into an Eddystone-URL Beacon

The Physical Web is cool new approach to the Internet of Things from Google. The Physical Web uses Eddystone beacons to broadcast URLs that can then be accessed by anyone via Bluetooth 4.0-enabled devices. This allows anyone to walk up to any object in their environment and interact with it. For example, people can walk up to a movie poster with a beacon broadcasting the URL for the trailer. One major benefit is that hardware-specific solutions don’t need to be developed – everything is done through the web. Eddystone is an open format, so there a many beacon manufacturers to choose from. However, if you don’t want to blow that kind of cash just for exploring you can make your own Eddystone-URL beacon with a Raspberry Pi. Here we will be doing just that.

For this project you will need:
1. A Raspberry Pi (I’m using a B+) with Raspbian installed
2. A Bluetooth 4.0 USB Micro Adapter
3. A Bluetooth 4.0-enabled device to read the beacon URL (such as a smartphone or tablet)

We will be using a simple Node.js to make our beacon. Go ahead and install it now if you need to. We will also need some npm modules to get our server up and running and turning it into an Eddystone beacon:

Bleno – Interfaces with the bluetooth adapter
node-eddystone-beacon – create and manage the beacon

First we will install Bleno since it is a dependency for node-eddystone-beacon. This module will allow use to interface with the Bluetooth Low Energy peripheral. It has its own set of dependencies, so we will go ahead and install those:

1
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev

We will then install Bleno:

1
npm install bleno

Finally, we will install node-eddystone-beacon:

1
npm install eddystone-beacon

We create our server and simply add a few lines that allow our beacon to serve a URL:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var http = require('http')
var eddystoneBeacon = require('eddystone-beacon');

/*set the url the beacon will advertise
If it is too long (more than 17 characters), you will need to use a URL shortener
*/
var url = 'YOUR-URL-HERE';

//set some options to customize your beacon
var options = {
  name: 'Beacon',    // set device name when advertising (Linux only)
  txPowerLevel: -22, // override TX Power Level, default value is -21,
  tlmCount: 2,       // 2 TLM frames
  tlmPeriod: 10      // every 10 advertisements
};

eddystoneBeacon.advertiseUrl(url, options);

http.createServer(function (request, response) {
    console.log(Beacon is now running);

}).listen(6000);

You can then launch the server using the following command:

1
node server.js

Your Eddystone-URL beacon is now up and running. You can see the URL using the Physical Web App for Android and iOS or by enabling the Physical Web option in Chrome via the chrome://flags settings. The option is available to add some routes to set beacon temperature and battery voltage without shutting down the beacon. You can visit the node-eddystone github page for more info. You are now set to explore the Physical Web.