espsss / reference / quick / wifi-status-codes

WiFi.status() values

WiFi.status() returns a value that the core updates from Wi-Fi events. Here is what each number means in arduino-esp32 3.3.12 and which event or reason code sets it.

In short

  • WL_CONNECTED (3) is set only when the station gets an IP address; right after association the status is WL_IDLE_STATUS (0).1
  • WiFi.begin() does not wait: it returns the current status right after starting the connection attempt. Use WiFi.waitForConnectResult() (default timeout 60000 ms) or poll WiFi.status().21
  • After a failure the status reflects the last disconnect reason: 201 → WL_NO_SSID_AVAIL, 200 or 204 → WL_CONNECTION_LOST, 202 or 203 → WL_CONNECT_FAILED (with conditions), most others → WL_DISCONNECTED.1

wl_status_t values

ValueNameWhen arduino-esp32 3.3.12 sets it
0WL_IDLE_STATUSAssociated with the AP but no IP address yet (STA_CONNECTED), or the IP was lost (STA_LOST_IP).3
1WL_NO_SSID_AVAILDisconnected with reason 201 NO_AP_FOUND: the scan did not find the network. Reasons 210…212 do not set it.3
2WL_SCAN_COMPLETED3—
3WL_CONNECTEDThe station got an IP address (STA_GOT_IP). Association alone is not enough.3
4WL_CONNECT_FAILEDReason 202 AUTH_FAIL (not on the very first disconnect since boot), or reason 203 ASSOC_FAIL when the core does not reconnect. Also returned by WiFi.begin() when the station could not be started or STA.connect() failed (bad SSID or passphrase length, configuration or connect error).3
5WL_CONNECTION_LOSTReason 200 BEACON_TIMEOUT or 204 HANDSHAKE_TIMEOUT.3
6WL_DISCONNECTEDThe station has started but is not connected (STA_START), or it disconnected with any reason not listed above. Reason 2 AUTH_EXPIRE leaves the status unchanged.3
254WL_STOPPEDThe station is not running: the initial value, and after STA_STOP.3
255WL_NO_SHIELD3Kept for compatibility with the WiFi Shield library; never set.

Reason codes are the Wi-Fi disconnect reasons (wifi_err_reason_t). Station side only (libraries/WiFi/src/STA.cpp).

WiFi.begin() and waitForConnectResult()

WiFi.begin(ssid, pass) returns at once

It starts the station, configures it and calls esp_wifi_connect(), then returns STA.status(). It returns WL_CONNECT_FAILED only when the station cannot be started or STA.connect() fails (missing or too long SSID, passphrase over 64 characters, a configuration error, or an esp_wifi_connect() error), not when the AP rejects the station later.2

waitForConnectResult(timeoutLength = 60000)

Polls every 100 ms while the status is WL_IDLE_STATUS (0) or WL_DISCONNECTED (6) and above, until it changes or the timeout runs out, then returns the status. If station mode is not enabled it returns WL_DISCONNECTED at once.1

It can return before the connection settles

WL_NO_SSID_AVAIL, WL_CONNECT_FAILED and WL_CONNECTION_LOST also end the wait, even though the core may still be retrying in the background.13

WiFi.begin("my-ssid", "my-password");
uint8_t st = WiFi.waitForConnectResult(15000);
if (st != WL_CONNECTED) {
  Serial.printf("Not connected, WiFi.status() = %u\n", st);
}

Wi-Fi event numbers

The arduino_event_id_t values that WiFi.onEvent() passes for Wi-Fi station and soft-AP events, and the status the station code sets on each.

IDEventWiFi.status() set to
100ARDUINO_EVENT_WIFI_OFF—4
101ARDUINO_EVENT_WIFI_READY—4
102ARDUINO_EVENT_WIFI_SCAN_DONE—4
103ARDUINO_EVENT_WIFI_FTM_REPORT—4
110ARDUINO_EVENT_WIFI_STA_STARTWL_DISCONNECTED4
111ARDUINO_EVENT_WIFI_STA_STOPWL_STOPPED4
112ARDUINO_EVENT_WIFI_STA_CONNECTEDWL_IDLE_STATUS4
113ARDUINO_EVENT_WIFI_STA_DISCONNECTEDdepends on the reason (table above)4
114ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE—4
115ARDUINO_EVENT_WIFI_STA_GOT_IPWL_CONNECTED4
116ARDUINO_EVENT_WIFI_STA_GOT_IP6—4
117ARDUINO_EVENT_WIFI_STA_LOST_IPWL_IDLE_STATUS4
130ARDUINO_EVENT_WIFI_AP_START—4
131ARDUINO_EVENT_WIFI_AP_STOP—4
132ARDUINO_EVENT_WIFI_AP_STACONNECTED—4
133ARDUINO_EVENT_WIFI_AP_STADISCONNECTED—4
134ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED—4
135ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED—4
136ARDUINO_EVENT_WIFI_AP_GOT_IP6—4

IDs follow from the enum in NetworkEvents.h; checked with static_assert in a sketch compiled with arduino-esp32 3.3.12 for esp32s3.

Pitfalls

The first AUTH_FAIL is not WL_CONNECT_FAILED

first_connect is a static flag: on the first disconnect since boot the core retries once whatever the reason (except 8 ASSOC_LEAVE), and AUTH_FAIL does not set WL_CONNECT_FAILED then. The flag is never set back, so later begin() calls do not get this extra retry.1

Checking for WL_DISCONNECTED only

A sketch that waits with while (WiFi.status() == WL_DISCONNECTED) stops waiting at WL_IDLE_STATUS, before an IP address is assigned. Wait for WL_CONNECTED instead.15

Sources

Each number links here; open “What it confirms” for the exact quotes. Checked 2026-11-28.

  1. arduino-esp32 3.3.12: libraries/WiFi/src/STA.cpp primary
    What it confirms (7)
    • WiFi.status() values: in short “} else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_GOT_IP) { … _sta_network_if->_setStatus(WL_CONNECTED); … } else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_CONNECTED) { _sta_network_if->_setStatus(WL_IDLE_STATUS);”
    • WiFi.status() values: in short “if (tryConnect) { esp_err_t err = esp_wifi_connect();”
    • WiFi.status() values: in short “if (reason == WIFI_REASON_NO_AP_FOUND) { _sta_network_if->_setStatus(WL_NO_SSID_AVAIL); … } else if (reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) { _sta_network_if->_setStatus(WL_CONNECTION_LOST);”
    • WiFi.status() values: waitForConnectResult(timeoutLength = 60000) “uint8_t waitForConnectResult(unsigned long timeoutLength = 60000); … if ((WiFiGenericClass::getMode() & WIFI_MODE_STA) == 0) { return WL_DISCONNECTED; … while ((!status() || status() >= WL_DISCONNECTED) && (millis() - start) < timeoutLength) { delay(100); } return status();”
    • WiFi.status() values: It can return before the connection settles “while ((!status() || status() >= WL_DISCONNECTED) && (millis() - start) < timeoutLength) { … } else if (first_connect) { //Retry once for all failure reasons … } else if (_sta_network_if->getAutoReconnect() && _is_staReconnectableReason(reason)) {”
    • WiFi.status() values: pitfall: The first AUTH_FAIL is not WL_CONNECT_FAILED “static bool first_connect = true; … } else if ((reason == WIFI_REASON_AUTH_FAIL) && !first_connect) { … } else if (first_connect) { //Retry once for all failure reasons first_connect = false; … if (reason == WIFI_REASON_ASSOC_LEAVE) { //Voluntarily disconnected. Don't reconnect!”
    • WiFi.status() values: pitfall: Checking for WL_DISCONNECTED only “} else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_CONNECTED) { _sta_network_if->_setStatus(WL_IDLE_STATUS);”
  2. arduino-esp32 3.3.12: libraries/WiFi/src/WiFiSTA.cpp primary
    What it confirms (2)
    • WiFi.status() values: in short “if (!STA.connect(ssid, passphrase, channel, bssid, tryConnect)) { return WL_CONNECT_FAILED; } return STA.status(); … uint8_t waitForConnectResult(unsigned long timeoutLength = 60000);”
    • WiFi.status() values: WiFi.begin(ssid, pass) returns at once “wl_status_t WiFiSTAClass::begin(const char *ssid, const char *passphrase, int32_t channel, const uint8_t *bssid, bool tryConnect) { if (!STA.begin()) { return WL_CONNECT_FAILED; } … return STA.status(); … esp_err_t err = esp_wifi_connect(); … log_e("SSID too long or missing!"); … if (passphrase && strlen(passphrase) > 64) {”
  3. arduino-esp32 3.3.12: libraries/WiFi/src/WiFiType.h primary
    What it confirms (10)
    • WiFi.status() values: 0 “WL_IDLE_STATUS = 0, … } else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_CONNECTED) { _sta_network_if->_setStatus(WL_IDLE_STATUS); … } else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_LOST_IP) { _sta_network_if->_setStatus(WL_IDLE_STATUS);”
    • WiFi.status() values: 1 “WL_NO_SSID_AVAIL = 1, … if (reason == WIFI_REASON_NO_AP_FOUND) { _sta_network_if->_setStatus(WL_NO_SSID_AVAIL); … } else { _sta_network_if->_setStatus(WL_DISCONNECTED);”
    • WiFi.status() values: 2 / Name “WL_SCAN_COMPLETED = 2,”
    • WiFi.status() values: 3 “WL_CONNECTED = 3, … _sta_network_if->_setStatus(WL_CONNECTED); } else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_LOST_IP) { … } else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_GOT_IP) {”
    • WiFi.status() values: 4 “WL_CONNECT_FAILED = 4, … } else if ((reason == WIFI_REASON_AUTH_FAIL) && !first_connect) { _sta_network_if->_setStatus(WL_CONNECT_FAILED); … } else if (reason == WIFI_REASON_ASSOC_FAIL) { _sta_network_if->_setStatus(WL_CONNECT_FAILED); … if (!STA.connect(ssid, passphrase, channel, bssid, tryConnect)) { return WL_CONNECT_FAILED;”
    • WiFi.status() values: 5 “WL_CONNECTION_LOST = 5, … } else if (reason == WIFI_REASON_BEACON_TIMEOUT || reason == WIFI_REASON_HANDSHAKE_TIMEOUT) { _sta_network_if->_setStatus(WL_CONNECTION_LOST);”
    • WiFi.status() values: 6 “WL_DISCONNECTED = 6 … if (ev->event_id == ARDUINO_EVENT_WIFI_STA_START) { _sta_network_if->_setStatus(WL_DISCONNECTED); … } else if (reason == WIFI_REASON_AUTH_EXPIRE) { } else { _sta_network_if->_setStatus(WL_DISCONNECTED);”
    • WiFi.status() values: 254 “WL_STOPPED = 254, … _status(WL_STOPPED) … } else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_STOP) { _sta_network_if->_setStatus(WL_STOPPED);”
    • WiFi.status() values: 255 / Name “WL_NO_SHIELD = 255, // for compatibility with WiFi Shield library”
    • WiFi.status() values: It can return before the connection settles “WL_NO_SSID_AVAIL = 1, … WL_CONNECT_FAILED = 4, … WL_CONNECTION_LOST = 5, … WL_DISCONNECTED = 6”
  4. arduino-esp32 3.3.12: libraries/Network/src/NetworkEvents.h primary
    What it confirms (19)
    • WiFi.status() values: 100 “ARDUINO_EVENT_WIFI_OFF = 100,”
    • WiFi.status() values: 101 “ARDUINO_EVENT_WIFI_READY,”
    • WiFi.status() values: 102 “ARDUINO_EVENT_WIFI_SCAN_DONE,”
    • WiFi.status() values: 103 “ARDUINO_EVENT_WIFI_FTM_REPORT,”
    • WiFi.status() values: 110 “ARDUINO_EVENT_WIFI_STA_START = 110, … if (ev->event_id == ARDUINO_EVENT_WIFI_STA_START) { _sta_network_if->_setStatus(WL_DISCONNECTED);”
    • WiFi.status() values: 111 “ARDUINO_EVENT_WIFI_STA_STOP, … if (ev->event_id == ARDUINO_EVENT_WIFI_STA_STOP) { _sta_network_if->_setStatus(WL_STOPPED);”
    • WiFi.status() values: 112 “ARDUINO_EVENT_WIFI_STA_CONNECTED, … if (ev->event_id == ARDUINO_EVENT_WIFI_STA_CONNECTED) { _sta_network_if->_setStatus(WL_IDLE_STATUS);”
    • WiFi.status() values: 113 “ARDUINO_EVENT_WIFI_STA_DISCONNECTED, … } else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_DISCONNECTED) {”
    • WiFi.status() values: 114 “ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE,”
    • WiFi.status() values: 115 “ARDUINO_EVENT_WIFI_STA_GOT_IP, … } else if (ev->event_id == ARDUINO_EVENT_WIFI_STA_GOT_IP) { … _sta_network_if->_setStatus(WL_CONNECTED);”
    • WiFi.status() values: 116 “ARDUINO_EVENT_WIFI_STA_GOT_IP6,”
    • WiFi.status() values: 117 “ARDUINO_EVENT_WIFI_STA_LOST_IP, … if (ev->event_id == ARDUINO_EVENT_WIFI_STA_LOST_IP) { _sta_network_if->_setStatus(WL_IDLE_STATUS);”
    • WiFi.status() values: 130 “ARDUINO_EVENT_WIFI_AP_START = 130,”
    • WiFi.status() values: 131 “ARDUINO_EVENT_WIFI_AP_STOP,”
    • WiFi.status() values: 132 “ARDUINO_EVENT_WIFI_AP_STACONNECTED,”
    • WiFi.status() values: 133 “ARDUINO_EVENT_WIFI_AP_STADISCONNECTED,”
    • WiFi.status() values: 134 “ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED,”
    • WiFi.status() values: 135 “ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED,”
    • WiFi.status() values: 136 “ARDUINO_EVENT_WIFI_AP_GOT_IP6,”
  5. arduino-esp32 3.3.12: docs/en/api/wifi.rst primary
    What it confirms (1)
    • WiFi.status() values: pitfall: Checking for WL_DISCONNECTED only “while (WiFi.status() != WL_CONNECTED) {”