Page 1 of 1

ESP32 MAC address does not match AP MAC address

Posted: Wed Dec 14, 2022 4:32 am
by autodog
Greetings,

We are using the ESP32-WROVER-B with esp-idf v3.3.6 and have noticed an issue we can't explain:

When we read the MAC address from the ESP32 WiFi interface in STA mode using the esp_wifi_get_mac() function, the value returned does not match the MAC address reported by the AP point it is connected to.

When the ESP32 STA connects to a 3rd party AP, the AP reports the ESP32 MAC address to be 30:AE:A4:CB:66:98
Multiple different AP vendors return the same value. Using esptoo.py read_mac also returns this same value.

When calling the esp_wifi_get_mac() function in firmware, it returns a STA MAC address of A8:D1:FB:3F:F8:D0

Example Code:

Code: Untitled.c Select all

// Get MAC address and display as 6-byte hex value
uint8_t mac[6];
char macAddr[13];
esp_wifi_get_mac(WIFI_IF_STA, mac);
snprintf(macAddr, sizeof(macAddr),
"%02X%02X%02X%02X%02X%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
printf("MAC address: %s", macAddr);
Any ideas if this is expected behavior or are we doing something funny here?

Thanks!
-AD

Re: ESP32 MAC address does not match AP MAC address

Posted: Wed Dec 14, 2022 8:25 pm
by ESP_igrr
Are you seeing this behavior with the wifi station example from IDF, or only with your application?

Since IDF v3.3.6 is EoL, I would also suggest trying the same with one of the newer IDF releases. If you still get the same issue, please report it at https://github.com/espressif/esp-idf/issues and we will investigate it.

Re: ESP32 MAC address does not match AP MAC address

Posted: Sun Jan 19, 2025 11:27 am
by moxhamj2@gmail.com
#include <WiFi.h> // for wifi

void setup() {
// Initialize Serial for debugging
Serial.begin(115200);
while (!Serial) {
}
Serial.println("Start program.");
printMacAddress(); // this does not display the correct mac address, returns MAC Address: FC:3F:3:0:0:0
WiFi.mode(WIFI_STA); // test if this fixes the issue, ChatGPT said it would but it does not...
printMacAddress(); // this does not display the correct mac address, returns MAC Address: 0:0:0:0:0:0
WiFi.scanNetworks(); // Trigger scan to fully initialize Wi-Fi (hours of debugging to find this...)
printMacAddress(); // this prints the correct mac address, MAC Address: 20:43:A8:63:FD:C8
// chatgpt suggested posting this solution on the internet
}

void loop() {
}

void printMacAddress() {
byte mac[6];
WiFi.macAddress(mac);
Serial.print("MAC Address: ");
for (int i = 0; i < 6; i++) {
if (i > 0) {
Serial.print(":");
}
Serial.print(mac, HEX); // Also print the byte in hexadecimal to the serial port
}
Serial.println("");
}

Code: Untitled.c Select all