Araf
Araf

Reputation: 530

calculate accurate Ibeacon distance

I'm at the beginning of developing an indoor navigation system with the help of Beacons in ios. We have 3 Bluecast beacons now and I am not getting accurate distance from these three. I have tested by putting three beacons in a same position but it's showing different distance and rssi values in major time.

I tried same with beacon provider reveal app and my own app but both apps are showing same value.

example code is

 locationManager = CLLocationManager()
 locationManager.delegate = self

 let uuid = UUID(uuidString: uuidStr)
 beaconRegion = CLBeaconRegion(proximityUUID: uuid!, identifier: "Beacones")

 beaconRegion.notifyOnEntry = true
 beaconRegion.notifyOnExit = true
 locationManager.requestAlwaysAuthorization()
 locationManager.startMonitoring(for: beaconRegion)
 locationManager.startUpdatingLocation()

distance calculator logic is in below

 public func calculateAccuracy(txPower : Double, rssi : Double) -> Double {
        if (rssi == 0) {
            return -1.0; // if we cannot determine accuracy, return -1.
        }

        let ratio :Double = rssi*1.0/txPower;
        if (ratio < 1.0) {
            return pow(ratio,10.0);
        }
        else {
            let accuracy :Double =  (0.89976)*pow(ratio,7.7095) + 0.111;
            return accuracy;
        }
    }

Upvotes: 1

Views: 2078

Answers (1)

davidgyoung
davidgyoung

Reputation: 64941

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.

Upvotes: 4

Related Questions