WiFi question - error connecting again

Hey guys! I'm having a problem that I don't know the reason for or if there's a solution. When I run the skecth below on ESP32 with the broadband internet at my house, the wifi connects and if I disconnect and reconnect the connection, it reconnects itself. But, if I use the 4g internet routed from my Smartphone, the wifi connects but if I disconnect the connection and connect again, it still appears as "disconnected".

Does anyone know why?

Thanks!

#include <WiFi.h>

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

}

void loop() {
  // put your main code here, to run repeatedly:
  if(WiFi.status() == WL_CONNECTED)
  {
    Serial.println("CONNECTED");
  }
  else
  {
    Serial.println("DISCONNECTED");
  }
}

Try printing out the actual Wifi status when it is "DISCONNECTED" is might give you a clue as to what is happening.

Not sure what you mean when you say "if I disconnect and reconnect the connection, it reconnects itself" do you mean if you disconnect and reconnect it works, or if you disconnect it will reconnect itself and works? Similarly when you say "if I disconnect the connection and connect again, it still appears as disconnected" do you mean you disconnect and reconnect it works, but disconnect and and it will not reconnect itself?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.