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