Understanding Ibeacon Distancing

Understanding ibeacon distancing

The distance estimate provided by iOS is based on the ratio of the beacon signal strength (rssi) over the calibrated transmitter power (txPower). The txPower is the known measured signal strength in rssi at 1 meter away. Each beacon must be calibrated with this txPower value to allow accurate distance estimates.

While the distance estimates are useful, they are not perfect, and require that you control for other variables. Be sure you read up on the complexities and limitations before misusing this.

When we were building the Android iBeacon library, we had to come up with our own independent algorithm because the iOS CoreLocation source code is not available. We measured a bunch of rssi measurements at known distances, then did a best fit curve to match our data points. The algorithm we came up with is shown below as Java code.

Note that the term "accuracy" here is iOS speak for distance in meters. This formula isn't perfect, but it roughly approximates what iOS does.

protected static double calculateAccuracy(int txPower, double rssi) {
if (rssi == 0) {
return -1.0; // if we cannot determine accuracy, return -1.
}

double ratio = rssi*1.0/txPower;
if (ratio < 1.0) {
return Math.pow(ratio,10);
}
else {
double accuracy = (0.89976)*Math.pow(ratio,7.7095) + 0.111;
return accuracy;
}
}

Note: The values 0.89976, 7.7095 and 0.111 are the three constants calculated when solving for a best fit curve to our measured data points. YMMV

calculate accurate Ibeacon distance

Be careful not to set unrealistic expectations in the degree of accuracy you can get. Estimating distance with Bluetooth signal levels provides at best a rough estimate of distance, but there are many pitfalls that can make it not work well.

For best results:

  • Set your beacon transmitter to as high of a value as possible to increase the signal to noise ratio and make rssi more consistent.

  • Set the beacon advertising rate to as high as possible to get as many statistical samples as you can to average out noise.

  • Adjust your txPower constant to be the measured average RSSI at one meter on a specific device receiver to be used in distance estimation.

  • If you find consistent over or under estimates with the formula, adjust the constants as needed for best fit.

Realize that obstructions (even human bodies), reflections, radio noise, phone cases, and even different phone models will all affect results. Estimating distance at 2-3 meters works best. At greater distances, you will see a much higher error rate as the signal level drops off exponentially with distance.

What are the nominal distances for iBeacon Far, Near, and Immediate

From what I understood of the API is that there is never a guarantee on actual distance, you should not use the readings to be considered an accurate measurement. The proximity is rather used to determine the relative distance between different beacons so that you can respond accordingly based on your applications requirements.

With that said, Apple definitely draws a gray area in their documentation. The description of measuredPower is intriguing and easily instils the thought that you can use this value to get an accurate distance reading (once calibrated of course). I just don't think that is the case however, with the likelihood of signal attenuation in these significantly low powered devices, I don't expect you'd get consistently accurate readings of an actual distance.

From the CLBeacon reference the description of accuracy reads

Indicates the one sigma horizontal accuracy in meters. Use this
property to differentiate between beacons with the same proximity
value. Do not use it to identify a precise location for the beacon.
Accuracy values may fluctuate due to RF interference
.

I feel that this inexplicably resonates throughout the entire usage of the iBeacon feature.

This is all my interpretation, I've not gone as fas as testing this in multiple environments over time to see if consistent readings are given. I am not sure if this helps at all.

Determining Distance and Direction of iDevice from Beacon

The distance is computed by comparing the received signal strength (RSSI) with the advertised transmitted power (txPower) of the beacon, as the signal strength in theory is inversely proportional to the square of the distance.

But there are lots of other things that can affect RSSI, including obstacles, orientation of the antennas, and possibly multi-path (reflections). So it's difficult to accurately measure distance based on this information.

Another way of measuring distance is using round-trip-time (RTT): you send something to the beacon, and you measure how long it takes to come back. But this requires a fixed response time, and on this sort of scale (meters), there are probably enough variable delays here and there that it might severely affect the calculation.

Direction would require either triangulation or multiple directional antennas, I don't believe that's the case in this scenario.

In short, you can get a rough idea of the distance (which is why it's good for proximity alerts), but accurate distance or direction would require different technologies.

Why do you need them? There may be alternatives based on your specific scenario.

EDIT

If you have a large number of beacons around, and you know their exact positions, it might be possible to pull off the following:

  • use at least 3 beacon distances to compute your exact position by triangulation
  • from there, as you know the position of the beacons, you can compute the distance and direction of any of the beacons (or anything else, really)

Of course, depending on the actual accuracy of the beacon distance measurement provided by the SDK, the result might be more or less accurate. The more beacons you have, the more precise you should be able to get (by picking only those that return a distance, or by eliminating those that are not "compatible" with the others when computing solutions).

How does an ibeacon compute accuracy in terms of advertising interval and samples collected?

The exact algorithm that iOS uses to compute the CLBeacon accuracy property is closed source, and Apple has not revealed what it is. That said, experimentation has shown a few things:

  1. The measurement approximates a distance in meters between an iPhone and a beacon.

  2. It is based on a 20 second sample of RSSI measurements. You can see this by plotting a graph of accuracy over time and seeing that an immediate change in position of a mobile device or beacon is not fully reflected in accuracy for 20 seconds.

  3. Because of the inherent noise on RSSI measurements, higher advertising rates will give better distance estimates by having more statistical samples to smooth out the noise. iBeacons transmitting at 10Hz will have 200 statistical samples of RSSI over a 20 second period under ideal conditions.

  4. Because the formula for calculating accuracy is not published by iOS, we came up with an independent algorithm that does something similar for the Android Beacon Library. You can see that formula here.

You can see a summary of my research into this area in this blog post.

How to measure the distance between an iPhone acting like an iBeacon and an Android device

We built a distance estimation formula into the Android Beacon Library of the form: d=A*(r/t)^B+C, where d is the distance in meters, r is the RSSI measured by the device and t is the reference RSSI at 1 meter. A, B, and C are constants. You can read more about it here. To use it with the library, you range for a beacon and then simply call:

beacon.getDistance();

This returns a distance estimate in meters. The library code is open source, so if you don't want to use the library you can copy the formula and use it directly.

As @TwoStraws notes, distance estimates are pretty rough guesses of how far a beacon is away, and the results you get vary with lots of factors:

  1. The gain of the antenna on the receiving device. (Every Android device model is slightly different)
  2. The noise on the A/D converter inside the phone that measures bluetooth signal strength.
  3. The radio noise in the room.
  4. Any obstructions between the transmitter and receiver.
  5. Any surfaces (especially metal) that reflect radio signals.

Just be sure you set your expectations properly. Distance estimates are good for deciding if a beacon is close or far, or whether one beacon is closer than another. But they are less useful for measuring absolute distance.

Swift iBeacon use accuracy or rssi for distancing

The big difference between using CLBeacon's rssi or accuracy fields for sorting beacons is the variability or the number and the averaging interval.

The accuracy field is averaged over approximately 20 seconds, so it essentially gives you the estimated distance of where the device was over the past 20 seconds. The real advantage is that this number is much less noisy than rssi, but there is significant lag.

The rssi field is averaged over 1 second, so it uses many fewer data points. While it has less time lag, it also has a lot more noise. For sorting purposes if using rssi, you will see the sort order jump around a lot more.

You must set your expectations appropriately for how accurate these numbers will be as estimates of distance as @Duncan-C describes in his answer. But for some uses cases where precision is not important they can work very well.

iBeacon Advertising - Meas. Power/TX Power to determine approximate proximity to an iBeacon?

The measured power field tells the mobile device what the RSSI should be if the beacon is exactly one meter away. If the measured power is equal to the RSSI, the estimated distance will be 1.0 meters. If the RSSI is stronger (a smaller magnitude number) the estimated distance will be < 1.0 meters. If it is weaker, it will be > 1.0 meters.

There is a formula that can estimate the distance based on these two numbers: Understanding ibeacon distancing



Related Topics



Leave a reply



Submit