wifi.rssi an wifi.scan

Code tips and tricks for beginners
Post Reply
User avatar
Fernando Perez
Posts: 106
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 55 times
Been thanked: 54 times

wifi.rssi an wifi.scan

Post by Fernando Perez »

I am studying the Annex instructions regarding Wifi and there is one thing I do not understand.
wifi.rssi always gives me a different value than the one I get through wifi.scan.
Is there something wrong with my program or functions?

Code: [Local Link Removed for Guests]

DIM mode$(3) = "sleep", "STATION", "AP", "AP+STA"
ssid$ = "MIWIFI_2G_Tmct"

wlog "Mode: " + mode$(wifi.mode)
wlog "Signal: " + str$(wifi.rssi) + " db  (" + str$((wifi.rssi+100)/100*110) + "%)"
wlog "Channel: " + str$(wifi.channel) + chr$(13)

wifi.scan
while wifi.networks(a$) = -1
wend
wlog a$ + chr$(13)

ioBuff.dim(0, 1000)
ioBuff.fromString(0, a$)

i = 0
do
  i = i + 1
loop until ioBuff.toString$(0, i, len(ssid$)) = ssid$

wlog "MAC: " + ioBuff.toString$(0, i + len(ssid$) + 1, 17)

signal$ = ioBuff.toString$(0, i + len(ssid$) + 19, 3)
wlog "Signal: " + signal$ + " db"
cicciocb
Site Admin
Posts: 309
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 85 times
Been thanked: 197 times
Contact:

Re: wifi.rssi an wifi.scan

Post by cicciocb »

Hi Fernando,
what do you mean exactly for "always different" ?

In fact, the RSSI information do not seems to be very stable.
For example, using this snippet extracted from your program

Code: [Local Link Removed for Guests]

DIM mode$(3) = "sleep", "STATION", "AP", "AP+STA"
while 1
  wlog "Mode: " + mode$(wifi.mode)
  wlog "Signal: " + str$(wifi.rssi) + " db  (" + str$((wifi.rssi+100)/100*110) + "%)"
  wlog "Channel: " + str$(wifi.channel) + chr$(13)
wend
Shows this result on one of my modules :

Code: [Local Link Removed for Guests]

Mode: STATION
Signal: -45 db  (60.5%)
Channel: 11

Mode: STATION
Signal: -49 db  (56.1%)
Channel: 11

Mode: STATION
Signal: -49 db  (56.1%)
Channel: 11

Mode: STATION
Signal: -47 db  (58.3%)
Channel: 11

Mode: STATION
Signal: -45 db  (60.5%)
Channel: 11

Mode: STATION
Signal: -45 db  (60.5%)
Channel: 11

Mode: STATION
Signal: -46 db  (59.4%)
Channel: 11

Mode: STATION
Signal: -46 db  (59.4%)
Channel: 11

Mode: STATION
Signal: -47 db  (58.3%)
Channel: 11

Mode: STATION
Signal: -47 db  (58.3%)
Channel: 11

Mode: STATION
Signal: -43 db  (62.7%)
Channel: 11

Mode: STATION
Signal: -43 db  (62.7%)
Channel: 11

Mode: STATION
Signal: -47 db  (58.3%)
Channel: 11

Mode: STATION
Signal: -46 db  (59.4%)
Channel: 11

Mode: STATION
Signal: -46 db  (59.4%)
Channel: 11

Mode: STATION
Signal: -44 db  (61.6%)
Channel: 11

Mode: STATION
Signal: -44 db  (61.6%)
Channel: 11

Mode: STATION
Signal: -47 db  (58.3%)
Channel: 11

Mode: STATION
Signal: -47 db  (58.3%)
Channel: 11

Mode: STATION
Signal: -45 db  (60.5%)
Channel: 11

Mode: STATION
Signal: -45 db  (60.5%)
Channel: 11

Mode: STATION
Signal: -47 db  (58.3%)
Channel: 11

Mode: STATION
Signal: -47 db  (58.3%)
Channel: 11

Mode: STATION
Signal: -47 db  (58.3%)
Channel: 11

Mode: STATION
Signal: -46 db  (59.4%)
Channel: 11

Mode: STATION
Signal: -46 db  (59.4%)
Channel: 11

Mode: STATION
Signal: -44 db  (61.6%)
Channel: 11

Mode: STATION
Signal: -44 db  (61.6%)
Channel: 11

Mode: STATION
Signal: -46 db  (59.4%)
Channel: 11

Mode: STATION
Signal: -46 db  (59.4%)
Channel: 11

Mode: STATION
Signal: -46 db  (59.4%)
Channel: 11

Mode: STATION
Signal: -46 db  (59.4%)
Channel: 11

Mode: STATION
Signal: -44 db  (61.6%)
Channel: 11

Mode: STATION
Signal: -44 db  (61.6%)
AndyGadget
Posts: 63
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 24 times
Been thanked: 54 times

Re: wifi.rssi an wifi.scan

Post by AndyGadget »

