iOS Swift: Calculate distance from RSSI

The iBeacon ranging process (as available from CoreLocation) do not provide a smooth going distance of iPhone from an iBeacon instead it gives a too much fluctuating values. I also tried to use weighted average over accuracy (by maintaining a collection of last 5 accuracies as reported in didRangeBeacons event) but it do not gives desired results. I come across the link that explained the use of Kalman Filter to remove noise from signals. I also came across a swift framework that has implemented the filter. Below is the formula that I tried to calculate the distance:


func calculateNewDistance(txCalibratedPower: Int, rssi: Int) -> Double{ if rssi == 0{ return -1 } let ratio = Double(exactly:rssi)!/Double(txCalibratedPower) if ratio < 1.0{ return pow(10.0, ratio) }else{ let accuracy = 0.89976 * pow(ratio, 7.7095) + 0.111 return accuracy } }



Here txCalibratedPower is -59. This formula is used after applying the kalman filter over a sample of 10 RSSI values as received from an Ibeacon. The calculated distance is not proper and also do not gets smoothed out to a near about fix value even when iPhone and iBeacon are stationry. Can anybody suggests what can be wrong with above process or any other better formula to use instead?


Thanks

Replies

Hi,


did you see this article https://www.hindawi.com/journals/misy/2016/2369103/


it describes in detail an implemenation of an "Extended Kalman Filter" to use with iBeacon and describes in detail the technical and mathematical background of it.


happy coding


Hardy

The noise you see is the fact that signals travel in multiple paths, impact of antenna orientation and gain, etc. If you were to try this in an anechoic chamber you would get much better close values. However, in real world the signal is unpredicable. To improve this you need multiple beacons and much more data (to filter). Using a single beacon, even with filtering, Kalman, etc, may improve but will not be as accurate as you expect. It also depends on your particular unit (Antenna, RF, etc)


Regards,

Gustavo


====================================

ARGENOX

Wireless Connecitivity Experts

Bluetooth, BLE, Wi-Fi

www.argenox.com

info@argenox.com

====================================