# Bluetooth Proximity

This post is going to cover aspects of determining proximity with Bluetooth devices and hence covers a couple of key pieces of data.

RSSI stands for Received Signal Strength Indication as is a measurement of radio signal strength, measure in dBm (decibel-milliwatts). The higher the RSSI value, the stronger the signal.

Signal strength can be affected by many things. Along with the obvious environment affects, such as walls and interference the different chipsets used can give wide variations and hence cannot be guaranteed to indicate whether one Bluetooth device is actually closer than another.

To use RSSI effectively to try to approximate proximity, at least in terms of whether we’re getting closer to the device or moving further away, we should track multiple samples of RSSI over time. If the signal is getting weaker then we might suggest the device is getting further away (ofcourse taking into account any environment and others forms of interference).

RSSI can be calculated (although it will likely be available from your preferred Bluetooth LE library) using the following formula (although this includes distance as a parameter which is, after all what we’re after with proximity so unlikely to have).

```RSSI = -10n log(d) + A

where

d is distance
A is txPower
and
n is a signal propagation constant
(for example it might be set to 2 in free space, but
vary in a walled area).
```

In situations where we have RSSI only (i.e. no TX Power) we can approximate proximity using the signal strength by checking the RSSI against the following range of values

RSSI of -50dBm to 0dBm – very close
RSSI of -90dBm to -50dBm – medium distance
RSSI of less than -90dBm – far away

However, as stated, signals may be affected by different forms of interference and also by the chipsets and power used for the radio, so can only be taken as “guesses” to proximity.

TX Power

If you see the an option on your preferred Bluetooth LE library called txPower which stands for transmitted power (also known as measured power).

Note: This doesn’t seem to be available/used by all Bluetooth devices. In which case it’ll be defaulted to zero.

TX power is used within the previous formula (along with the RSSI value) to help determine distance or proximity estimates. It allows us to take into consideration the actual power of the Bluetooth device as it’s a calibrated (read-only constant) which indicates the expected RSSI at a distance of 1 metre from the Bluetooth device. So with RSSI and TX Power we can rearrange the previous equation to calculate distance, here’s a C# implementation of that

```public static double GetProximity(int rssi, int txPower)
{
const int signalPropagationConstant = 2;
return Math.Pow(10d, ((double) txPower - rssi) / (10 * signalPropagationConstant));
}
```

Obviously when calculating proximity with a 0 txPower the distance will no longer be valid and hence you’ll have to simply have to use sample RSSI to get a basic idea of signal strength).