0

in this code I am using wifiManager.setTimeout(60); so that when it fails to connect to the wifi it should restart. However, wifiManager.setTimeout(60) is not working at all. It get stuck and display these lines :

*WM: AutoConnect

*WM: Connecting as wifi client...

*WM: Using last saved values, should be faster

It never displays this :

"failed to connect and hit timeout"

which means wifiManager.setTimeout(60) is not working . Below is the code:

  #include <ESP8266WiFi.h>          

 //needed for library 
 #include <DNSServer.h>
 #include <ESP8266WebServer.h>
 #include <WiFiManager.h>          



  void setup() {
       // put your setup code here, to run once:
       Serial.begin(115200);

      //WiFiManager
       //Local intialization. Once its business is done, there is no need to 
       //keep it around
        WiFiManager wifiManager;
      //reset settings - for testing
      //wifiManager.resetSettings();

     //sets timeout until configuration portal gets turned off
     //useful to make it all retry or go to sleep
      //in seconds

      wifiManager.setTimeout(60);


  //fetches ssid and pass and tries to connect
  //if it does not connect it starts an access point with the specified name
 //here  "AutoConnectAP"
 //and goes into a blocking loop awaiting configuration

  if(!wifiManager.autoConnect("AutoConnectAP")) {
     Serial.println("failed to connect and hit timeout");
     delay(3000);
     //reset and try again, or maybe put it to deep sleep
     //ESP.reset();
     ESP.restart();
     //ESP.deepSleep(20e6, WAKE_RFCAL);
    delay(5000);
   } 

   //if you get here you have connected to the WiFi
   Serial.println("connected...yeey :)");

    ESP.deepSleep(20e6, WAKE_RFCAL);
    delay(3000);

 }

  void loop() {
  // put your main code here, to run repeatedly:

  }

I am using ESP8266 thing dev board. Can anyone please tell me what is wrong and how to resolve the issue ? Thank You!!

migrated from electronics.stackexchange.com Jan 1 at 5:50

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • Are you certain this comment is on one line? //Local intialization. Once its business is done, there is no need to keep it around. Also are you sure what times are in seconds and what is in mS? – Sparky256 Jan 1 at 3:04
  • Yes I have corrected it. Time is in seconds. 60 mean 1 minute. – Ahmed Jan 1 at 3:14
  • 2
    You'll probably need to pursue this with the author of the library. – Chris Stratton Jan 1 at 3:32
  • it must be using the last wifi settings - because Using last saved values means that it has successfully connected to an AP - though, it's surprising that "connected...yeey :)" isn't output – Jaromanda X Jan 1 at 6:23
  • add delay(500) after Serial.begin to see all the output from the beginning – Juraj Jan 1 at 9:00
-1

Try using setConfigPortalTimeout(60) instead of setTimeout(60)

Because it has been updated in version 0.10 of WiFiManager library. see : https://github.com/tzapu/WiFiManager#010

  • setTimeout just calls setConfigPortalTimeout - so there's no difference – Jaromanda X Jan 1 at 21:29

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.