Just like @mlusiak said, it’s a fairly complex topic, to estimate the distance to the beacon based on the signal strength (i.e., RSSI). I’ll mention just a few things to account for:
-
RSSI will go down if you cover the beacon (e.g., a person comes in between you and the beacon). That is, you’re still in the same distance, but RSSI goes down—so where you to base the distance estimate on the RSSI, the distance would go up, without you moving an inch.
-
Beacon signal is a radio waves that bounces of walls, ceiling, floor, objects, etc. If a radio wave bounced of a ceiling, and then reached the phone, it’s strength is going to be smaller than that of a radio wave that went straight from a beacon to the phone. But the phone has no idea what’s the difference between the two radio waves that hit it, so it’ll report different RSSI. Again, you can stand in place, same distance to the beacon, but you’ll see two different RSSI levels reported, and thus, two different distance estimates.
-
Holding the phone at a different angle, in your pocket, etc., will also affect RSSI.
-
The model of the phone affects the RSSI. (Different antenna, different form factor affecting the signal propagation, etc.)
There are more, but I don’t want this to be a very long post (:
You smooth and average out the RSSI spikes and fluctuations, but naturally, it’ll never be perfect. Long story short, make sure to manage your expectations about estimating distance to beacons.