Recently I turned my Puck.js into a personal Beacon that can be configured to a multitude of environments. The first version was simple & worked well but having been hacked together in a just a couple of minutes there were many things that I thought could have been done better. Happy with the outcome of these tweaks I thought I’d share my code and findings.
Turn on an LED
The constants LED1, LED2 & LED3 are setup for the Red, Green & Blue LEDs respectively. To turn on the Red LED simply run:
Broadcast a URL
Advertising a URL with Eddystone is easy. Simply required the module and then call advertise with your URL.
Note: Your URL should be no more than 17 characters long but you can use a URL shortener.
To stop advertising your URL just run:
Detecting button presses
Putting it all together we end up with the following source:
I’m keen to see how this experiment goes and how effective it is. To measure this I’ll be using Google URL Shortener to provide me with basic analytics as well as shorten any URLs that I want to broadcast. I plan on having the beacon with me when I give talks and changing the URL to point to my slides and feedback questionnaires.
I’ve really enjoyed the approachability of coding with Puck.js and Espruino. Having used other dedicated iBeacons in the past as well as Estimote beacons the Puck.js lends itself far better to being a versatile & programmable and packs much more functionality that I’m keen to explore further.