Using esp_efuse_mac_get_default() in IDE 2.X to get ESP8266/ESP32 MAC address

Hello everyone,

I am struggling to obtain ESP8266 and ESP32 mac address.

There are multiple ways to obtain it:

  • WiFi.macAddress()
  • esp_read_mac() //for which you need to specify an interface
  • ...

esp_efuse_mac_get_default() seems to get the factory assigned mac address of the chip.

I can't make esp_... functions work in Arduino IDE. I can't include esp_system.h neither.

How to make those work in Arduino IDE?

Thank you for your help,

Have a good day!

Why don't you want to use WiFi.macAddress()?

It gives a different result if I call it very early in setup() vs later on in loop()

Please post the code that behaves that way. I'd like to try it on an ESP32

I don't have the code that produced 2 different mac adresses anymore. I tried to rewrite it, but now it gives me only one mac address...

Pilot Error :flight_arrival:

Anyway, I found the API you asked about. Compiles but untested:

#include "esp_mac.h"

void setup() {
  uint8_t mac[8];
  esp_efuse_mac_get_default(mac);

}

void loop() {
}

What do I need to install to be able to use esp_mac.h ?

might be obvious, but i quite don't understand what download from esp-idf-2.0/components/esp32/include/esp_system.h at master · pycom/esp-idf-2.0 · GitHub

You don't need to install anything. It's included in the ESP32 Arduino Core.

Ok, I can't try it right now on ESP32.

Here is the ref for ESP8266 ( esp_efuse_mac_get_default()) . But still, I cannot use any of those functions:

esp_system.h: No such file or directory

esp_mac.h: No such file or directory

I don't have experience with ESP8266.

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