Chat freely about anything...

User avatar
By donnib
#38789 Hi,
I have this construction :
Code: Select allvoid LaunchWifi()
{
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  WiFi.config(ip,gateway,subnet);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}


and sometimes it ends up in the while and never connects, if i reboot the device it usually works so what is the best approach to wait say 5sec then retry to connect from start again ?

donnib
User avatar
By donnib
#38827
Mario Mikočević wrote:Try this ->

Code: Select all  if( !WiFi.isConnected() ) {
    Serial.println( "Disconnected!" );
    WiFi.reconnect();
    WiFi.waitForConnectResult();
  }


Thx but i don't have WiFi.isConnected(), in which library is that ?