maanantai 25. huhtikuuta 2016

Turn your RaspberryPi 3 into a Bluetooth Beacon

You can do it!

Raspberry Pi 3 has built-in Wifi and Bluetooth. With a few lines of commands anyone can turn Raspi 3 into a beacon which broadcasts URL of one's choice via Bluetooth. It's not that tricky at all! Read on!

Eddystone by Google

There are different techniques what comes to beacons. You can choose at least between Apple and Google. What we are going to try is called Eddystone brought by Google. And hey, even Apple's devices (with Chrome installed) are able to hear these kind of beacons.

Raspi 3 has it all ready for you

With Raspberry Pi 3 built-in Bluetooth 4 LE (Low Energy) and Raspbian Linux your beacon will be up and running in no time! So go and get you gear and burn OS on a microSD-card. Next, the actual setup of a beacon.

Setting up a beacon

Type in the following commands using Terminal app.

Become superuser:

sudo su

Enable Bluetooth in Raspberry Pi 3:

hciconfig hci0 up

Let Bluetooth advertise and make it not-connectable:

hciconfig hci0 leadv 3

Set up an advertisement which Raspi3 will broadcast (in my case the URL is http://www.edupoli.fi):

hcitool -i hci0 cmd 0x08 0x0008 18 02 01 06 03 03 aa fe 10 16 aa fe 10 00 00 65 64 75 70 6f 6c 69 2e 66 69 00 00 00 00 00 00 00

Don't copy the code above but visit Eddystone URL command calculator and create advertisement of your own.

That's it! Your beacon is now up and running! Next: how to receive the URL which Raspi 3 is broadcasting?

Physical Web

Android:

Make sure Bluetooth and Location are on. Find them in Settings. Download Physical Web app from Play Store and install it: https://play.google.com/store/apps/details?id=physical_web.org.physicalweb&hl=en . Launch Physical Web app and let it search for beacons.

iPhone/iPad:

Please visit the following URL and follow the instructions in video to turn Physical Web on: https://www.youtube.com/watch?v=gxPcPXSE_O0

If you can't reach your beacon read through these instructions how to setup your phone/tablet: https://support.google.com/chrome/answer/6239299?hl=en


Download Physical Web app
from Play Store

Fire up the app and let it
look for beacons

There you have it!

iPhone 4S can hear a beacon
in the neighbourhood







4 kommenttia:

  1. Olipas vaivatonta! Miten tuon majakan saisi kaikkein helpointen käynnistymään automaattisesti Raspin käynnistyessä?

    VastaaPoista
  2. Tuossa pitää tutkia Raspbiania, joka on siis Debian. Varmaan tulisi kirjoittaa skripti, joka ajetaan automaattisesti käynnistyksen yhteydessä.

    VastaaPoista
  3. Hi, is it possible to run Physical Web app on Android Wear (Moto 360)? I don't always have my phone on me, and would like my smartwatch to detect when it is near the Raspi.

    VastaaPoista
  4. Actually I don't know. Please let me know if it's possible!

    VastaaPoista