-
Notifications
You must be signed in to change notification settings - Fork 13.3k
WiFi.scanNetworks() dont work #1355
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
Comments
similar problem...
the same example on latest github version (sdk 1.5):
it's looking like the latest sdk version (or wifi lib) do not show first network or skips it |
Oh, right, I think this was mentioned somewhere. Previously there was a bug On Thu, Jan 7, 2016, 18:13 reaper7 [email protected] wrote:
|
Yes, I can also confirm this behavior on 2.1.0-rc1. |
this still seems to be the issue with the latest github as well, is that correct? |
is the fix for this just in the example? |
@Links2004 no problem. It seems WiFi.scanNetworks(); is not working properly, not finding some or all of networks in latests sdks I am not sure how to go about replicating it... for instance, i have my own access point that does not appear in the scan, but if i enter ssid and pass manually, it works just fine cheers |
WiFi.scanNetworks() still do not working properly :( WifiScan example show 5 networks - do not show(or find?) TP-LINK_XXXXXX network. But this network are in range because ESP can connect to it (without any problems!) with other examples like WiFiWebServer etc! |
@igrr can you fix it? |
it looks like first found network are "under index 0" |
Looks like the code has changed — I was referring to an older version which I wrote initially. |
now works ok :) |
i can also confirm it s working, thank you very much |
Thanks for the scan fix which I think I have completed. It seems better now but I'm not 100% convinced I have it right. One router is 6" from my PC and reads 100%, the main router next door is 76% but when I keep scanning over and over again I see one or the other plus lots of 20% to 50% routers but never both of mine together. That suggests I might still be missing the first index in the scan or ESP's are a little crazy. The closest router is a bridge from the main router so I guess that could be the reason it only sees one but they do have different SSID's. Also with the 100% router switched off it takes 5 to 10 rescans to find the 76% router even though each scan is finding 6 or 7 20% to 50% routers. Is this normal behaviour from the ESP's or am I still missing the first index? |
your scan look like there are many routers out there, |
i am not 100% positive, but i think i have seen more than 12 .... |
i was wrong, i can test |
12 is about the most I have seen but each scans seems to bring up different AP's. Or perhaps I should say not exactly the same 6 to 12 it found on the previous scan. Sometimes very different and sometimes missing both of my 100% and 75% AP's. |
Just seen 13 AP's, none of which were my AP's. |
Could it be channel collisions or a specific mode, I remember seeing someone having an issue with B routers. Channel collisions ? Mine fluctuates from 22- 27 aps /*
* 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 "ESP8266WiFi.h"
void setup() {
Serial.begin(115200);
// Serial.setDebugOutput(true);
// 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");
Serial.println();
Serial.println("MAC: " + WiFi.macAddress());
}
String encryptionTypeStr(uint8_t authmode) {
switch(authmode) {
case ENC_TYPE_NONE:
return "NONE";
case ENC_TYPE_WEP:
return "WEP";
case ENC_TYPE_TKIP:
return "TKIP";
case ENC_TYPE_CCMP:
return "CCMP";
case ENC_TYPE_AUTO:
return "AUTO";
default:
return "?";
}
}
void loop() {
Serial.println("scan start");
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks(false,true);
Serial.println("scan done");
if (n == 0)
Serial.println("no networks found");
else
{
// sort by RSSI
int indices[n];
for (int i = 0; i < n; i++) {
indices[i] = i;
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (WiFi.RSSI(indices[j]) > WiFi.RSSI(indices[i])) {
//int temp = indices[j];
//indices[j] = indices[i];
//indices[i] = temp;
std::swap(indices[i], indices[j]);
}
}
}
Serial.print(n);
Serial.println(" networks found");
Serial.println("00: (RSSI)[BSSID][hidden] SSID [channel] [encryption]");
for (int i = 0; i < n; ++i)
{
// Print SSID and RSSI for each network found
// Serial.print(i + 1);
Serial.printf("%02d", i + 1);
Serial.print(":");
Serial.print(" (");
Serial.print(WiFi.RSSI(indices[i]));
Serial.print(")");
Serial.print(" [");
Serial.print(WiFi.BSSIDstr(indices[i]));
Serial.print("]");
Serial.print(" [");
Serial.print((String) WiFi.isHidden(indices[i]));
Serial.print("]");
Serial.print(" " + WiFi.SSID(indices[i]));
// Serial.print((WiFi.encryptionType(indices[i]) == ENC_TYPE_NONE)?" ":"*");
Serial.print(" [");
Serial.printf("%02d",(int)WiFi.channel(indices[i]));
Serial.print("]");
Serial.print(" [");
Serial.print((String) encryptionTypeStr(WiFi.encryptionType(indices[i])));
Serial.print("]");
Serial.println();
delay(10);
}
}
Serial.println("");
// Wait a bit before scanning again
delay(10000);
} |
I am also now seeing something similar after testing for a bit, for example my home router disappearing from scans now and then, maybe 2 out of 10 times EDIT EDIT |
Threw nodemcu on my chip and am not seeing this behavior. Ill keep looking into it. |
Well more testing and cannot reproduce now. Might be some channel interference, or fast scan switching modes, but my home ap is showing up in every scan now on 2 boards after thousands of scans. Will post details if it occurs again or I can isolate the operating mode |
This one is getting quite long, and the original bug has been fixed. @tablatronix please open a new issue if you are able to reproduce it. |
hi everyone |
AnanthaChakravarthi : I'm guessing different antenna & wifi chips will have different success rates at detecting wifi networks. likely the esp8266 has poorer quality antenna and wifi chip than your mobile has. I'm still curious if this is a hardware thing, or software delays needed to allow 'better' finding of wifi ssid's. |
Worked for me: It's only helped``` /* 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 "ESP8266WiFi.h"void setup() { // Set WiFi to station mode and disconnect from an AP if it was previously connected Serial.println("Setup done"); void loop() { Serial.println("scan start"); // WiFi.scanNetworks will return the number of networks found if (n == 0) { // Wait a bit before scanning again
|
Source
git clone https://github.com/esp8266/Arduino.git esp8266
function
WiFi.scanNetworks();
don't find any networks
The text was updated successfully, but these errors were encountered: