2

How to convert WiFi level (i.e. -45 , -88 ) in to percentage ?

I want to convert WiFi level in % . I get WiFi level using level ( in dBm format)

I try lot of google but not get proper ans

Nirav Ranpara
  • 13,753
  • 3
  • 39
  • 54
  • afaik there is not lower limit on this value. 0dB ought to be 100%. You will arbitarily have to set a lower limit. Also, dB is calculated using 20*log10(abs(x)) – ErikTJ Dec 18 '12 at 08:08
  • Maybe this link will explain something http://www.sengpielaudio.com/calculator-thd.htm. Those values -45 are dB values http://en.wikipedia.org/wiki/Decibel – CodingBarfield Dec 18 '12 at 08:08
  • 0dB is quite far from any normal level. In fact, 0dB is quite bad (clipping and such) – John Dvorak Dec 18 '12 at 08:09
  • You could compare the Signal-to-Noise ratio to the Signal or Noise alone. – John Dvorak Dec 18 '12 at 08:10
  • @JanDvorak in WiFi receiving, 0dBm means "no attenuation", which equals to the received power to be the same as the sending power. Clipping is not an issue here (you seem to be confused with the 0dBm of amplifiers, which can cause clipping in the rest of the chain (mainly speakers)). – Bart Friederichs Dec 18 '12 at 08:18
  • @BartFriederichs I thought 0dBm = receiver's maximum. You don't know at which amplitude the sender is sending. – John Dvorak Dec 18 '12 at 08:20
  • @JanDvorak you could be right. – Bart Friederichs Dec 18 '12 at 08:22
  • @BartFriederichs In fact, I had the opportunity to meet a WiFi AP that my receiver decided to ignore above -40 to -50 dBm when it used a specific channel, so 0dBm is, AFAIU, a great way to get no connection at all. inSSIDer clips its range at -10 and -100 dBm (meaning that neither is expected to happen). APs started to disappear from the graph between -80 to -90 dBm - but then it could depend on the amount of noise. – John Dvorak Dec 18 '12 at 08:35

4 Answers4

4

Problem with this is that is very dependent on the receiving antenna. Some antennas register no useable signal at -90 dBm, some already at -80. You will have a hard time finding 0% (100% strictly being 0dBm).

I have created a Wifi scanner application where I use -100dBm as 0% and 0dBm as 100%, in Java it turns into something like this (MIN_DBM being -100):

public int getPowerPercentage(int power) {
     int i = 0;
     if (power <= MIN_DBM) {
            i = 0;
     } else {
            i = 100 + power;
     }

     return i;
}
Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195
2

This is what Microsoft does for dBm <> percent conversion: https://stackoverflow.com/a/15798024/2096041

Basically -50 .. 0 dBm maps linear to 100 .. 0 %. Like MS, i would prefer to sit on the safe side and not use -100 as 100% as some answers here suggest.

Community
  • 1
  • 1
Barry Staes
  • 3,890
  • 4
  • 24
  • 30
1

The WifiManager class has a function calculateSignalLevel, but as it states here, it results in an error if numLevels is greater than 45. Possible workaround could be something like this:

double percentage = WifiManager.calculateSignalLevel(int rssi, 40) * 2.5;

but of course, this will be in steps of 2.5 percents - I don't know your use case but maybe this is sufficient.

As others have stated, calculating percentages is problematic, and there's no simple precise solution for that.

1615903
  • 32,635
  • 12
  • 70
  • 99
0

You could derive the percentage from the signal-to-noise ratio, rather than the signal intensity alone, if this information is available. This is probably the desired metric.

An android.net.wifi.ScanResult does not publish the neccessary information (as of Dec 2012), but you might be able to get this information through other means.

Signal = Noise => unusable signal, so you could set 0dB SnR = 0%. Also you could set 10dB SnR to 90% (90% of the signal power is not drowned out in noise), and 100% = no noise at all. More generally,

p = 100% * (1 - 10^(SnR / (10dB)))
John Dvorak
  • 26,799
  • 13
  • 69
  • 83
  • can you please say how to implement in java(android) ? – Nirav Ranpara Dec 18 '12 at 08:24
  • @NiravRanpara I don't know how to get the SnR from the Android API (I was assuming you already know that). For the math, look at [`Math.pow`](http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#pow(double,%20double)) – John Dvorak Dec 18 '12 at 08:26
  • @NiravRanpara concerning other implementation details replace `100%` with `100` for display purposes or no multiplication at all for the purposes of further computation, and replace `10dB` with `10` if the input is already in dB. – John Dvorak Dec 18 '12 at 08:39