WiFiManager icon indicating copy to clipboard operation
WiFiManager copied to clipboard

Not connecting to new WiFi without hard reset.

Open Kusnierz-Maciej opened this issue 10 years ago • 35 comments

After calling On Demand Configuration and configuring new wifi settings via configuration portal I get.

*WM: WiFi save *WM: Sent wifi save page *WM: Connecting to new AP *WM: Connecting as wifi client... *WM: Connection result: *WM: 0 *WM: Failed to connect. *WM: Request redirected to captive portal

WiFi settings are good, because after hard reset module connects to this wifi without any problems.

Kusnierz-Maciej avatar Jan 17 '16 13:01 Kusnierz-Maciej

hi, could you update to latest github of esp8266 core for arduino?

tzapu avatar Jan 17 '16 14:01 tzapu

Dear tzu, When you say to update to latest github of esp8266 core for Arduino, what exactly do you mean by that? I have Arduino (and ESP8266) installed in three places: /opt/arduino-1.6.5-r5 /home/odilon/.arduino15 / home / odilon / Arduino (sketch folder and private libraries) I do not know exactly where the esp8266 core Arduino must be installed I am very confused by the amount of directories that both the Arduino as ESP8266 use, as well as the speed with which new updates are made. Every time I do a new update, go through problems. Could anyone tell me how best to work with Arduino and esp8266 on Ubuntu Linux 15.04? I'm seriously considering uninstall ALL and start again. Is a good idea ? What release of Arduino should I use - the last? And the ESP8266 - 2.1.0-rc1? I'm using Arduino 1.6.5 for being compatible with the Eclipse and Arduino plugin for eclipse. But this is not the most important for me, if I need to update the Arduino IDE for the younger and abandon the use of eclipse. My application is running 100% ok with the AT firmware when I put the application code (webserver and arduino functions) into the arduino hardware (ProMini, Arduino Uno, Nano, etc..) and I use the ESP8266 ONLY for wifi. But now I want to use the ESP8266 WITHOUT Arduino... But this is proving to be impossible !!

odilonafonso avatar Jan 18 '16 16:01 odilonafonso

Hi,

Easiest for you to try would be to get arduino 1.6.6, and install through boards manager 2.1.0 rc1 of the esp core and 0.6 of wifimanager

If you are feeling adventurous, and this should work with 1.6.5, Try this https://github.com/esp8266/Arduino/blob/master/README.md#using-git-version-

Make sure you removed the esp8266 older version you have, there should be a hardware/esp8266 com folder somewhere.

tzapu avatar Jan 19 '16 05:01 tzapu

Ok... now I have Arduino IDE 1.6.7 and ESP8266WiFi git-version. Things appear a little better, but not 100%. Thanks for help. WiFiManager is a very nice tool !

odilonafonso avatar Jan 19 '16 19:01 odilonafonso

@Hooch180 could you try the change to the lib that @odilonafonso posted here https://github.com/tzapu/WiFiManager/issues/71#issuecomment-172958415

cheers

tzapu avatar Jan 20 '16 06:01 tzapu

I am experiencing the exact same problem as @Hooch180 with both the following configurations:

  • Arduino 1.6.7 + Arduino core for ESP8266 v2.0.0 + WiFiManager 0.6
  • Arduino 1.6.7 + Arduino core for ESP8266 GitHub version 2016-01-21 + WiFiManager GitHub version 2016-01-21

madcrow avatar Jan 21 '16 21:01 madcrow

@madcrow could you try the change that @odilonafonso made, listed above and see if it s better? cheers

tzapu avatar Jan 22 '16 07:01 tzapu

@tzapu I am afraid the solution offered by @odilonafonso won't be of any help in this scenario, because in this case the problem should be somewhere around the connectWifi() function call inside startConfigPortal() and NOT in autoConnect() .

Remember, this is the scenario, when:

  1. The ESP8266 tries to connect to an AP via autoConnect()
  2. The AP is unavailable or ESP8266 is not preconfigured for that particular AP -> the connectWifi() inside autoConnect returns something != WL_CONNECTED. (And this part of the library works perfectly well.)
  3. startConfigPortal() is called by autoConnect() -> the config portal is initialized, waiting for connections
  4. Teh user connects to config portal via browser, selects SSID, sets up credentials, and custom config data -> config portal signals connect=TRUE.
  5. The if (connect){} part of startConfigPortal() is being executed now, connection to the newly configured SSID is being attempted: if (connectWifi(_ssid, _pass) != WL_CONNECTED) //line 154 in WifiManager.cpp This is where the problem is: If the credentials were correctly configured, this connectWifi() call should return WL_CONNECTED. Instead it always returns 0, i.e WL_IDLE_STATUS.

madcrow avatar Jan 22 '16 07:01 madcrow

you are correct of course... and since you already tried 'Arduino 1.6.7 + Arduino core for ESP8266 v2.0.0 + WiFiManager 0.6' i m at a loss as to what to suggest... maybe try printing some messages to serial right before connecting to make sure _ssid & _pass did not get overwritten somehow? (poor memory management for instance..)

tzapu avatar Jan 22 '16 07:01 tzapu

I've just printed the SSID and pass: ... DEBUG_WM(F("SSID: ")); DEBUG_WM(_ssid); DEBUG_WM(F("Pass: ")); DEBUG_WM(_pass); if (connectWifi(_ssid, _pass) != WL_CONNECTED) { ...

And they were both accurate.

madcrow avatar Jan 22 '16 07:01 madcrow

bollox... if you just put WiFi.begin(ssid,pass) without wifi manager, does it work ok ?

tzapu avatar Jan 22 '16 07:01 tzapu

does it work after reset for you as well like for @Hooch180 ?

tzapu avatar Jan 22 '16 07:01 tzapu

@tzapu Now I swithed to WiFi.begin and manual conifg portal. I'm no longer using autoConnect. So yes. WiFi.begin works.

Kusnierz-Maciej avatar Jan 22 '16 07:01 Kusnierz-Maciej

so it must be that s happening when it goes from STA to AP and tries to connect. @madcrow if you still ahve the test sketch could you try to replace the begin in connectWifi with the following

WiFi.setAutoConnect(true); 
WiFi.begin(ssid.c_str(), pass.c_str(), 0, NULL, true);

tzapu avatar Jan 22 '16 08:01 tzapu

Yes, if I reset the module, it connects successfully, just like for @Hooch180.

madcrow avatar Jan 22 '16 08:01 madcrow

Unfortunatly I don't have access to my sketch and HW right now, because now I am writing from my workplace. But I will try your suggestion later.

madcrow avatar Jan 22 '16 08:01 madcrow

ok, there s another issue here that behaved similarly and a reboot was sorting it, so maybe i just have to add the feature to reset on end of configuration. wifi gets messed up a few times switching modes...

anyway, it would be really interesting to see the results of your test above, as i can t replicate the issue, i can t do it myself...

tzapu avatar Jan 22 '16 08:01 tzapu

Of course. I'll try it after work, I promise ;)

madcrow avatar Jan 22 '16 08:01 madcrow

Hmm... it is interesting that you cannot replicate the issue. I have a NodeMCU 1.0 board (ESP12E) and a bare ESP12F module. I tried autoconnect on both, and both behaved the same (i.e. reboot was necessary to successfully connect).

madcrow avatar Jan 22 '16 08:01 madcrow

i tried it on a wemos d1 mini and i ll try now on a nodemcu 1.0

tzapu avatar Jan 22 '16 08:01 tzapu