How to measure the distance between an iPhone acting like an iBeacon and an Android device

橙三吉。 提交于 2020-06-28 14:11:29

问题


I'm using my iPhone as an iBeacon device, and on the other side I have an Android 4.4.2 device scanning for the Bluetooth LE iBeacon signal from the iPhone. I searched for a good and easy way to calculate the distance between iBeacons and my Android phone, but I couldn't find anything that can help me with this.

Could you help me on this matter?


回答1:


We built a distance estimation formula into the Android Beacon Library of the form: d=A*(r/t)^B+C, where d is the distance in meters, r is the RSSI measured by the device and t is the reference RSSI at 1 meter. A, B, and C are constants. You can read more about it here. To use it with the library, you range for a beacon and then simply call:

beacon.getDistance();

This returns a distance estimate in meters. The library code is open source, so if you don't want to use the library you can copy the formula and use it directly.

As @TwoStraws notes, distance estimates are pretty rough guesses of how far a beacon is away, and the results you get vary with lots of factors:

  1. The gain of the antenna on the receiving device. (Every Android device model is slightly different)
  2. The noise on the A/D converter inside the phone that measures bluetooth signal strength.
  3. The radio noise in the room.
  4. Any obstructions between the transmitter and receiver.
  5. Any surfaces (especially metal) that reflect radio signals.

Just be sure you set your expectations properly. Distance estimates are good for deciding if a beacon is close or far, or whether one beacon is closer than another. But they are less useful for measuring absolute distance.




回答2:


It's impossible to measure beacon distance accurately, I'm afraid, which is why Apple's own code just says "Immediate", "Near", "Far" and "Unknown". The best you can do is set up a reconstruction of the conditions you expect then do trial and error tests to map signal strength to probable distance. Trust me: I've spent a lot of time trying to do beacon distance measurement using a range of hardware.

Remember that the LE in Bluetooth LE means "Low Energy" – this stuff really is designed to use as little power as possible. That means the signal from iBeacons gets interrupted by people, walls and other objects. So, if I'm holding a beacon in my hand and put my phone next to it, I'll get a strong signal. If I move the beacon behind my back, the signal strength will collapse. If I just turn around, that has the same effect (for the same reason).

If you want to go down the "best you can do" approach, you effectively have to recreate at least partially the environment where your app will be used. So, if your app will be used in an office, find an office and place some beacons around there. Same for being in a shop.

Then get your app out and measure beacon strength at various distances to the beacon, potentially with obstacles in the way. With some averaging, you end up with something like "at 1 metre my signal strength was X, at 5 metres it was Y, at 10 metres it was Z", etc, and you then feed that into your distance calculation. It is, effectively, an educated guess.

If you find any library that claims to do beacon distancing for you, it just means they've taken their own educated guess based on their own signal strength testing.

One tip: if you're able to, stick your beacons to the ceiling. This minimises the chance of obstacles (read: people) getting between your beacon and your app.



来源:https://stackoverflow.com/questions/34337717/how-to-measure-the-distance-between-an-iphone-acting-like-an-ibeacon-and-an-andr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!