espressif / arduino-esp32

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

Change the amount of time it scans for a wifi signals #10082

Closed brandonfake69 closed 2 months ago

brandonfake69 commented 2 months ago

Related area

Wifi

Hardware specification

ESP32

Is your feature request related to a problem?

I am following the example from https://github.com/espressif/arduino-esp32/tree/0fa4aa632c6dcb7736a291a33fb9f0a25614d6d0/libraries/WiFi/examples/WiFiScan

It seems there is not a way to change the amount of time the ESP32 scans for a signal. For this, I am missing a LOT of access points I can find via other means. I would like to scan for 5 minutes but this seems to scan for about 5 seconds then return the results. How to fix?

Describe the solution you'd like

Scan for a longer time period.

Describe alternatives you've considered

Flipper zero

Additional context

No response

I have checked existing list of Feature requests and the Contribution Guide

brandonfake69 commented 2 months ago

Setting this seems to make no difference in the amount of time it scans:

  int n = WiFi.scanNetworks(false, true, false, 30000000);
lbernstone commented 2 months ago

From esp-idf doco

The values of maximum active scan time and passive scan time per channel are limited to 1500 milliseconds. Values above 1500ms may cause station to disconnect from AP and are not recommended.

Just a note. This is not a tutorial site. It is a forum for errors in the code here. Please ask general questions at https://esp32.com

P-R-O-C-H-Y commented 2 months ago

Hi @brandonfake69, as Ibernstone wrote, there is this note in docs of recommended maximum scan time per channel. Can you test the scan with: int n = WiFi.scanNetworks(false, true, false, 1500); if you get better scan results?

P-R-O-C-H-Y commented 2 months ago

@brandonfake69 Can you take a look and test the changes in the PR I linked? I have added an option to specify minimum active time for scanning. So now if I assume and use maximum recommended scan time 1500 ms, I ca was able to get from 5s scan time to 17,5 seconds of scan time. You can check the new example or run it directly. Thanks for any feedback.