3

Is it possible to calculate the distance between the device and the iPhone, or at least, have an idea of the strength so I can check if the distance is getting smaller or bigger as I move. I would like to build some sort of system which makes it easier to find "lost" things in a close perimeter.

Is such thing possible? And if so, what is the best way to do this.

I assume that there is no obstruction between the two devices.

Gilles Lesire
  • 1,237
  • 17
  • 33

1 Answers1

5

Yes, absolutely!

Actually it's basic functionality provided by Core Bluetooth. To reference a link provided by a previous answer:

As soon as a Peripheral is discovered during the scanning, the Central delegate receives the following callback:

  • (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI

This call notifies the Central Manager delegate (the view controller) that a peripheral with advertisement data and RSSI was discovered. RSSI stands for Received Signal Strength Indicator. This is a cool parameter, because knowing the strength of the transmitting signal and the RSSI, you can estimate the current distance between the Central and the Peripheral. So, you can use the distance as a filter for a given service: only if the Central is close enough to the Peripheral, then your app does something.

The RSSI value allows you to estimate the distance, create virtual fences and can also be used to zero-in on a BLE device by comparing the new RSSI measurement to the previous one.

RowdyRobot
  • 126
  • 4
  • Thanks that's exactly what I meant, I don't need to have a real calculation of the distance, just knowing if I'm getting colder or hotter :). – Gilles Lesire Sep 19 '13 at 08:54
  • Ok, my mistake : I provided same link, but didn't take the time to read it thoroughly. Other SI question about that here : http://stackoverflow.com/questions/13705647/finding-distance-from-rssi-value-of-bluetooth-low-energy-enable-device – Vinzzz Sep 19 '13 at 12:23
  • Anyway, little update, I figured out a way to roughly tell a person he is getting closer or farther from the object. It's a very rough estimate but it's better than no information at all when searching for something. Since the RSSI is so unstable, you might want to use a floating/moving average of the last 50 RSSIs and compare it to the last 5 RSSIs. (the amounts are just examples, with some tweaking you'll get there). And also allow a small margin of error of a few percent so your scanner isn't to sensitive. – Gilles Lesire Sep 04 '14 at 09:08
  • We could use this before the ble device is connected to iPhone. What if i need to show the distance once the device is connected to iPhone ? – Yasitha Waduge Mar 30 '15 at 16:13
  • did anyone get the distance between the BLE device and peripheral using RSSI ? anyone ? if yes then guide me with this . – Moxarth May 31 '17 at 05:26