Using Beacons with Smartphone Apps

Bluetooth beacons are a powerful tool for creating personalised experiences through mobile apps. They work by transmitting signals that can be detected by all smartphones. When a user comes within range, the app detects the beacon’s signal and identifies the user’s proximity to a specific location.

This enables the delivery of contextually relevant content, such as detailed information or reviews when a customer approaches a product in a retail store. It also allows for personalised recommendations based on a user’s location and past behaviour, offering tailored suggestions that match their interests.

Interactive experiences are another feature made possible by Bluetooth beacons. They can trigger app-specific actions based on user location, such as providing wait times and virtual queuing options in an amusement park. Additionally, they assist in wayfinding and navigation within large venues by providing directions and highlighting points of interest.

Utilising Bluetooth beacons for personalised experiences benefits businesses in numerous ways. They enable enhanced engagement with customers by delivering timely content, fostering a stronger connection and loyalty. They improve customer satisfaction by providing tailored information and recommendations, making customers feel more valued. Sales and conversion rates are also boosted by offering targeted promotions when customers are near specific products.

Bluetooth beacons gather valuable data that provides insights into customer preferences and behaviour, helping businesses optimise operations and make data-driven decisions to enhance their offerings and marketing strategies.

Android and iOS use included operating system APIs to detect Bluetooth beacons. When an Android application detects a beacon, it gets a callback to a function including the signal level (RSSI), where developers can specify the app’s operation. On iOS the framework includes classes to represent beacons and beacon regions, enabling monitoring and ranging, i.e., determining the approximate distance to a beacon. When an app registers to monitor a specific beacon region, iOS notifies the app if the device enters or exits that region. This happens even if the app isn’t running at the time. Furthermore, if the app is currently in use, it can continually receive updates about nearby beacons and their relative distance.

In both Android and iOS, the apps don’t connect with the beacons. Instead, they detect the Bluetooth signals that the beacons broadcast. Also, both systems require the user’s permission for the app to access Bluetooth and location services.

Which Beacons Transmit a MAC Address?

A MAC (Media Access Control) address is a hardware identification number that uniquely identifies each device. In the context of Bluetooth, a MAC address is used to identify a specific Bluetooth device, such as a smartphone, headset or a Bluetooth beacon. All beacons transmit a Bluetooth MAC Address which is a 48-bit address usually represented in hexadecimal format like this: 0123456789AB.

All devices such as smartphones can see the incoming MAC addresses that are sent as part of the device discovery stage rather than the main Bluetooth LE advertising payload. iOS is a bit strange and non-standard because it hides detected Bluetooth MAC address from apps, and hence from users, when detecting beacons and other Bluetooth devices.

No such restriction happens on Android or any other device. The rationale is probably that Apple wants you to use their ids, the iBeacon UUID, major and minor or the Peripheral Id rather than the MAC address. Apple also probably think they are protecting privacy in some way. A few beacons and other devices such as sensors and fitness trackers additionally put the MAC address into the advertising payload which circumvents Apple’s restrictions and allows reading of the MAC address by apps.

Can I Use My Phone as Bluetooth Beacon?

A question that often arises is, “Can I use my phone as a Bluetooth beacon?” The answer is ‘yes’.

Before we get into the details, it’s essential to understand what a Bluetooth beacon is. In simple terms, a Bluetooth beacon is a small wireless device that transmits a periodic signal to other Bluetooth-enabled devices within its range. This technology is often used for indoor positioning, sensing and other location-based services.

Technically, yes, a smartphone can function as a Bluetooth beacon. Both Android and iOS platforms offer apps to turn your phone into a beacon transmitter. However, there are some caveats.

Using your phone as a Bluetooth beacon can be a significant drain on your battery. Beacons are designed to be low-energy devices that can run for years on a single battery. Your phone, on the other hand, has many other functions that consume power, so using it as a beacon will lead to the need for frequent charging.

The range of a dedicated Bluetooth beacon can be up to 100 metres, depending on the model and settings. A smartphone’s Bluetooth range is generally much shorter, limiting its effectiveness as a beacon.

