Traveling with Beacons: Checked Luggage Made Easy
In the last year, I have been flying a lot. Most of the time, I’m traveling to conferences all over the world to speak about this kind of thing: building cool stuff to show off what you can do with the modern web. I love what I do, but traveling can be quite a pain!
Most of the time, I’m flying, which means the agonizing, long wait for the luggage to arrive. You stand next to the luggage belt, anxiously watching each of the suit cases as they fall out of the magic, secret luggage storage belt area, and you usually hit several false positives before your piece of luggage actually arrives.
As I’m sure you’ve figured out by now, I like automating things and using technology to make life easier. So, I went ahead and thought up a cheap solution to have your luggage tell you when it’s finally arrived!
(You can even do it without any code ;)
As you might have guessed, it’s all about using beacons and notifications.
I used this solution for the first time just a few weeks ago on my flight back from ngPoland, and it worked amazingly. My travel mates were really surprised when they saw the notification about my luggage approaching, and when they saw me picking it up just 30 seconds later right off the belt.
We are going to use Bluetooth beacons for tracking the luggage. A BLE beacon is a device that constantly broadcasts some kind of information. In our case, the requirements for the beacon are really simple — as long as the address of the beacon doesn’t change (some beacons cycle random addresses to prevent tracking — which is the opposite of what we need), it doesn’t really matter what it broadcasts. However, if you have an iOS device, you will need a beacon which supports the iBeacon format — a proprietary format developed by Apple.
In my case, I used a cheap beacon that I got from AliExpress, which also supports the iBeacon format (seems like it is no longer on sale, but here is an alternative). All you need is a CR2032 battery, and you get a working solution for under $10. There are even some products that come with the batteries included — I haven’t tested them, but I am pretty sure anything that says it supports iBeacon will do the trick.
Note that for our use case battery life is not a huge factor in picking a beacon — we only need to use the beacon for a couple of hours each time (unless you’re on a crazy long flight), so even these $5 Gimbal Beacons should do the trick. They are also FCC certified, which means they are tested and verified not to interfere with other wireless equipment (such as the airplane’s radios).
The software requirements are quite simple. The main requirement would be for the app to scan for BLE devices and get a notification whenever our beacon is in range. We would probably want to start scanning as soon as we get to the luggage belt. A nice extra feature to have would be to display the Received Signal Strength Indication (RSSI) value, which would roughly tell us how far the luggage is from our device.
So, the easiest way to implement this idea would be to take advantage of an existing app that has these requirements. One such app is the free Beacon Locator for Android, which can trigger all sort of actions when a beacon is in range (or goes out of range), including a notification. Setting it up is super easy; you can scan for your beacon and then configure what happens when it gets in range. You can even configure the message that appears in the notification:
p.s. — There are many more creative use cases you can easily set up using this (or a similar) app: you could automatically switch your phone to silent mode when you approach a conference room, track the number of times you go in and out of your office, put a beacon on your cat’s collar and set up a recording of your voice saying, “NO!” every time she gets near the knitting box, configure a device to play the theme from Rocky whenever you get near a treadmill… you get the idea. Basically you can launch any app, trigger an IFTTT recipe, run a Tasker action, and do pretty much any location-based thing you could think of. Here’s some more inspiration.
With iOS, this is a little more challenging to do “right out of the box.” I had to spend about two hours, downloading a bunch of different beacon apps to find one that would work, but eventually I found an app that can scan for the beacon in the background (which is called “Region Monitoring” in iOS terminology). I finally found an app called Beacon Player which did the trick. (And yes: despite the app store screenshots showing Chinese characters, once you download it, there’s English text inside the app.)
Another challenge with iOS was that none of the apps would just scan for all beacons around and let me choose from a list. This is a limitation imposed by Apple, apparently, by design. Instead, you have to manually figure out the UUID, Major, and Minor values for the beacon. If you don’t know these values, you can easily figure out by installing the nRF Connect app on any Android device and scanning for all BLE devices around you. If you know any easier method to make it work with iOS, I would love to hear it!
So, we have got a working solution, and we didn’t have to write even a single line of code. How cool is that?
Beacons and the Web
If you have been following my blog, you have probably read about The Physical Web and about Web Bluetooth, and it probably got you thinking: can I take advantage of these web technologies for this use case?
Unfortunately, not yet. With the Physical Web, you will see a notification when a beacon is around you, but it is a non intrusive notification, which means that it won’t make any sound, won’t pop up, and won’t present any icon on the notification bar: you will only see it if you intentionally open the notification pane of your device (which more or less defeats the purpose of getting notified when your luggage arrives).
Web Bluetooth is more promising candidate for this use case, and indeed, there is actually a hack you can use in order to get notified when the beacon is in range. The trick would be to open the web page prior to handing over you luggage, and connect it with the beacon. Then, leave this page open, and as you land, click a button that will make the page repeatedly try to reconnect to the beacon. Once the connection is re-established, the page can play some sound to let you know when your luggage is arriving. The main drawback of this workaround is that you have to keep this page open all the time throughout the flight — it can go to background, but you can’t restart the phone or the browser, and you have to remember to connect with the beacon prior to boarding. Doable, but exceedingly less fun.
A much more promising path is the Web Bluetooth Scanning API, which is currently in the works. Unfortunately, it is yet to be implemented by any major browser. You can see an example of what kind of code it would take to scan for an iBeacon according to the current spec here. My bet is that we will have a working implementation in Chrome by the end of this year (though I couldn’t get any official confirmation on that).
If you are eager to create your own application and can’t wait until this is rolled out in the web, you can take advantage of Ionic 2 together with the iBeacon cordova plugin to build your own cross-platform app that will notify you when your beacons are in range.
Taking Off from Here
(Excuse the flying pun… I’ve been traveling a lot.)
Sometimes I wonder whether beacons will become more common, or if they’ll continue being used in mostly niche applications. Projects like this one, however, make me think that beacons might be of use to everyone after all–like anything, it’s just a matter of being imaginative and finding the right ideas!
One cool thing we can do now is extend the solution to solve an additional problem: instead of merely using the beacon to notify you when the luggage is arriving, we can actually program the beacon to start broadcasting your contact information about an hour after your landing, using the Physical Web. This way, if your luggage is lost, it will start broadcasting a link to a page with your contact information, so people in the place where it ended up could easily notify to you (even random people who happen to be at the same place — if they get the notification, they can ping you on WhatsApp and tell you where they are so you know where your luggage is).
This behavior requires programming the beacon (i.e. uploading a new code to it), and I plan to cover it in a future post. Stay tuned!