57

I can get WiFi signal level in dBm using following code.

for (ScanResult result : wifiScanResultList) {
    int signalLevel = result.level;
}

It gives negative value. When we see the default system WiFi setting and clicked on the connected WiFi network, it gives "Good" or "Bad" as signal strength. What is the range that we can filter those negative vales as "Good" signal strength or "Bad" signal strength?

Seraphim's
  • 12,559
  • 20
  • 88
  • 129
AnujAroshA
  • 4,623
  • 8
  • 56
  • 99
  • 3
    Isn't dBm for the most part negative? – A--C Dec 18 '12 at 12:27
  • Yes, that is true. What I need is a standard range that I can apply for my own WiFi handling Android app. When I click on the connected WiFi network on a real device, it gives me "Good" as Signal strength. I want to know how they measure it as a "Good" strength. Thanks for the reply. – AnujAroshA Dec 18 '12 at 13:56
  • 1
    This is the answer to your question: http://androidxref.com/4.2_r1/xref/frameworks/base/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java#103 – Oleksandr Kravchuk Dec 18 '12 at 19:52

7 Answers7

74

its an old post but this might help someone...

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

Documentation: public static int calculateSignalLevel (int rssi, int numLevels)

se_bastiaan
  • 1,716
  • 14
  • 19
Alan
  • 1,509
  • 1
  • 16
  • 21
37

Please check how dBm values for received Wireless Signal power are represented.

Excellent >-50 dBm

Good -50 to -60 dBm

Fair -60 to -70 dBm

Weak < -70 dBm

Nisha Salim
  • 687
  • 5
  • 13
25
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

// Level of a Scan Result
List<ScanResult> wifiList = wifiManager.getScanResults();
for (ScanResult scanResult : wifiList) {
  int level = WifiManager.calculateSignalLevel(scanResult.level, 5);
  System.out.println("Level is " + level + " out of 5");
}

// Level of current connection
int rssi = wifiManager.getConnectionInfo().getRssi();
int level = WifiManager.calculateSignalLevel(rssi, 5);
System.out.println("Level is " + level + " out of 5");
se_bastiaan
  • 1,716
  • 14
  • 19
ddiego
  • 3,247
  • 1
  • 28
  • 18
8

Yes, exactly. This is how dBm values for received signal power are represented. Here are some details at Wikipedia.

-100 means lowest value (no signal at all), and 0 means extremely good signal (100%)

Oleksandr Kravchuk
  • 5,963
  • 1
  • 20
  • 31
  • 1
    0 isn't 100% percent. Received signal strength can be above 0 dBm. >= -51 dBm usually means 100%. – Thomas Oct 18 '17 at 15:11
  • @Thomas what a nonsense. Did you even check linked Wikipedia page or try to research it yourself before making this statement? – Oleksandr Kravchuk Oct 18 '17 at 22:37
  • Unlinke you I seem to know a little bit more about wireless system it seems, otherwise you wouldn't have written "non-sense". Your Wikipedia link only lists the transmit power of radio stations and so on. Also -100 isn't the lowest value ... GSM for example still works below -100 dBm. – Thomas Oct 20 '17 at 14:44
  • 2
    I downvoted this now because this answer about the received signal strength (RSSI) is totally wrong. Please do some research. This answer here: https://stackoverflow.com/a/33689523/1392778 is correct. – Thomas Oct 20 '17 at 14:58
  • RSSI = -100 does NOT mean no signal. It means received signal power is 100 dB below 1 mW. Yes, this may mean practically a useless signal. No, this does NOT mean "no signal". Similarly, extremely good signal does not mean 100%. There is no defined 100% signal. 100 % of what? Four bars out of four is just a GUI, but does not mean "100%". This answer is not useful. -1 – Roland Jul 26 '21 at 20:40
7

You already have got the levels, So I will tell you how to classify that wifi into high,medium or low strength. Following is a code

    int level = result.level;

    if (level >= -50) {
        //Best signal
    } else if (level >= -70) {
        //Good signal         
    } else if (level >= -80) {
        //Low signal
    } else if (level >= -100) {
       //Very weak signal
    } else {
       //Too low signal
    }
Roland
  • 4,619
  • 7
  • 49
  • 81
Ajji
  • 3,068
  • 2
  • 30
  • 31
0

Here are the wifi signal levels used by the Samsung A7 :

return when (rssi) {
    in -63..-1 -> 4
    in -73..-64 -> 3
    in -83..-74 -> 2
    in -93..-84 -> 1
    else -> 0
}

I think it should be pretty similar for the other brands.

Greelings
  • 4,964
  • 7
  • 34
  • 70
-1

The Constants from WifiManager.java are slightly different so I will add them here:

MIN_RSSI: Anything worse than or equal to -100 will show 0 bars.

MAX_RSSI: Anything better than or equal to -55 will show the max bars.

einUsername
  • 1,569
  • 2
  • 15
  • 26