While there are apps such as Locate Beacon, Beacon Simulator (for iOS), Beacon Simulator, nRFConnect (for Android) that can turn your phone into a beacon, these are often not as reliable or feature-rich as dedicated beacon hardware. You won’t be able to change all the settings such as power, advertising period and advertising type as you would with a dedicated hardware beacon. Additionally, running such an app in the background may interfere with other phone functions and some phones eventually close long running services.

Despite these limitations, there are scenarios where using your phone as a Bluetooth beacon could be useful. If you’re a developer or a business looking to experiment with beacon technology, using a phone can be a cost-effective way to test your ideas before investing in dedicated devices.

While it’s possible to use your phone as a Bluetooth beacon, it’s generally not the most efficient or reliable method for most applications. However, for personal use or small-scale use, it can serve as a convenient alternative. If you’re considering implementing beacon technology on a larger scale, investing in inexpensive dedicated hardware is usually the better option.

View Bluetooth beacons

Reverse Engineering iBeacon and Eddystone Bluetooth GATT Services

For some of our beacons such the manufacturers haven’t documented their Bluetooth Service Characteristics. This means that while they are ok for scanning/proximity type applications, you can’t write your own app to, for example, change programmatically the UUID, major and minor, transmit power, advertising period and must rely on the manufacturer’s configuration app. While this of no consequence for the majority of uses that set and forget settings, more ambitious scenarios might want directly access the Bluetooth GATT services to change settings.

Uri Shaked has a great article on Medium on how to Reverse Engineer a Bluetooth Lightbulb. His method uses the developer logging in Android 4.4 and later to allow inspection of the Bluetooth packets and hence the Bluetooth Services and Characteristics that are being used. This method can equally be used with iBeacon and Eddystone beacons to reverse engineer the Bluetooth GATT information.

Another method is to use a Bluetooth sniffer. This listens in on the Bluetooth communication between two devices. One way of doing this is with Nordic Semiconductor’s Sniffer software on a dongle. There’s a tutorial on JimmyIoT.

It’s usually ill-advised to reverse engineer interfaces to discover undocumented features because the manufacturer can change the implementation thus breaking your solution. However, it’s very rare that firmware is ever updated in beacons and when it is, it’s usually only to fix bugs rather than change the implementation.

Processing on Bluetooth Device or Smartphone?

There’s often a dilemma when creating Bluetooth systems whether to place the processing on the smartphone or on the Bluetooth device.

The efficient and accurate prediction of an individual’s heart rate using wearable devices is crucial for various personal care applications. A new study Energy-efficient Wearable-to-Mobile Offload of Machine Learning Inference for Photoplethysmogram-based Heart-Rate Estimation (pdf) from the Universita di Bologna, Italy, looks into the trade-offs between carrying out heart rate tracking on the device itself or delegating the work to a mobile device.

The research introduces CHRIS, an inference system that uses the interconnectedness between a smartwatch and a smartphone. This system assesses the balance between energy consumption and heart rate tracking error. Depending on the connection status, a user-specified error, energy constraints and an estimate of the input difficulty, CHRIS employs two heart rate prediction algorithms. These are executed on either the smartwatch or the phone.

CHRIS showed the potential to achieve up to 2.03 times energy reduction on the smartwatch by deferring processing off the smartwatch, without a reduction on the tracking accuracy.

The Advantage of iBeacon over Eddystone and AltBeacon

iBeacon, Eddystone and AltBeacon are the three main beacon technologies. All of them use the standard Bluetooth Low Energy (LE) advertising format. Bluetooth LE is designed for short bursts of radio that uses little power and is therefore suitable for battery operation. Each of the advertising variants uses a unique advertising packet format that defines what kind of data the beacon transmits.

iBeacon, launched by Apple in 2013, was the first to adopt this technology and created a new wave in proximity services. It uses a simple advertising format, which consists of a UUID (universally unique identifier), Major, and Minor identifiers.

Eddystone, introduced by Google in 2015, offers a more complex advertising packet format with four different frame types: Eddystone-UID (similar to iBeacon’s UUID), Eddystone-URL (broadcasting web address), Eddystone-TLM (telemetry information about the beacon itself), and Eddystone-EID (an encrypted version of Eddystone-UID for secure applications).

Altbeacon, an open-source specification introduced by Radius Networks, provides a simpler format similar to iBeacon.