Deleted by Andy - Answering the wrong question :D
Last edited by AndyGadget on Mon May 03, 2021 4:42 pm, edited 2 times in total.
User avatar
Fernando Perez
Posts: 106
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 55 times
Been thanked: 54 times

Re: wifi.rssi an wifi.scan

Post by Fernando Perez »

Francesco, running the readings continuously, I see that the values obtained vary almost the same as the opinions of our politicians. :mrgreen:
But I mean that when I run the wifi.scan command I always get a value several decibels lower than when I get it through the wifi.rssi command.
Look at this:

Code: [Local Link Removed for Guests]

ssid$ = "MIWIFI_2G_Tmct"

while 1
  wlog "Signal wifi.rssi: " + str$(wifi.rssi) + " db"

  wifi.scan
  while wifi.networks(a$) = -1
  wend
'  wlog a$
  
  i = 0
  do
    i = i + 1
    b$ = mid$(a$, i, len(ssid$))
  loop until b$ = ssid$
  wlog "Signal wifi.scan: " + mid$(a$, i + len(ssid$) + 19, 3) + " db" + chr$(13)   

wend

Do you know what it could be?
What will be the most reliable?
cicciocb
Site Admin
Posts: 309
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 85 times
Been thanked: 197 times
Contact:

Re: wifi.rssi an wifi.scan

Post by cicciocb »

Fernando,
in my case I have "around" the same values.
The only explanation I have is that the intensity is not sampled at the same time so the difference exists.

This is the program running on my module

Code: [Local Link Removed for Guests]

Signal wifi.rssi: -55 db
Signal wifi.scan: -52 db

Signal wifi.rssi: -54 db
Signal wifi.scan: -56 db

Signal wifi.rssi: -54 db
Signal wifi.scan: -54 db

Signal wifi.rssi: -56 db
Signal wifi.scan: -54 db

Signal wifi.rssi: -58 db
Signal wifi.scan: -52 db

Signal wifi.rssi: -57 db
Signal wifi.scan: -55 db

Signal wifi.rssi: -55 db
Signal wifi.scan: -54 db

Signal wifi.rssi: -52 db
Signal wifi.scan: -53 db

Signal wifi.rssi: -52 db
Signal wifi.scan: -51 db

Signal wifi.rssi: -52 db
Signal wifi.scan: -55 db

Signal wifi.rssi: -52 db
Signal wifi.scan: -55 db

Signal wifi.rssi: -50 db
Signal wifi.scan: -56 db

Signal wifi.rssi: -53 db
Signal wifi.scan: -52 db
User avatar
Fernando Perez
Posts: 106
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 55 times
Been thanked: 54 times

Re: wifi.rssi an wifi.scan

Post by Fernando Perez »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Mon May 03, 2021 4:34 pm Deleted by Andy - Answering the wrong question :D
Andy, your work at ThingSpeak is really nice. My goal is simply to mount a meter of the wifi signal that reaches my ESP8266 module to determine what is the best placement in the different rooms of a house.
But I see that it will not be very reliable as there are so many differences from one second to another, without even moving the module.
User avatar
Fernando Perez
Posts: 106
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 55 times
Been thanked: 54 times

Re: wifi.rssi an wifi.scan

Post by Fernando Perez »

It's funny, Francesco. This is what I get.
image.png
I will investigate in case I am doing it on a faulty module or any other reason. Thank you.
You do not have the required permissions to view the files attached to this post.
AndyGadget
Posts: 63
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 24 times
Been thanked: 54 times

Re: wifi.rssi an wifi.scan

Post by AndyGadget »

Thanks Fernando. I didn't pick up on the RSSI / Scan discrepancy which was the main point of your post.
I'll be posting the greenhouse monitor as a project once I've done a bit more work on the monitor display.


If you're looking for relative strength between rooms, I'd just choose either RSSI or Scan and take an average of 10 readings.
A couple of db either way won't make much difference.
User avatar
dMajo
Posts: 5
Joined: Thu Apr 08, 2021 5:42 pm
Has thanked: 1 time

Re: wifi.rssi an wifi.scan

Post by dMajo »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Mon May 03, 2021 7:24 pm ...
A couple of db either way won't make much difference.
Except that the voltage doubles every 6 dB while the power doubles every 3 dB
AndyGadget
Posts: 63
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 24 times
Been thanked: 54 times

Re: wifi.rssi an wifi.scan

Post by AndyGadget »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Wed May 12, 2021 10:13 am ...
A couple of db either way won't make much difference.
Except that the voltage doubles every 6 dB while the power doubles every 3 dB
[/quote]

True, but as Fernando is using this for room to room comparative measurements, largely irrelevant. The usable range is enormous.
From experience I've found around -25dB sitting next to a router, a sharp increase in packet loss starting around -70db and just forget it at -80dB.

My greenhouse monitor data at [External Link Removed for Guests] is spot-sampled each time it wakes up (every 10 minutes) and currently shows a variation of 9dB. (Graph is actually 100 + RSSI.)
Post Reply