-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
SOLVED: Wifi.config not working? #128
Comments
You need to do config() after begin(). |
Thank you Imroy - with config() after begin() it works! |
Thanks this solved my problem also. In my case that is for the WiFi.softAPConfig |
This also works for WiFiMulti.run(), where there is no begin(). |
Thanks for the info. Cleared my issue. |
Hello this is my code IPAddress ip(10,0,0,101); Thanks for your support |
same for me - SNM isn't working... |
I have found WiFi.config issue, for some reason, is particularly sensitive to serial upload speeds. Go figure. But slowing down the serial upload got me back on track. Maybe it'll help you. |
Rolling back to V2.2.0 fixed all my static IP connection problems |
Using NodeMCU/lua, I've found several issues trying to connect after using config and changing the password or auth parameters for AP mode or stationap . Using NodeMCU, according to the doc's the config statement for AP mode is in the form wifi.ap.config(cfg) Where: |
Iam using wifi shield Esp8266 is connected the my laptop but wifi shield getting data not produce in laptop. my wifi shield port is showing in my laptop network settings .i was click the showing wifi shield port is open then show NO internet open. what is the problem showing NO internet open. then i was do the trouble shooting in my network settings after trouble shooting problem found --The DNS Server is not responding. |
Iam using wifi shield Esp8266 is connected the my laptop but wifi shield getting data not produce in laptop. my wifi shield port is showing in my laptop network settings .i was click the showing wifi shield port is open then show NO internet open. what is the problem showing NO internet open. then i was do the trouble shooting in my network settings after trouble shooting problem found --The DNS Server is not responding. |
I was having the same problem and i thing i found the solution . the order on the manual is WiFi.config(ip, dns, gateway, subnet) but after inspection of the library it seem the the CORRECT order have to be From a computer guy point of view it is logical . So for example if you want to declare a DNS wich is mandatory to resolve names |
I have downloaded tcp client application from playstore.i have to connect it to my wifi module esp8266.my ip address is 192.168.1.128 then what is my port number..pls help me |
Just to add to this. As @thorathome said, slowing down to 57600 baud uploads completely fixed this issue for me. Nothing else I tried would work. |
According to this: esp8266/Arduino#128 Wifi.config() needs to be called after Wifi.begin(). Otherwise the static IP issn't used by the ESP8266 gateway.
According to this: esp8266/Arduino#128 Wifi.config() needs to be called after Wifi.begin(). Otherwise the static IP issn't used by the ESP8266 gateway.
I've run into this issue primarily after the I've just uploaded a new firmware to the ESP8266 directly from the Arduino IDE. At first it assigns itself a DHCP address even with a call to My work around, which so far works, is to send some data through the connection and then check whether the IP address is as expected. In my case I'm sending a syslog packet and a DNS query to get enough data through (delays and Serial.print() don't seem to affect it). Below is my currently working code:
|
What I've determined by watching network traffic and logs is that after uploading a new firmware directly from the Arduino IDE the ESP8266 will try to get it's IP via DHCP even if you give it a static address via The ESP8266 will behave properly once power has been removed and restarted. As such my solution above won't always catch the problem depending on the timing of any DHCP reply from the DHCP server after setting the static IP. Adding the check inside your loop() will catch things eventually if the address does get set via DHCP but that is a poor workaround that only makes sense if the underlying bug can't be fixed. |
Thanks for having opened a new issue in #4656 |
Many older examples left off the DHCP server and it used to work fine with just WiFi.config(staticIP, gateway, subnet). After updating to a recent (ie. 2.5.0) library the WiFi.hostByName function in my NTP routine stopped working and just returned "(IP unset)". Apparently the older libraries didn't need the DHCP server in WiFi.config but the newer libraries do. |
??? DHCP server address is not used in hostByName() function - actually you don't have to set DHCP server address, because that address is contained in DHCP response packet. Did you mean DNS server? |
I agree with jstuewe that the 4th parameter DNS server is required when I started using the NTPClient library. I fought this issue for 2 hours tonight after adding the NTPClient library and code to a previously working version of code. Google search found this github posting and his reply solved my problem. |
Posting from jstuewe is a lifesaver. I was stuck since last 2 weeks with not being able to access internet through my esp8266. Adding gateway as the 4th parameter fixes the issue. Funny that devs made a breaking change without documenting it. The official documentation for WiFi.config() is obsolete, incomplete and useless. |
Glad my comment helped. They definitely need to update the documentation. |
Arduino legacy API: https://www.arduino.cc/en/Reference/EthernetBegin note: in current master, this code is split between here and there (this is current master = pre-v3) If one of them is not working, please open a new issue for us to keep track of it so we can solve them in the next versions. |
The issue in the v2.7.4 API document is that the DNS parameter is listed as optional. Using a static IP address worked without a DNS entry in older libraries but in 2.5.0 and above it can't resolve DNS entries if you don't include the DNS parameter. I don't know if it's an issue with the code or the documentation but one or the other needs to be updated. In my case, I included the gateway again in the 4th\dns1 parameter to fix it.
This is also discussed in #2371 |
Do I understand that you can resolve addresses with a static IP setup without giving a DNS parameter ? |
Kind of? Most DHCP setups will provide the DNS servers to their clients. It would be unusual to need a manually defined DNS server together with DHCP |
I was answering to that:
|
Right, yeah. That would only work as you described. Name resolution needs something to provide that data, it won’t “just work” |
It did 'Just work' before 2.5.0 so older code and examples stop working after updating. Probably due to the hard coded DNS serves d-a-v mentioned above. The issue is that the documentation lists DNS as optional where it is required for most use cases. It would be nice to include that in the documentation. I don't know if it would be appropriate, but it it would work in many cases to include the gateway as a default DNS server if one isn't provided. My code uses WiFi.config(staticIP, gateway, subnet, gateway) |
I am trying to set static IP address, and tried this:
IPAddress ip(192,168,0,124);
(...)
WiFi.config(ip);
WiFi.begin(ssid, password);
Compiler error: It wants three arguments: IP, gateway, subnet.
New attempt:
IPAddress ip(192,168,0,124);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
(...)
WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
This compiles, but the IP address does not change.
Please advise.
The text was updated successfully, but these errors were encountered: