iBeacons are playing very important role in this era of Internet of Things. Recently, a lot has been written about them, but there are actually just a few sources explaining the technical perspective. This article should very briefly explain how iBeacons communicate with other devices.
“iBeacon is an indoor positioning system that Apple Inc. calls “a new class of low-powered, low-cost transmitters that can notify nearby iOS 7 devices of their presence.” They can also be used by the Android operating system (limited to central-only). The technology enables an iOS device or other hardware to send push notifications to iOS devices in close proximity.”
The iBeacon works on Bluetooth Low Energy (BLE), also known as Bluetooth Smart. Bluetooth LE can also be found on Bluetooth 4.0 devices that support dual mode. In a real life scenario it would be more of a location-aware, context-aware, pervasive small wireless sensor beacon that could pinpoint users’ location in a store: iBeacons could send notifications of items nearby that are on sale or items customers may be looking for, and it could enable payments at the point of sale (POS) where customers don’t need to remove their wallets or cards to make payments. It could be a possible Near Field Communication (NFC) competitor.
To understand how iBeacons work, we need to start with BLE.
BLE – Bluetooth Low Energy
iBeacons use BLE (Bluetooth Low Energy) technology also marketed as Bluetooth Smart. BLE was introduced under the name Wibree by Nokia in 2006 and is part of the Bluetooth 4.0 specification since it was merged to Bluetooth standard in 2010. BLE uses different protocol than Classis Bluetooth and therefore is not backwards-compatible. Bluetooth LE uses the same 2.4 GHz radio frequencies.
So except Classic Bluetooth, we have 2 more types of Bluetooth peripherals:
- Bluetooth Smart Ready – dual-mode device compatible with both Classic and LE
- Bluetooth Smart – LE-only device which is not compatible with Classic Bluetooth
Most of the newest mobile devices and computers support Bluetooth Smart Ready (so both Classic and LE protocols). iBeacons are (usually) LE-only devices and therefore not compatible with older Classic Bluetooth.
The biggest advantage of BLE is its low energy consumption. This enables iBeacons to transmit a signal continuously on a single button cell battery for a couple of years (usually 2-3 years). As with the Classic Bluetooth, LE can reach up to 100 meters.
How does BLE communication work
Without going too deep into details, there are two modes of communication:
- advertising – one-way discovery
- connecting – two-way communication
iBeacons use only advertising mode and I’m not going to talk about connecting mode (for those who are interested, you can look at Apple’s Core Bluetooth guide). As I said before, iBeacons run in the advertising mode. This means they periodically send packets of data that can be received by other devices like smartphones or tablets. iBeacons behave like a beacon that is only sending “Here I am!” signals and not listening. This messages can be transmitted in intervals from 20 ms to 10 seconds and the longer the interval, the longer is the battery life.
iBeacons transmit packets and its size can by up to 47 bytes. Following is a diagram of this packet broke down to particular blocks.
So the BLE packet in advertising mode consists of:
- Preamble (1 byte)
- Access Address (4 bytes) – always
- PDU Header (2 bytes)
- PDU MAC address (6 bytes)
- PDU Data (0-31 bytes)
- iBeacon prefix (9 bytes)
- Proximity UUID (16 bytes)
- Major (2 bytes)
- Minor (2 bytes)
- TX power (2 bytes)
- CRC (3 bytes)
The most important block for us is the PDU Data. Following is an example of this block split into sub-blocks:
02 01 06 1A FF 4C 00 02 15 # iBeacon prefix (fixed)
B9 40 7F 30 F5 F8 46 6E AF F9 25 55 6B 57 FE 6D # Proximity UUID
00 49 # Major
00 0A # Minor
C5: 2’s complement of measured TX power
Let’s explain meaning of each block (line):
iBeacon prefix (1st line) – these are 9 fixed bytes with the following meaning. iBeacon prefix indicates that this BLE device is actually an iBeacon device.
01 # Flags AD type
06 # Flags value
1A # Number of bytes that follow in second (and last) AD structure
FF # Manufacturer specific data AD type
4C 00 # Company identifier code (0x004C == Apple)
02 # Byte 0 of iBeacon advertisement indicator
15 # Byte 1 of iBeacon advertisement indicator
Proximity UUID (2nd line) – is an identifier that distinguishes your iBeacons from the others. Your mobile app is then set up to listen just to this proximity UUID.
Major (3rd line) – is used to group a related set of iBacons.
Minor (4th line) – is used to identify individual iBeacons.
2’s complement of measured TX power (5th line) – actual TX power can be calculated as a 2’s complement: 0xc5 = 197 => 256-197 = -59 dBm. TX power is the strength of the signal measured at 1 meter from the iBeacon. This number is then used to determine how close you are to the iBeacon. The calculation is based on the fact that you know TX power (RSSI at distance of 1 meter from the iBeacon) and current RSSI (Received Signal Strength Indication). iOS does the calculation for us. Other platforms need to calculate it – the only one example I found: http://stackoverflow.com/questions/20416218/understanding-ibeacon-distancing
So what exactly iBeacon is?
It’s a Bluetooth LE device with the specific packet format. Other devices recognize iBeacon by the PDU Data block (exactly by the first 9 bytes of this block) and based on this data block can determine their distance from the iBeacon. This means, that every device capable of BLE can be turned into an iBeacon. iBeacons are widely used for micro-location purposes (especially inside buildings where GPS or other technologies aren’t capable of accurate results).
In the next article, I will show you how to turn your smartphone, tablet or laptop into an iBeacon transmitter. I’m also exploring how machine learning could be used together with iBeacons in order to locate devices inside buildings.
Where to get iBeacons
- and more…