Skip to content

WiFi.scanNetworks() not working on ESP32 and no viable workaround yet? #3294

@zamorae

Description

@zamorae

Hardware:

Board: ESP32 Dev Module
Core Installation/update date:?
IDE name: Arduino IDE 1.8.5
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 921600
Computer OS: Windows 7 Ultimate SP1

Description:

Hi all,

I have bumped into a major problem in my project. When trying the WiFi.scanNetworks() operation it crashes the entire system. I tested it using the following chips:

ESP-WROOM-32
ESP-WROOM-32U

Before someone suggests visiting an existing thread/topic, I have visited all these and no one seems to have a clear workaround, plus all these are closed topics:

#758 Closed
#242 Closed
#791 Closed
#918 Closed
#1617 Closed

The closest work around is to run WiFiscan.ino adding a couple of lines of code that actually disconnects Wifi then calls a non-existent AP, but for me it doesn't work at all:

Sketch:

/*
 *  This sketch demonstrates how to scan WiFi networks.
 *  The API is almost the same as with the WiFi Shield library,
 *  the most obvious difference being the different file you need to include:
 */
#include "WiFi.h"

void setup()
{
    Serial.begin(115200);

    // Set WiFi to station mode and disconnect from an AP if it was previously connected
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    WiFi.begin("AccessPoint", "Password");  //tried the "lolllool","loooooooool" in #758 too
    delay(100);

    Serial.println("Setup done");
}

void loop()
{
    Serial.println("scan start");

    // WiFi.scanNetworks will return the number of networks found
    int n = WiFi.scanNetworks();
    Serial.println("scan done");
    if (n == 0) {
        Serial.println("no networks found");
    } else {
        Serial.print(n);
        Serial.println(" networks found");
        for (int i = 0; i < n; ++i) {
            // Print SSID and RSSI for each network found
            Serial.print(i + 1);
            Serial.print(": ");
            Serial.print(WiFi.SSID(i));
            Serial.print(" (");
            Serial.print(WiFi.RSSI(i));
            Serial.print(")");
            Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
            delay(10);
        }
    }
    Serial.println("");

    // Wait a bit before scanning again
    delay(5000);
}

I keep getting a fatal watchdog error on core 0:

Debug Messages:

⸮E (23527) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (23527) task_wdt:  - IDLE0 (CPU 0)
E (23527) task_wdt: Tasks currently running:
E (23527) task_wdt: CPU 0: wifi
E (23527) task_wdt: CPU 1: IDLE1
E (23527) task_wdt: Aborting.
abort() was called at PC 0x400d9a7f on core 0

Backtrace: 0x4008c7e0:0x3ffbe160 0x4008ca11:0x3ffbe180 0x400d9a7f:0x3ffbe1a0 0x40081789:0x3ffbe1c0 0x40132fb6:0x3ffb5290 0x40133005:0x3ffb52b0 0x401334b5:0x3ffb52d0 0x401303bd:0x3ffb5370 0x40130692:0x3ffb53f0 0x401310fa:0x3ffb5440 0x40131f50:0x3ffb5460 0x40132408:0x3ffb5480 0x400d9382:0x3ffb5540 0x400d9632:0x3ffb5570 0x4010d28d:0x3ffb55a0 0x4010d392:0x3ffb55d0 0x4010d68e:0x3ffb5600 0x4010d82b:0x3ffb5630 0x4008f8cc:0x3ffb5650 0x4008877d:0x3ffb5690

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:9232
load:0x40080400,len:6400
entry 0x400806a8
E (21412) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (21412) task_wdt:  - IDLE0 (CPU 0)
E (21412) task_wdt: Tasks currently running:
E (21412) task_wdt: CPU 0: wifi
E (21412) task_wdt: CPU 1: IDLE1
E (21412) task_wdt: Aborting.
abort() was called at PC 0x400d9a7f on core 0

Backtrace: 0x4008c7e0:0x3ffbe160 0x4008ca11:0x3ffbe180 0x400d9a7f:0x3ffbe1a0 0x40081789:0x3ffbe1c0 0x40132fb6:0x3ffb5290 0x40133005:0x3ffb52b0 0x401334b5:0x3ffb52d0 0x401303bd:0x3ffb5370 0x40130692:0x3ffb53f0 0x401310fa:0x3ffb5440 0x40131f50:0x3ffb5460 0x40132408:0x3ffb5480 0x400d9382:0x3ffb5540 0x400d9632:0x3ffb5570 0x4010d28d:0x3ffb55a0 0x4010d392:0x3ffb55d0 0x4010d68e:0x3ffb5600 0x4010d82b:0x3ffb5630 0x4008f8cc:0x3ffb5650 0x4008877d:0x3ffb5690

Please let me know if someone has tried a different workaround than the ones stated on the previous issues. I find it incredible that such a nice chip as the ESP32 has this major flaw that hinders its potential. I can get nothing from the Espressif forums on this, so I presume this is not a major problem for most people, the previous workarounds work fine for the majority, nobody uses the scan function (really?), or I am doing someting wrong.

I see from the previous postings that the issue started with an update on the libraries of the ESP and also that the threads go back to 2017 so its pretty worrisome that nobody is talking of this issue in 2019.

Thanks in advance
-EZ

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions