3

i am developing an android application which have module to search all nearest / detected wifi hotspot.

i can get all detail from searched wifi hotspot like, SSID, BSSID, capabilities, frequency, level and timestamp

with these information, i also need Distance of wifi ( The distance between wifi accesspoint and Mobile Device )

i am using below lines to get Distance.

double exp = (27.55 - (20 * Math.log10(freqInMHz)) + Math.abs(levelInDb)) / 20.0;
double distanceM = Math.pow(10.0, exp);

this will return distance in meter.

i got these code by reserch on google from many pages.

but i think i am going wrong, this code is returning wrong distance. i also tried a lot on google search but not getting accurate output.

Please help me. how can i get Distance between Wifi AP and Mobile device?

Ajay
  • 1,189
  • 1
  • 12
  • 28
  • 1
    I don't think this is even possible. Maybe you can get a very, very rough estimation of the distance based on the level of the signal, but it will depend on so many parameters (power of the source, the walls, orientation of the device...) that I doubt it could be of any use. – Orabîg Jan 30 '15 at 08:42
  • 1
    possible duplicate of [How to calculate distance from Wifi router using Signal Strength?](http://stackoverflow.com/questions/11217674/how-to-calculate-distance-from-wifi-router-using-signal-strength) – Selvin Jan 30 '15 at 08:49
  • The wireless signals do travel at a certain speed so the latency between the device and nearest point could theoretically be calculated I guess? I have no idea how though, since the distances are so short it seems almost instant. – G_V Jan 30 '15 at 08:55
  • does your results improve if you are measuring (lets say) 10,000 times in a row and then calculate the difference based on those results? – sschrass Jan 30 '15 at 09:03
  • @Ajay Did you find some solution ? – Ihor Bykov Apr 01 '16 at 13:13
  • @LgorB : No, but after that i changes way to check wifi accessibility by pinging on every 20 to 30 seconds. – Ajay Apr 01 '16 at 13:25

4 Answers4

5

This code:

double exp = (27.55 - (20 * Math.log10(freqInMHz)) + Math.abs(levelInDb)) / 20.0; double distanceM = Math.pow(10.0, exp);

Works under the assumption of free space path attenuation between two isotropic antennas and the AP transmitting at a power of 20dBm (and the math is not even correct; the frequency dependence of free space path loss is different; not that is matters for the bands of W-LAN, uses, the correction is in the 27.55).

In reality you're dealing with anisotropic antennas, obstacles in your path, diffraction effects and the AP varying it's power output to save energy if no high bandwidth is required.

Or in other words: It's totally impractical to obtain a reliable distance figure just looking at the received power. It can give you a ballpark, order of magnitude, but not something that's remotely accurate. This is just basic physics.

The only reliable way of measuring distance is time-of-flight. For this you have to measure the roundtrip time between the device and the access point. Since we're dealing with the speed of light and distances in the order of meters up to 100m (top), this means measuring nanoseconds. Can be done but requires some work. See the link SatelliteSD gave you (it's in German but the diagrams and keywords should be understandable).

datenwolf
  • 159,371
  • 13
  • 185
  • 298
1

It is possible, you could use the Time-of-Flight approach. Keep in mind that you can't rely on the messages recieved, but on the overhead received (like ACK) I can only come up with this reference (german language) measuring of signal runtimes And from a quick read I think it is a very tedious thing to do.

sschrass
  • 7,014
  • 6
  • 43
  • 62
0

No, it is not possible.

You'll not be able to find the hotspots distance from your current device location to the actual hotspot.

It seems that the hotspots don't report their coordinates.

Check the Link which has more detailed info.

Community
  • 1
  • 1
AADProgramming
  • 6,077
  • 11
  • 38
  • 58
  • the op only wants a distance, not a position. – sschrass Jan 30 '15 at 09:00
  • @SatelliteSD I mean to say "location" of device, corrected the answer! – AADProgramming Jan 30 '15 at 09:02
  • as per some research, i think we can get distance from level and frequency. – Ajay Jan 30 '15 at 09:03
  • I am not sure you can get a seriously accurate fix!! – AADProgramming Jan 30 '15 at 09:15
  • @AADTechnical : yes, i can't get accurate results. – Ajay Jan 30 '15 at 09:35
  • @Ajay: received power level tells you nothing about the distance to the AP. You can make the assumption of free space path attenuation (which depends on the frequency) and a standard candle AP (assuming all APs transmit at reference level) and your receiver is perfectly isotropic, as the AP. But in practice none of these assumptions hold. – datenwolf Jan 30 '15 at 09:51
-1

There is a method called "triangulation" but for this case you have least 3 hotspot. You can answer with detail in this pdf.

http://www.see.ed.ac.uk/~slig/papers/ITM2010.pdf

Cüneyt
  • 2,565
  • 25
  • 31