Closed mikehenrty closed 2 months ago
Goal: Build an Eddystone beacon using my Arduino board with a BLE shield, and have it broadcast a Physical Web URL. Verify the beacon and URL are found by Google's open-source Physical Web iOS App.
Google's Physical Web
The general idea of the Physical Web is to extend the internet so that one can interact with physical objects around them. Beacons broadcast URLs that are location-sensitive in that the URL will point to a web site that is relevant to the beacon's physical location or purpose. Clients run on mobile phones and scan the area around their current location and discover messages advertised on nearby beacons.
For more details about beacons themselves see my 'Beacons and more Beacons' write-up.
For more information about the Physical Web, refer to Google's Physical Web Github repo.
Make an experiment to experience the Physical Web.
Build an Eddystone BLE beacon that omits a Physical Web URL, and have it discovered by Google's official open-source Physical Web iOS app. Eddystone beacons can be purchased however they take a few weeks to ship and are expensive for being a tiny piece of hardware. Since I already had an Arduino board I thought I would just try building my own beacon instead.
Arduino Uno, RedBear Lab BLE Shield, 9V battery, iPhone.
Arduino
Stand-alone physical web beacon, see Google's Beacons page.
Attach the RedBear BLE Shield to the Arduino board, then attach to the computer via the Arduino USB cable.
Arduino Uno with attached RedBear BLE Shield
To use the RedBear BLE Shield you have to install the corresponding Arduino libraries: "BLE SDK for Arduino" and "RBL_nRF8001". Startup the Arduino SDK and on the menu choose "Sketch" => "Include Library" => "Manage Libraries..." then search for each one. Click on each entry and click "Install".
Installing libraries in the Arduino SDK
Next I did a quick test of the BLE Shield to ensure it all works fine. With the Arduino still powered up and attached to USB:
Uploading the RedBear BLE Controller Sketch
BLE Controller App scanning for BLE Shields
BLE Controller App found the BLE Shield and pins are listed
Next I needed the code to actually change the Arduino into an Eddystone BLE beacon. Lucky for me I found this blog posting about building an Eddystone beacon from your Arduino board, and that pointed me to this open-source Arduino sketch in Github.
After grabbing the code all I had to do was change the actual URL that the beacon will broadcast; so I changed it to "www.mozilla.com" so that it would point to installing Firefox. You can find my version of the same sketch here in my iot-hacking Github repo.
The Arduino sketch mentioned above requires an Arduino library called "arduino-BLEPeripheral". So with the sketch open in the Arduino IDE, on the menu I chose "Sketch" => "Include Library" => "Manage Libraries…" then searched for ‘BLEPeripheral’, once it was found I clicked and chose ‘Install".
Installing the BLEPeripheral library in the Arduino IDE
Next I just had to compile and upload the sketch! Once uploaded the sketch starts to run on the Arduino board automatically. Uploading the beacon sketch
Now that the code is uploaded and running on the Arduino, disconnect it from the USB cable, and attach the 9V battery power supply to the board. Now we have a live stand-alone Eddystone beacon that we can move anywhere!
Finished Arduino Eddystone BLE Beacon
Next it was time to check if my Physical Web beacon is actually found! I installed the official Google Physical Web App on my iPhone, ensured that Bluetooth was turned on, and then started up the app!
As soon as I started the app, it automatically started searching for nearby Eddystone beacons, and my beacon was found. There was only my beacon nearby so it was the only one in the list.
Google's Physical Web app showing my Eddystone beacon
When I clicked on the beacon entry in the list, it automatically started my phone's browser and navigated to the URL I had coded in the sketch - and presented me with a download button to download the Firefox for iOS App. Success! :)
Result after clicking on my beacon in the Physical Web App beacon list
The code was already available open-source on Github, so it was fast to grab and modify slightly (only had to change the broadcasted URL). See the source code for my beacon in my Github iot-hacking repo.
For my Eddystone beacon it is 28 LOC (not including the supporting Arduino libraries, etc).
For the Physical Web project itself, currently there are 44 contributors on the Physical Web Github repo.
For the Eddystone Physical Web beacon protocol itself, at this moment there are 21 contributors on the Eddystone Github repo.
The beacon itself has no physical interface; to interact with the beacon Google has an open-source Android Physical Web app and a Physical Web iOS app.
Arduino
Google's Physical Web
Bluetooth Low Energy protocol Eddystone beacon protocol
There are different types of beacons out there that use different protocols, for example Apple's iBeacon. However the Physical Web project is based on Google's open-source Eddystone beacon protocol. Some beacons are manufactured to support both protocols, some for just one of them. It seems easier to get iBeacons than Eddystone beacons, at least in my limited experience trying to find an Eddystone beacon in Canada.
I don't know what kind of interest there is in the Physical Web project or how many Eddystone beacons are actually in use today. It looks like Google has a lot of support from several manufacturers to build Eddystone beacons (even though I found it hard to get one here in Canada).
Cool idea to expand the internet to physical objects that exist around our current geographical location.
Need a mobile app to interact with the Physical Web.
If the Physical Web takes off and becomes popular, IMO there is an opportunity for Mozilla to build our own Physical Web interface.
Closed-source beacon protocols, hardware, and supporting apps/infrastructure become the most popular and dominate (and silos) this emerging space. Also perhaps this entire concept doesn't gain enough traction.
See also: https://github.com/mozilla-magnet
Let's craft an experiment around Google's physical web.