Skip to content

ESP8266 WiFi.scanNetworks returns 0...always #4543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Normtot opened this issue Mar 21, 2018 · 10 comments
Closed

ESP8266 WiFi.scanNetworks returns 0...always #4543

Normtot opened this issue Mar 21, 2018 · 10 comments

Comments

@Normtot
Copy link

Normtot commented Mar 21, 2018

My new nodeMCU board (purchased March 2018), having no additional wiring other than the USB to a PC, will not respond with any wifi networks upon running a WiFi.scanNetworks call. The board is surrounded by many networks as per the results of my phone sitting next to it. Other sketches developed on the Arduino IDE for serial communications work well, as do sketches on the GPIO pins with sensors, but the WiFi does not work to minimally see networks.

I've tried flashing it, using capacitors for the power supply, grounding some pins, etc. This nodeMCU from HiLetGo with AI-THINKER ESP8266 just won't "see" any networks. Attempting to log into a specific network with WiFi.begin obviously doesn't work either because it doesn't see the network.

Can someone tell me if there is an even more basic test than WiFi.scanNetworks to run to determine if the WiFi portion of this chip is working?

@electrical-pro
Copy link

electrical-pro commented Mar 21, 2018

Does soft AP work?
Soft AP example

@Normtot
Copy link
Author

Normtot commented Mar 21, 2018

My phone doesn't see the soft AP of the ESP8266. I thought I would focus on the client portion of the ESP8266.

@electrical-pro
Copy link

electrical-pro commented Mar 21, 2018

My new nodeMCU board

Do you have other ESP8266? and if so do they work?
When using soft AP what do you see in serial after "Setting soft-AP ... " do you see "Ready" or "Failed!"?

@Normtot
Copy link
Author

Normtot commented Mar 21, 2018

I have no other ESP8266 boards. When the sketch is run, some commands output some diagnostic results, such as mode: STA+AP, PHY mode: N, bcn 100, etc. This is a sketch from Arduino IDE. I suspect that Ready or Failed are AT command responses? What type of network would I see from my phone if the soft AP was working?

@electrical-pro
Copy link

#include <ESP8266WiFi.h>

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

  Serial.print("Setting soft-AP ... ");
  boolean result = WiFi.softAP("ESPsoftAP_01", "pass-to-soft-AP");
  if(result == true)
  {
    Serial.println("Ready");
  }
  else
  {
    Serial.println("Failed!");
  }
}

void loop()
{
  Serial.printf("Stations connected = %d\n", WiFi.softAPgetStationNum());
  delay(3000);
}

If you are using this example then you will see a network with a name ESPsoftAP_01
In the serial you should see this, if soft AP started successfully:

Setting soft-AP ... Ready
Stations connected = 0
Stations connected = 0

If soft ap start is not successful then you will see Failed! instead of Ready

@Normtot
Copy link
Author

Normtot commented Mar 21, 2018

Some success! Thanks. The code above returns "Ready". So something is working. However, it is returning zero stations connected, even having my phone's wi-fi next to it. Also, my phone doesn't see the wi-fi network ESPsoftAP_01.

@electrical-pro
Copy link

electrical-pro commented Mar 21, 2018

If it returns Setting soft-AP ... Ready it means you should see the wi-fi network ESPsoftAP_01 on your phone, and if you don't see it, then it means we have no idea what is the problem. Maybe it is a hardware issue, but I am not an expert. By the way, in the description, you should say what core version you use. I recommend trying it with 2.3.0 or 2.4.1 core version, maybe one of them will work.

@Normtot
Copy link
Author

Normtot commented Mar 21, 2018

Thanks. That's what I was afraid of. :)

@devyte
Copy link
Collaborator

devyte commented Mar 21, 2018

Note: struct scan_config is inited with:

    struct scan_config config;
    memset(&config, 0, sizeof(config));

With SDK 2.2, scan_config struct received new data members:

struct scan_config {
    uint8 *ssid;    // Note: ssid == NULL, don't filter ssid.
    uint8 *bssid;    // Note: bssid == NULL, don't filter bssid.
    uint8 channel;    // Note: channel == 0, scan all channels, otherwise scan set channel.
    uint8 show_hidden;    // Note: show_hidden == 1, can get hidden ssid routers' info.
    wifi_scan_type_t scan_type; // scan type, active or passive    
    wifi_scan_time_t scan_time; // scan time per channel     // <--- new, struct has min and max times, both are now set to 0
};

It is currently unknown whether setting both min and max to 0 makes sense or is well-behaved.

@devyte
Copy link
Collaborator

devyte commented Oct 14, 2020

I have WiFi.scanNetworks working in my own app, and I believe @Erriez also just did a test with scanning while implementing #7629. That means that the current core has scan working correctly.
Closing due to can't reproduce.

@devyte devyte closed this as completed Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants