ESP-01 suddenly wont connect to the wifi

im using an ESP-01 as a standalone microcontroller, and i was using it to send data from a sensor to the web

and it was working perfectly, but suddenly it just didnt. i went testing around and found out that apparently it was having trouble connecting to my wifi, even though the SSID and Password that i hardcoded in havent changed

next i also tested the same sketch on a diffrent ESP-O1, and it started working again

that lead me to believe i somehow blew the esp, but after a bit of testing it can still run every example sketch perfectly, even the WifiScan

this is the connecting part of the code

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

    delay(2000);
    
    WiFi.begin(ssid, pass);
    
    Serial.println("connecting");
    while(WiFi.status() != WL_CONNECTED){
      Serial.println(WiFi.status());
      delay(500);
      
    }

    if(WiFi.status() == WL_CONNECT_FAILED){
      Serial.println("failed to connect to wifi");
    }else{
      Serial.println("connected succesfully!");
    }
   
}

Wifi.status() here returns 7 for a while, and then 4
which i found out later that each number corresponds to a code

    WL_NO_SHIELD        = 255,   // for compatibility with WiFi Shield library
    WL_IDLE_STATUS      = 0,
    WL_NO_SSID_AVAIL    = 1,
    WL_SCAN_COMPLETED   = 2,
    WL_CONNECTED        = 3,
    WL_CONNECT_FAILED   = 4,
    WL_CONNECTION_LOST  = 5,
    WL_DISCONNECTED     = 6

but 7 is unlisted...

im completely stumped here

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