ESP32 Wi-Fi MAC Address Changes Unexpectedly
Learn why the ESP32's MAC address may appear to change between reboots or Wi-Fi modes, and how to ensure consistent device identification.
Common Causes
- 🔄
MAC Derived from EFUSE But Varies by Interface
ESP32 has multiple MAC addresses for Wi-Fi STA, AP, and Bluetooth. If you’re reading from different modes, values may differ.
- ⚙️
Random MAC Address Generation
Some libraries or apps (e.g., ESP-Now, softAP) intentionally use randomized or locally-administered MACs for privacy or mesh operation.
- 📦
MAC Not Burned in EFUSE
In rare cases (e.g., custom modules or engineering samples), no factory MAC is programmed, leading to fallback generation.
- 🧯
Manual Override in Code
Your firmware or a library may be calling
esp_wifi_set_mac()
oresp_base_mac_addr_set()
to override the default MAC.
Symptoms
MAC Address Changes Between Reboots
Serial logs or router logs show different MAC addresses for the same device on each power cycle.
Device Shows Up as New on Every Boot
Home automation platforms, DHCP servers, or firewalls treat each rebooted ESP32 as a new device.
SoftAP MAC Differs from STA MAC
When switching between Access Point and Station mode, the visible MAC changes even without rebooting.
Static IP Binding Fails
DHCP reservations based on MAC don’t work reliably because the ESP32’s MAC appears to vary.
Solutions
Always Read MAC in Station Mode
Use WiFi.macAddress()
or esp_wifi_get_mac(WIFI_IF_STA)
to get the primary MAC consistently.
Avoid SoftAP or ESP-Now if Not Needed
These modes can use different or dynamic MACs. Stick to STA-only mode if MAC persistence matters.
Burn or Lock a MAC in EFUSE
For production modules, ensure a valid MAC is burned into EFUSE and retrieved at boot.
Set a Fixed MAC Manually (Optional)
Use esp_base_mac_addr_set()
early in your code to assign a fixed base MAC address for consistency.
More Details
ESP32 Wi-Fi MAC Address Changes Unexpectedly #
If your ESP32 device shows up with a new MAC address every time it reboots, switches Wi-Fi modes, or powers on, you’re not alone. This issue can cause problems in networks that rely on static DHCP leases, MAC-based firewall rules, or device identification.
Let’s explore why this happens, how to diagnose it, and how to make your ESP32’s MAC address consistent.
Understanding ESP32 MAC Address Behavior #
The ESP32 chip comes with multiple MAC addresses:
- Wi-Fi Station (STA)
- Wi-Fi Access Point (AP)
- Bluetooth
- (Optional) Ethernet or SDIO interfaces
Each is derived from a factory-burned base MAC in EFUSE, with Espressif assigning specific offsets per interface. The key point is: the MAC can appear to change depending on which interface or mode is active.
Common Situations Where MAC Changes #
🔄 Switching Between STA and AP Mode #
If your code uses both Station and Access Point modes (WIFI_AP_STA
), the reported MAC from WiFi.softAPmacAddress()
and WiFi.macAddress()
will differ:
Serial.println(WiFi.macAddress()); // STA MAC
Serial.println(WiFi.softAPmacAddress()); // AP MAC
These are legitimate and expected differences — but can confuse networks expecting a single MAC.
⚙️ Randomized MAC in Certain Features #
Modes like ESP-NOW, mesh, or softAP sometimes use locally-administered (randomized) MACs for privacy. This is especially true for prototyping or when no MAC is burned in EFUSE.
You may also see MACs like 02:xx:xx...
, where the 02
prefix indicates a locally administered address.
🧯 MAC Set in Code (Overridden) #
Libraries or user code may call:
esp_wifi_set_mac(WIFI_IF_STA, my_mac);
This explicitly sets a MAC and will override the default. If not done consistently, the MAC will vary between boots.
Diagnosing the Issue #
To determine whether your ESP32 has a consistent factory MAC:
uint8_t base_mac[6];
esp_efuse_mac_get_default(base_mac);
Serial.printf("Base MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
base_mac[0], base_mac[1], base_mac[2], base_mac[3], base_mac[4], base_mac[5]);
If this base MAC remains constant, your chip has a proper burned-in address.
If it’s all zeros or the call fails, you may be using a custom or engineering sample chip without a valid EFUSE MAC.
Best Practices for Stable MAC Address #
✅ Always Use STA MAC for Identification #
When using the ESP32 in client mode, get the MAC via:
WiFi.macAddress();
or
esp_wifi_get_mac(WIFI_IF_STA, mac_buffer);
This ensures consistent reporting across reboots.
✅ Avoid Switching Wi-Fi Modes Mid-Session #
Switching between STA and AP modes may change the visible MAC. If stability is needed, stick to WIFI_STA
only.
✅ Assign a Manual MAC (Advanced) #
If your module lacks an EFUSE MAC or you're building pre-production hardware, you can set your own MAC using:
esp_base_mac_addr_set(my_mac);
Do this early in setup()
, before Wi-Fi is initialized.
Ensure the MAC follows valid format rules — avoid multicast/reserved addresses and make it unique.
✅ Burn MAC Address in EFUSE (Manufacturing Only) #
For commercial products, Espressif recommends burning a permanent MAC into EFUSE. This requires access to the programming tools and should be done with caution.
Conclusion #
An ESP32 changing MAC addresses isn’t necessarily a bug — but it can be a headache if you’re relying on it for network tracking or static IP assignment.
To avoid surprises:
Use the STA MAC consistently
Don’t mix Wi-Fi modes unless needed
Avoid libraries that override MAC unless you understand why
Use
esp_base_mac_addr_set()
only if you know what you’re doing
With the right handling, you can ensure the ESP32 is reliably identified every time it connects.

Quick Navigation
Additional Resources
Still Stuck with an ESP32 Issue? Let's solve it together.
Our interactive troubleshooting wizard will guide you through common ESP32 problems and their solutions, step by step.