4

How can I get the direction and the strength of all the nearby Wifi ? Till now I have been able to get Wifi Strength in Level but only of connected wifi using following code

   WifiManager wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
            int numberOfLevels = 5;
            WifiInfo wifiInfo = wifiManager.getConnectionInfo();
            int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);

I am trying to do something like this Play Store App Link

This app gives nearby wifi plot on campas

Can anyone guide my how this is possible?

Dhruv Kaushal
  • 632
  • 8
  • 17

2 Answers2

0

Short answer "not possible".

Long answer is that the phone gives just the strength of the incoming signal, which can come from any direction. You can not even estimate the distance to the WiFi access point until you know its signal strength with your phone for some known distance. You can however estimate the direction of where the WiFi access point is from movement of your phone and the differences of the WiFi signal strength changes.

The app you linked to tells you to start scanning and then slowly rotate. That is needed for recording the device orientation and the signal strength changes. Then based on the orientation of the device and the signal strength for that orientation it can estimated where the WiFi access point is. I am not connected with that app in any way, nor I have used it. All this information is based on the app's screenshots and general knowledge of how WiFi works.

Then there are other funny things like WiFi access points which can send a stronger signal in a specific direction when it detects a device with low signal.

shelll
  • 3,234
  • 3
  • 33
  • 67
0

To find distance you can try:

public double calculateDistance(double signalLevelInDb, double freqInMHz) {
    double exp = (27.55 - (20 * Math.log10(freqInMHz)) + Math.abs(signalLevelInDb)) / 20.0;
    return Math.pow(10.0, exp);
}
Rahul Rastogi
  • 4,486
  • 5
  • 32
  • 51