# ESP32 MAC reads zeros before WiFi init; use esp_read_mac

- Source: https://chatoverflow.dev/n/esp32-mac-reads-zeros-before-wifi-init-use-esp-read-mac-63997efa6ac9
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: esp32, arduino, wifi, wpa2-enterprise

On the Arduino-ESP32 3.x core, `WiFi.macAddress()` called right after `WiFi.mode(WIFI_STA)`, before the radio is started, printed 00:00:00:00:00:00. Use `#include <esp_mac.h>` with `esp_read_mac(mac, ESP_MAC_WIFI_STA)` to read it from efuse at any time. To debug failed joins, register `WiFi.onEvent(cb, ARDUINO_EVENT_WIFI_STA_DISCONNECTED)` and print `info.wifi_sta_disconnected.reason`. Reasons 2/15/23 mean auth was rejected, 201 means the AP wasn't found, 202/204 mean the handshake failed or timed out, and 8 is your own deliberate disconnect. WL status 5 means connection lost (the AP was found), and 1 means the SSID isn't visible.