The functionality of beacon technologies are different on iOS and Android due to differences in the operating systems themselves. Apple’s strict app guidelines and strong emphasis on user privacy limit the ability of apps to perform tasks in the background. For instance, iOS only allows apps to scan for iBeacon formatted advertisements in the background using the CoreLocation library, not CoreLocation. Eddystone or AltBeacon can only be read in background using CoreLocation. Android offers more flexibility for background tasks and can work with iBeacon, Eddystone and Altbeacon.

Although Eddystone and Altbeacon have their merits, iBeacon is the advertising of choice for most scenarios involving smartphone apps due to the integration with iOS.

How to See Bluetooth LE Advertising on Android and iOS

To see Bluetooth LE advertising on smartphones, you can use a Bluetooth scanner app. These apps are available from the App Store and Google Play Store and can be downloaded and installed on your smartphone.

To use a Bluetooth scanner app, follow these steps:

  1. Open the App Store Google Play Store on your device and search for “Bluetooth scanner” or “Bluetooth advertising”.
  2. Select a Bluetooth scanner app that you want to use and install it on your device. nRFConnect is a well-known scanner, provided by Nordic Semiconductor, the manufacturer of the Bluetooth System-on-chip in most beacons.
  3. Once the app is installed, open it and enable Bluetooth on your device, if it is not already enabled.
  4. The app will scan for nearby Bluetooth devices that are broadcasting advertising packets. It will display a list of the devices it finds, along with their names and other information.
  5. You can tap on a device in the list to see more details about it, such as its Bluetooth address (only on Android), signal strength, and any advertising data that it is broadcasting.

In summary, using a Bluetooth scanner app is a simple and effective way to see Bluetooth advertising on an smartphones. These apps allow you to see the devices that are broadcasting advertising packets, as well as the data that they are transmitting.

Background Bluetooth Scanning on Android

There was a time when it was very easy to scan for beacons in background on Android. You just set up a service using the standard Bluetooth APIs. Over the years, Google has crippled the ability to perform reliable background processing to the point where it’s nearly as bad as on iOS. David Young says:

“Today, Android Services are often more trouble than they are worth”

David has an answer to the problem in the form of using Android BroadcastReceivers and threads. He explains the problem and solution on his blog. David also has a useful Github app demonstrating the technique.

Read about custom solutions

Working with GATT on Android

Most of the time, beacons transmit and the receiving software such as apps on iOS and Android or applications on single board computers (SBC) only read the advertising data. There’s no connection to the beacon. However, for programmatic setup of beacon parameters or accessing some sensor data, applications might need to connect via what’s known as Bluetooth GATT.

There’s an article on How to Work Properly With BT LE On Android. It provides some useful pointers such as not performing scanning and GATT connection simultaneously, avoiding auto-connect and not blocking GATT callbacks.

GATT can be unreliable on Android. While scanning for advertising data usually works very well, we have found that GATT connections fail all the time on about 5% of devices. This is due to poorly implemented OS Bluetooth software. This means beacon manufacturer-supplied configuration apps sometimes can’t connect. The only solution is to use a different phone (or the iOS version of the app on iPhone).

Troubleshooting Beacon Problems

Some people come to us, having set up their beacons, saying “It doesn’t work”. Most scenarios involve a beacon, an app and a phone. Solving most problems involves breaking the problem down by swapping out each of the beacon, app and phone until it works.

If you have more than one beacon, you can swap out the beacon. Having said this, it’s rare for beacons to fail and if the problem is with the beacon, it’s more likely to be the beacon settings that are incorrect.

While you can’t swap out the manufacturer configuration app, you can use another app such as Nordic’s nRF Connect (on iOS and Android) to scan for a beacon, see if it’s advertising and if so, what type of advertising it is sending.

It’s common for individual phones to have have problems. First, make sure you have Location and Bluetooth on. Anyone working with beacons will usually need to have both Android and iOS devices to diagnose problems. Run the app (and nRF Connect) on multiple phones of different platform type (iOS/Android) to help narrow down problems.

If you still can’t get it working, send us a support ticket. Please don’t just say “It doesn’t work” and instead describe what you have done and at what stage it doesn’t work with any error messages.

Also read

Why Doesn’t the Manufacturer’s Configuration App Connect?

Testing if a Beacon is Working