I was recently at a tech conference where they decided to retrofit us with bluetooth beacons. I wasn't too keen on this. I decided to call them out on it.
They gave me a generic response, and I decided to push this a little further. I wanted to make my displeasure as public as possible without harming the attendees of the conference. Since the ODTUG group and its users love twitter, I decided to make something that tweeted how many beacons it saw around it, in real time.
To the bar! I used all of my laptop's internal and external battery to make this happen. The beer was good, the server was awesome (shout out to Jennifer) and the pizza was good.
The result of my coding session was a Bluetooth 4.0 scanner. I was on a little bit of a power trip. The LinkIt ONE was the perfect board for this endeavor.
I've fought with interesting limitations that the LinkIt ONE has had for years, but I was willing to work around anything to make this happen.
I first looked for scanning code specifically for the BT 4.0 bands. The ONE can scan in BT 2.0, 4.0, and 2.4GHz wifi, so it was important to just focus on the end goal here. I got my BT 4.0 scanner going (picture above) and tried it out at the conference the next day. I then just focused on getting the count of the beacons heard. Once I had that, I created a Maker Channel in IFTTT to push that count to.
From here, I read the documentation on how to trigger the event, and made a recipe to push a tweet to an account made just for this.
The code from this site was instrumental to making my code work: https://gist.github.com/outofmbufs/d6ced37b49a484c495f0
By slowly putting the pieces together, I was able to make a tweeting object. Here's the jist of how the code works:
- For one second, count the number of BT 4.0 beacons.
- After 60 cycles, connect to web by wifi or cellular connection.
- Create POST event and send it.
- Start cycle again.
My original design used wifi, but the LinkIt ONE seems to not be able to handle multi-node wifi, even ones without passwords. I was directed to Hologram from a friend, and have had success with the implementation of that. In looking up my code for the GPRS version, it seems like that code was not saved. Maybe I'll recreate it at some point.
Since I had the code working, I needed to give the LinkIt ONE a proper home. I had acquired a viking hat from a trivia night (go team BI!) and thought this would be perfect. Although I didn't wear the hat for very much of the conference, the ONE's proper home was inside of one of the horns where the battery and unit fit very nicely.
After all this was said and done, the members of ODTUG and I talked, and we are all friends now. This was a proof of concept I made to show them that even the best intentioned ideas can be exploited. Remember folks, beacon safely.
Comments