ESP32 Not finding networks using wifiScan

Hi!

I trying to use the ESP32 for the first time and I wanted to do a simple wifi scan using the example code but the device cannot find any networks. I'm confused since my computer etc can all find them, just not the ESP32. I have no idea where to even start, I've had a look online and haven't seem to come across any answers.

Here's the Code I've been using:

/*
 *  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();
    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've tried two different esp32-wroom-32u boards, they are both functional otherwise.
I have added the Json, downloaded the boards, not sure what to do!

Thanks,

Just to be sure...
Could You draw a little schematics showing the powering? All devices containing transmitters use quite some current for transmitting and mistakes are not unusual.

At the location where the ESP32 are tested, how well is the WiFi reception on the computer? You should have at least 80% of the lines blacked as the ESP32 doesn't have an antenna as good as the computer has.
Also ensure that you have a 2.4GHz WiFi network as the ESP32 cannot use the 5 GHz range WiFi networks.

2 Likes

Do you have a WIFI enabled printer that is advertising for a connection? I did and had lots of similar trouble with a laptop in a far away bedroom. When I turned the printer WIFI off, the problem went away and the laptop could find the router very quickly.

1 Like

If I understand correctly, I only have the esp32 connected to my laptop and thats it.

Good. Then power issues can be ruled out. Hope the other replies help You.

1 Like

When doing WiFi scanning, the ESP32 is programmed into promiscious mode ... a special "listening" mode that does not use an AP point. Your PC only provides power and a serial terminal.

Maybe try different code:
ESP32 Useful Wi-Fi Library Functions (Arduino IDE) | Random Nerd Tutorials

1 Like

Hi all,

thanks for your replies and suggestions. - I appreciate it! I ended up going to another place and it detected networks! It was weird though because the channels the signals were on seemed to be 5Ghz, which my original wifi was on too. There also wasn't any wifi printers around and the both codes ended up working in the other place. very odd

cheers!

I can see my neighbors WIFI and they are 1/4 to 1/2 mile away!

Current ESP32 is only 2.4GHz

A 5GHz was rumored but I have not seen one.
Introducing ESP32-C5: Espressif’s first Dual-Band Wi-Fi 6 MCU | Espressif Systems

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.