espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.44k stars 7.38k forks source link

WifiScan:: Weak signal reception compared to ESP8266 #242

Closed tobozo closed 6 years ago

tobozo commented 7 years ago

Last month I received this ESP32S dev board from aliexpress and ran the WifiScan.ino example but the scan results are much worse than what I get when I scan with an ESP8266.

Instead of getting the usual amount of SSIDs (between 50 and 80 in my area), I only get two or three, and sometimes nothing. And the ESP32S is heating a bit more than the ESP8266.

There are no interferences, the ino code is similar, both ESP8266 and ESP32S had their code compiled and tested under the same circumstances.

After posting on reddit, someone suggested it could be a design error, so I ordered another model from aliexpress.

Today I've Just received this other board and it's exactly the same problem, displaying only 3 AP where the ESP8266 shows 50.

Now I'm wondering if there's some kind of setting that sets the Wifi to low power mode, or if I'm just unlucky in my model choices.

[Edit] Also tested on ESP32-Wrover-Kit (v3), ESPEA32, MH-ET-LIVE, D-Duino32

me-no-dev commented 7 years ago

What you describe is rather strange. I have a few 8266 and 32 boards here and will have a look. Though my area is not that noisy.

tobozo commented 7 years ago

More observations: when the ESP8266 sees an AP with -40db, both ESP32 models see the same AP with an RSSI between -60 and -70db. There's an average 20db difference. I took a photo of both models, maybe I've just bought a shitty clone or something. I had some pins removed off the first model (the ones too close to the antenna) with no effect whatsoever.

esp-32

me-no-dev commented 7 years ago

yeah,... what a horrible design... see how there is a board under the antenna? that should not be there at all. esp-32-mini-dev-board-samples-03

tobozo commented 7 years ago

Yep free space is recommended, but 20db difference is a lot, it is the equivalent of having metal shielding. i.e. laptop casings can attenuate the signal more than 10db , but a piece of PCB shouldn't attenuate that much, otherwise Wemos D1 mini and other dev kits have a problem ?

Also the second model is ESP32 DEVKIT V1, aka "DOIT/SmartArduino ESP32 DevKit" is a recommended model from the sp32.net page, can I assume this one has a placement reasonable enough not to attenuate the signal by 20db ?

I've ordered a third model, same as the one you posted here.

tobozo commented 7 years ago

I just tried yet another ESP32 module, the ESPea32, and it behaves the same way.

@me-no-dev are you positive dev kits for ESP8266 and ESP32 should have the same reception quality for Wifi? I'm starting to believe they don't, or that something hasn't been tuned-up yet somewhere in the toolchain.

[edit] added link

me-no-dev commented 7 years ago

@tobozo Will do my best to test this next week ;) I will be on a trip to help customers, but I'll have ESP8266 and ESP32 boards with me. Please ping back here around tuesday/wednesday so I do not forget :)

tobozo commented 7 years ago

(sorry for the misclose)

I just followed the tutorial to install micropython for esp32, then flashed the ESP32 and ran the wifi scan micropython code just to compare how many AP are returned.

I've run 10 scans per situation, here are the average values:

With the ESP32:

With the ESP8266:

[edit] If bad design on my ESP32 model affects RSSI, I still wonder why micropython returns more AP than an Arduino sketch. Speculation: BLE settings interfering with WiFi settings, scan loop exiting too fast ?

me-no-dev commented 7 years ago

interesting enough, there isn't any limitation imposed by the WiFi library in Arduino to how many APs are returned. Code is taken from the ESP8266 lib and only method calls are adapted. Maybe something default?

tobozo commented 7 years ago

I just found out that the gap between micropython and arduino is only observable in micropython after I make erase and make deploy.

Flashing with Arduino seems to cancel that effect.

If I make deploy micropython after a successful Arduino flash, there's no observable gap: the micropython library scan results give the same average as with Arduino.

Does it make sense the make erase somehow resets something that would allow me to enumerate more access points when using micropython ?

me-no-dev commented 7 years ago

There might be a setting that get's stored in NVS based on some config value maybe... and then does not get overridden unless you erase the flash

tobozo commented 7 years ago

Hey @me-no-dev I just received the same model as on your picture, and the quality/behaviour is the same as with the other models.

What settings should I be looking for? Is that part of Arduino, ESP-IDF or something else I should recompile?

tobozo commented 7 years ago

Could this be related

kriswiner commented 7 years ago

I'm curious how my ESP32 development board would fare in your tests. I only have one or two other wifi nodes close to my house (neighbors) but in my tests the ESP8285 and ESP32 behave about the same. Of course I don't use the ESP modules, I prefer to design my own circuit and I wonder if such a hardware design difference could be responsible for the difference in reception behavior you are seeing?

https://www.tindie.com/products/onehorse/esp32-development-board/?pt=full_prod_search

me-no-dev commented 7 years ago

Ok so I got around to do some tests today and can say that my ESB32 boards actually perform better than my ESP8266 boards. Signal quality is about the same (in terms of dB) but the ESP32 board finds much more networks. Now I do not have an env that has more than 10-15 APs in range, but the ESP32 get's most while the ESP8266 only finds like 4-5 most of the time.

tobozo commented 7 years ago

I haven't updated my sdk for a while so I'll git pull & test again later today. I've also ordered this model and probably will try @kriswiner 's suggestion too.

tobozo commented 7 years ago

I wrote a test sketch and collected some data from 4 different models of ESP32 and 2 different models of ESP8266.

I'm not sure what this all means, is that test even valid ?

[edit] spelling

kriswiner commented 7 years ago

I ran the test on my board and was able to detect just one AP (my local router); I got 93/100 hits with an average RSI of -29. Not sure what this means either. I often can detect the neighbors AP also, not this time.

tobozo commented 7 years ago

Would this test be more significant in a busy area? But looking again at the collected data, RSI is the same on ESP32 and ESP8266. The only notable difference is the amount of acces points returned by the scan.

me-no-dev commented 7 years ago

Latest commits include an updated api for scanning where you can define max time in ms to search each channel. Number returned results change when the default 300ms is increased, but scan takes longer too. Give it a go ;) I would like to close this one.

tobozo commented 7 years ago

Just updated the SDK (git pull + tools/get.exe) and ran the test sketch

Active Scan

Passive Scan

Am I using this right ?

tobozo commented 7 years ago

bump

This is still a problem: in an area where any ESP8266 model easily detects a 100 unique SSID in one single WiFiScan(), all ESP32 models I have only return an average 15 SSID (even the ESP32 Wrover Kit V3).

This time I've also tried this script and can conclude it's not Arduino related since this one does not use the IDE and features the same symptoms.

@me-no-dev @copercini how can I help resolve this issue? I have a bunch of ESP32/ESP8266 dev boards I can test with..

copercini commented 7 years ago

@tobozo It's crazy, but try connect to a network before scan, like replace these lines of example by WiFi.begin("router", "password");

tobozo commented 7 years ago

@copercini interesting, now it returns a bigger amount of SSIDs, but after a few scans:

192.168.1.12
Setup done
round #0 .. 64 results
round #1 .. 52 results
round #2 .. 53 results
round #3 .. 54 results
round #4 .. 61 results
round #5 .. no networks found
round #6 .. 64 results
round #7 .. 59 results
round #8 .. 54 results
round #9 .. E (54393) wifi: pm.c 956
Task watchdog got triggered. The following tasks did not feed the watchdog in time:
Tasks currently running:
CPU 0: wifi
CPU 1: IDLE
Task watchdog got triggered. The following tasks did not feed the watchdog in time:
Tasks currently running:
CPU 0: wifi
CPU 1: IDLE
Task watchdog got triggered. The following tasks did not feed the watchdog in time:
Tasks currently running:
CPU 0: wifi
CPU 1: IDLE
Task watchdog got triggered. The following tasks did not feed the watchdog in time:
Tasks currently running:
CPU 0: wifi
CPU 1: IDLE

[edit] also enabling debug makes it worse

tobozo commented 7 years ago

@copercini I'll close this issue since it's kinda sorted out, the watchdog thing only happens on the wrover kit anyway.

What I'm wondering is why do I have to WiFi.begin() (no arguments required) on ESP32 while it's not required on ESP8266, and also why does it matter?

copercini commented 7 years ago

Wrover module have a flash bug which does not work fine at 80Mhz.


About Scan, for me it works:

  WiFi.disconnect();
  WiFi.begin("lolllool","loooooooool"); //Can be a inexistent network

But this doesn't works:

  WiFi.disconnect();
  WiFi.begin();

So my guess it's something inside this function (WiFi.disconnect clean RF calibration maybe): https://github.com/espressif/esp-idf/blob/master/components/esp32/include/esp_wifi.h#L659 which I can't see the source code.

That's all I know.

tobozo commented 7 years ago

@copercini That's good to know, thanks for solving that long time mystery :+1:

copercini commented 7 years ago

For me it's still a bug!

The Espressif guys should take a look on the root cause or at least edit the example with the WiFi.begin workaround

tobozo commented 7 years ago

this doesn't work for me

  WiFi.disconnect();
  WiFi.begin();

however without WiFi.disconnect() this works without arguments [edit] not after erase_flash so my test was probably invalid

  WiFi.begin();

For me it's still a bug!

should I reopen this ticket then ?

copercini commented 7 years ago

Will reopen due it's still not fixed

Testato commented 6 years ago

I tried many core version and this Bug is present on some but not on others.

I can reproduce it, for example:

nevercast commented 6 years ago

Do you mind doing a git bisect to see if you can find the offending commit? @Testato From what I can see, there is two IDF changes between those commits. Would be good to narrow down the search space.

Testato commented 6 years ago

I'm not a Git expert so I never used bisect.

This bug is very important, it is present in the actual master version, i hope someone can solve it

me-no-dev commented 6 years ago

The reality is that those functions are in the closed wifi lib (no source to look at). BTW have you tried WiFi.mode(WIFI_STA); before going through scan?

tablatronix commented 6 years ago

What is the status of this issue?

tobozo commented 6 years ago

@tablatronix I can't observe the gap anymore, whether I use:

  WiFi.disconnect();
  WiFi.begin();

... or ...

  WiFi.begin("blahblah", "blahblah");

... the wrover kit I'm using for testing finds the same amount of AP's.

Closing this as resolved \o/

cgmckeever commented 4 years ago

@tobozo Sorry for dragging up an old issue .. But this seems to be the most conversed thread on this topic. May I ask what you found? Im finding that my ESP32's wifi performance are extremely poor compared to my ESP8266. Was that the consensus you had? And it seems that the Wrover ESP32 was more inline with the ESP8266 performance? Really appreciate it

tablatronix commented 4 years ago

@cgmckeever Ill try to test a comparison tomorrow, I have a network with over 30 aps, and both an esp8266 and esp32 variant of my own pcb I use.

Just to clarify you are strictly referring to wifiscan when you say "performance"

cgmckeever commented 4 years ago

@tablatronix Thanks for the ping! Actually, I mean just crappy wifi range in general. I cant get an ESP32 to connect to a AP 10 feet away, let alone through any obstacle

andi07x commented 4 years ago

I had the same problem with my ESP32 boards and Arduino IDE. After some research I found a hint that the WiFi is in power save mode. After adding

`

include

include

include

... void setup() { WiFi.mode(WIFI_STA); esp_wifi_set_ps( WIFI_PS_NONE );

... ` to my code the performance was comparable to the ESP8266. Hope this helps somebody.

leo-hofman commented 1 year ago

I changed the following in the YAML file and it appears to help:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.178.62
    gateway: 192.168.178.1
    subnet: 255.255.255.0
  output_power: 20dB
  power_save_mode: LIGHT