esp now: scanNetworks invoked asynchronously generates reset

grzegorz_kr
Posts: 6
Joined: Sun Apr 11, 2021 6:34 pm

esp now: scanNetworks invoked asynchronously generates reset

Postby grzegorz_kr » Sun Jan 16, 2022 2:59 pm

Hi All, I always get ESP32-WROOM-32D module reset when calling scanNetworks function asynchronously (with parameter: true).
Below is a code snippet.
(Entire sketch taken from: https://arduino-esp8266.readthedocs.io/ ... mples.html, please refer to the last example on this page)
The code is for ESP8266 but I assumed it would work the same for ESP32.
An asynchronous call is useful because it does not block other functions during a long network scan.
Unfortunately it always crashes while scanning.
Has anyone experienced something like this?

void loop()
{
..................

// trigger Wi-Fi network scan
if (currentMillis - lastScanMillis > SCAN_PERIOD)
{
WiFi.scanNetworks(true);
Serial.print("\nScan start ... ");
lastScanMillis = currentMillis;
}

// print out Wi-Fi network scan result upon completion
int n = WiFi.scanComplete();
if(n >= 0)
{
Serial.printf("%d network(s) found\n", n);
for (int i = 0; i < n; i++)
{
Serial.printf("%d: %s, Ch:%d (%ddBm) %s\n", i+1, WiFi.SSID(i).c_str(), WiFi.channel(i), WiFi.RSSI(i), WiFi.encryptionType(i));
}
WiFi.scanDelete();
}

}

grzegorz_kr
Posts: 6
Joined: Sun Apr 11, 2021 6:34 pm

Re: esp now: scanNetworks invoked asynchronously generates reset

Postby grzegorz_kr » Sun Jan 16, 2022 9:34 pm

ok, I found a problem: Serial.printf was the culprit.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], HighVoltage and 61 guests