Join Michael Lehman for an in-depth discussion in this video Overview of iBeacon, part of Programming the Internet of Things with iOS.
- All right, we've talked about generic Bluetooth low energy devices. Now we're going to talk about a very specific implementation of a device using Bluetooth low energy that Apple introduced with iOS 7, called the iBeacon. It's really hard to design products by focus groups. A lot of times, people don't know what they want until you show it to them. Steve Jobs. The iBeacon is a standard, it's not a device. Apple doesn't make any iBeacons, there are multiple manufacturers that make iBeacons, and they're simply little tiny Bluetooth devices, that do three things, they advertise a specific UUID, and then they have two other numbers called a major ID and a minor ID, that are programmed by people who are configuring the Beacons.
We're going to talk about connecting the iBeacons, we're going to talk about how iBeacons use core location in order to both give you the ability to detect how far away you are from a particular Beacon, and also how core location can call you back when you get close to one, and this is the geofencing mechanism that's built in to core location, and then we'll talk about some applications of iBeacon. iBeacon standard, as I said, was introduced in iOS 7, it's specifically a Bluetooth LE device, and you have an application defined UUID. So, for example, if you had one retail store in a mall, potentially all the iBeacons in that particular store would have the same UUID and different major and minor numbers to tell you whether you're in the card department, or the pen department, or the stationary department say if you were in the stationary store or the shoe department, the suit department, and the sportswear department if you were in a clothing store.
The major ID and minor ID are something you program into each unique iBeacon so that you can determine when you're closest to the shoe department, versus when you're closest to the sportswear department. You can get commercially available iBeacons right now. They're inexpensive, and they basically are a BLE device with a battery. You can get them from Kontakt.io, Estimote, and we have some estimotes here which we'll show you how they work, Gimbal, Roximity, and StickNFind. There may more companies making iBeacons by the time you watch this particular movie, so check out Google for looking for iBeacon device, or go to that iotlist.co where you'll find notifications whenever anybody releases a new device like this.
Connecting to an iBeacon is simple. They are Bluetooth, but they are not accessed using core Bluetooth, all the stuff that we saw before is great, you can find an iBeacon by that but you can't get that iBeacon ID and the major and minor. That requires specific code that's implemented in iOS 7, and licensed to the iBeacon manufacturers for running on their devices. The device GUID is not the same as the iBeacon UUID. So if you use the BLE scanner to find your iBeacon the ID you get back is not going to be the one you can use with core location. You have to know what that is.
The iBeacon API is very simple to use, and we built a little iBeacon application and I'm going to show you how that works right now. So let me show you how it works, and then we'll talk about how it's built. The first thing that has to happen in your iBeacon app, is you have to be able to allow the user to give permission. And so there's a specific key, which I'll point out to you in the info.p list, which you have to put the string that shows up down here which I just put in detecting iBeacons. So I'm going to go ahead and click allow. Now you see it says, "Starting scan." and there, it thinks that I've got an iOS device somewhat near, because it's Bluetooth, it thinks that I'm a little close, a little far, it goes back and forth, but now, if I put it over here right next to the iOS device, now it thinks it's immediate.
And if I pick it back up again, and I hide it behind my back here, it thinks it's now gone from immediate back to far. If I take the battery out, in a short while, it will think we've left the region. And there we go, now it's decided that we're out of the range of the iBeacons, so we've exited the region. And this is all the various callbacks that you get from core location, both region entered and exited, as well as proximity detection, near, far and immediate. And this app we're going to give you the source code for, you'll find it in the exercise files, and we'll go take a look at the contents of that app in just a minute.
- Exploring the IoT universe
- Understanding sensors and effectors
- Connecting inputs and outputs
- Connecting to devices via Wi-Fi or Bluetooth
- Using Apple iBeacon
- Creating your own things with programmable hardware
- Using IFTTT to program things
- Exploring trends in IoT