简体   繁体   中英

How to estimate distance between two android devices? (bluetooth preferred)

Target is not to have the real distance. It is something simpler.
Target is to check whether another device is very very close . True or false. Let's say 10 or 15 cms is close so our check is true and any device further away fails the check and it is false.

My first approach was to use api's method fetchUuidsWithSdp() but it failed!
Latency seemed the same whether the devices where a couple of cms away or at the other end of a large room!

Any solution even without bluetooth is acceptable. For instance, I am totally unfamiliar with the wifi direct p2p protocol. Maybe there could be something in there useful to have a rough estimation of distance.

Edit: I am reading about Received Signal Strength Indicator( RSSI ). This could be used for our particular case, a rough estimation of distance between devices. But maybe there could be something to combine in order to improve the accuracy.

Edit: I put Ralgha's answer to the test. I did established a connection and had a minor protocol to ping-pong among devices.
When ping-ponged with 1 byte average latency was 22.6000 msec when very close and 22.6087 msec when on the other corner of the room.
When ping-ponged with 1024 bytes average latency was 40.3173 msec when very close and even smaller, 32.3138 msec, when on the other corner of the room.
After all, indeed, latency does not carry any information about distance !

Thanks!

你可以用声音测量距离

I've looked into bluetooth positioning and it istn' quite as easy as detecting the signal strength. For really accurate results you also need to take into account the types of phone your using, the battery type and the condition of the battery. You also have to take into account the environment and how it might efffect the signal strength, and also obstacles that may interfere with the signal, such as people, walls, tables, etc.

To determine the distance you would also need to use triangulation techniques to determine the position of a mobile. You can also set up a number transmitters in your environment and measure against each one. Knowing the positions of these transmitters you can then work out the position of the phone.

However, the signal strengths will vary and you will have to do a lot of calibration. There a number of scientific papers that give some insight into the algorythms required. There are also a couple of companies that provide this as a service, used in malls, museums etc.

That said, if you can get the signal strength then you should be able to work out a basic near or far result, it just won't be fully accurate, and in this case i still think having a number of transmitters would still help a lot.

Paper, some of the pitfalls PDF(download), another paper

THere are loads of papers i've read from googling bluetooth positioning that will give you some pointers.

The only feasible way to do it that I can think of is with NFC. To use Bluetooth or Wi-Fi you'd have to do it via signal strength, but every transmitter is different so that wouldn't be reliable at all.

Latency is rather useless since the radio waves travel at the speed of light and the time difference between traveling an inch and a mile is essentially zero. To measure that difference you'd need a much higher resolution than you have in a phone.

You are not specifying the objective for this distance detection, but if you could add some additional requirements to that (ie phone orientation and flash light), a totally different approach could probably be used.

If both devices are oriented in a way that both cameras face each other, the flash light could be used to validate the correct phone and distance. The size of the white spot generated in the camera image decreases rapidly with distance, and a specific flash sequency could differentiate between the other phone flash light and other light sources.

This could require some tweaking to work outdoors, as for the same distance the spot size will be much smaller ...

Regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM