-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Can not connect to some routers #7360
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
This is a debug messages for another router that I connect with the same code (changing ssid). bcn 0 connected with PONESA-3G, channel 7 Connection established! |
I accessed the configuration of the CLARO2G router, to which the ESP was not being able to connect and manually placed it to use channel 7. bcn 0 connected with CLARO2G, channel 7 Connection established! |
The biggest issue I've had is the modem over-driving the router. I think the default WiFi.setOutputPower(x) is set to 17dBm, and I had to drop that to 5dBm to get reliable connection to my router. That's one thing to check, In any case. |
I did not know this method WiFi.setOutputPower (x). |
@odilonafonso readthedocs, but it's probably incomplete. |
The times I have seen this it's due to a bad wifi config on board. You have to wipe the flash when downloading the sketch. |
Grateful for the @devyte help, but I didn't understand what you mean. I have already tried to rewrite the firmware with the three options offered by the IDE: "Only sketch" I've already done another test; without modifying anything on the router, just adding any channel in the call to "Wifi.begin ()" and that sometimes works, other times it doesn't. I really don't know what to conclude, apparently it is a hardware failure and not a software failure. I'm thinking of adding a loop to the call Wifi.begin () adding one channel after another, until I get a connection. |
In my code it's usually |
Just an idea... would it make sense to make this output power dynamic, based on the RSSI of the AP you want to connect to? |
I always look at the .h source and often the .cpp |
I made some changes. I added a channel to Wifi.begin (). New sketch#include <ESP8266WiFi.h> // Include the Wi-Fi library
const char* ssid = "CLARO2G"; // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = "meiadeseda"; // The password of the Wi-Fi network
void setup() {
Serial.begin(115200); // Start the Serial communication to send messages to the computer
delay(10);
Serial.println("\n\n");
WiFi.mode(WIFI_STA);
int i = 0;
int ws;
long tini = millis();
long tnow;
#define CHINI 2
#define CHEND 9
#define INTERVAL 5000
int chan = CHINI;
int retrys;
#define NTRYS 3
while (true) {
Serial.println("Connecting to " + String(ssid) + " Channel:" + String(chan));
WiFi.begin(ssid, password, chan); // Connect to the network
retrys = 0;
while ( (ws = WiFi.status()) != WL_CONNECTED && retrys < NTRYS) { // Wait for the Wi-Fi to connect
tnow = millis();
if ( tnow - tini > INTERVAL ) {
++i;
Serial.println("Not connected after " + String(i*INTERVAL/1000) + "secs status:" + String(ws));
tini = tnow;
++retrys;
}
yield();
}
if (ws == WL_CONNECTED) break;
chan = (chan == CHEND ? CHINI : chan+1);
}
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
}
void loop() {} Debug messages
...... I don't know why I get this message: Why ? Why does the message say ESP is connected? |
It would make the source a lot more readable if you place 3 back-ticks before and after the source code block. And the AP you connect to determines the WiFi channel, not the client that tries to connect to it. |
If you can't connect to the AP, how can you tell if your TX power is too hot (or weak)? BER would be a better indicator unless the RSSI gives a "too hot" "too weak" response, as a number by itself is almost meaningless without a range. |
RSSI can output +31 as value indicating it is in some kind of error state. I agree about the limited meaning of the RSSI value. |
Back-ticks ? what are back-ticks? I do not call If it is not to provide the channel that I want to use, then what is the channel argument in the call for? And I still don't understand what the debug message is:
That must have probably been sent by the ESP8266WiFi library. |
The same as you use to mark a few words in code markup. As illustration, I will now use the wrong (the other) single quotes: To mark a word in 'code markup' ''' Now with the correct 'back ticks' (the single comma left from the To mark a word in
|
Thanks @TD-er !! |
@odilonafonso in your case, Wifi.begin() means connect the ESP's wifi station + establish a dhcp IP address. Your last log says |
@devyte Why did you close? The problem has not been solved.
The message I am just questioning why the message "connected to CLARO2G" arrives from "somewhere" and meanwhile I get "disconnected" status. |
@devyte this
This seems to me to be a software problem. There is no point in the library sending a "CONNECTED" log message and at the same time sending "DISCONNECTED" status. |
As a matter of fact, I do have also lots of reports where some units enter some kind of loop where they constantly report disconnect events and only remain connected for a very short while. Right now I don't have any clue as to where I have to look for a fix to this. |
@TD-er that sounds like a different thing. The logs here show a dhcp timeout. |
@odilonafonso I didn't say the message comes from your sketch. What I said was:
Both steps must complete to have a correct WiFi status. The first part (wifi connection) produces the connect message on channel 6. The second part (getting a dhcp IP from your dhcp server) times out and fails, so then the connection process resets and restarts.
|
What I can't understand is why Wemos is able to connect 100% of the time to other routers and with this (CLARO2G), the connection is not established regularly. |
I will try to add some logging to see if 'my' problem is actually different. |
@odilonafonso what I am telling you is that you have a dhcp timeout. Why that happens with the esp is something that you need to investigate, e. g. with wireshark, which is off topic here, because this is an issue tracker and not a general support forum. If the result of that investigation is that you see something wrong in our core (emphasis on this last part), then open an issue here, explain your findings, and we'll look into how to fix it. |
Netdump might be useful to monitor what is sent and received on the esp. |
I tried with two other wemos. Same problem. Debug log
What means this log message ? I used the third argument from WiFi.begin (). I specified the channel to use. Okay, it could be something else to be investigated, but it's clear from the documentation: WiFi.begin (ssid, pass, channel) The channel must be used. Or not ? WiFi.status() Returns
|
What means: error: pll_call exceeds ems!!! Debug logconnected with CLARO2G, channel 1 connected with CLARO2G, channel 1 |
You don't need to specify it.
They are generated by the closed source firmware. What version of the arduino core do you use (first line displayed on serial). |
@odilonafonso It can be used as a hint to speed up connecting, but in the end it is the access point you try to connect to that determines the channel to be used. |
|
Well, then why is there this option in the function call? |
Hello odilonafonso |
Try forcing to use 802.11b or 802.11g standard |
Using the sketch New sketch on 10 Jun 2020. |
You mean the code mentioned here in this comment? |
Thank you TD-er // PHY_MODE_11B = 802.11b // PHY_MODE_11G = 802.11g // PHY_MODE_11N = 802.11n WiFi.setPhyMode(WIFI_PHY_MODE_11G); |
Platform
Settings in IDE
Problem Description
ESP is unable to connect to some routers.
On some routers it works perfectly; others do not.
I was unable to identify the difference between the routers that explains this differentiated operation.
I tried to change the ssid, password.
It does not connect and after 250 seconds it connects and obtain a strange IP. It does not appear to be a LAN IP.
Sketch
#include <ESP8266WiFi.h> // Include the Wi-Fi library
const char* ssid = "CLARO2G"; // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = "mypassword"; // The password of the Wi-Fi network
void setup() {
Serial.begin(115200); // Start the Serial communication to send messages to the computer
delay(10);
Serial.println('\n');
Serial.println("\n\n");
WiFi.begin(ssid, password); // Connect to the network
Serial.print("Connecting to ");
Serial.print(ssid); Serial.println(" ...");
int i = 0;
int ws;
long tini = millis();
long tnow;
#define INTERVAL 10000
while ( (ws = WiFi.status()) != WL_CONNECTED) { // Wait for the Wi-Fi to connect
tnow = millis();
if ( tnow - tini > INTERVAL ) {
++i;
Serial.println("Not connected after " + String(i*INTERVAL/1000) + "secs status:" + String(ws));
tini = tnow;
}
yield();
}
Serial.println('\n');
Serial.println("Connection established!");
Serial.print("IP address:\t");
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
}
void loop() {}
Debug Messages
SDK:2.2.2-dev(38a443e)/Core:2.6.3=20603000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-16-ge23a07e/BearSSL:89454af
mode : sta(5c:cf:7f:36:89:dc) + softAP(5e:cf:7f:36:89:dc)
add if0
Connecting to CLARO2G ...
wifi evt: 8
wifi evt: 2
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt
connected with CLARO2G, channel 6
dhcp client start...
wifi evt: 0
Not connected after 10secs status:6
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
Not connected after 20secs status:6
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
Not connected after 30secs status:6
Not connected after 40secs status:6
Not connected after 50secs status:6
wifi evt: 7
wifi evt: 7
wifi evt: 7
......
...... (similar debug msgs)
......
wifi evt: 7
wifi evt: 7
Not connected after 250secs status:6
ip:169.254.221.137,mask:255.255.0.0,gw:0.0.0.0
wifi evt: 3
Connection established!
IP address: 169.254.221.137
wifi evt: 7
wifi evt: 7
wifi evt: 7
The text was updated successfully, but these errors were encountered: