My application requires me to set the mac address and then report that address when I connect to a websocket. I found this from read the docs. Right now I use esp_wifi_get_mac() to get the mac address of the wifi module, and that's what I'm reporting to the server. I now need to set that mac address myself. How do I store a custom mac address in BLK3 of EFUSE? Can I do it from the command line?
I found this article talking about burning it, but it says it can be dangerous. Is this the right approach? Should I just store it in NVS and use that or is it better to burn it to eprom?
Set MAC Address
Re: Set MAC Address
You may store MAC address in NVS and set it via a call to esp_base_mac_addr_set function. Please take a look at system/base_mac_addr example which shows different MAC address storage options.
-
- Posts: 34
- Joined: Wed Sep 21, 2016 6:40 am
Re: Set MAC Address
Hi,
I've tried to set the mac address using esp_base_mac_addr_set().
It seems to be success to write, but my wifi STA keep showing:
D (2809) event: SYSTEM_EVENT_STA_DISCONNECTED, ssid:EasyIO_RnD@wifi, ssid_len:15
, bssid:10:c3:7b:e1:c7:e8, reason:2
And the AP seems to be down as well, because I don't see the AP ssid in the wifi list.
When I remove the code that writing my custom mac address, it works normal again.
I've tried to set the mac address using esp_base_mac_addr_set().
It seems to be success to write, but my wifi STA keep showing:
D (2809) event: SYSTEM_EVENT_STA_DISCONNECTED, ssid:EasyIO_RnD@wifi, ssid_len:15
, bssid:10:c3:7b:e1:c7:e8, reason:2
And the AP seems to be down as well, because I don't see the AP ssid in the wifi list.
When I remove the code that writing my custom mac address, it works normal again.
Re: Set MAC Address
call esp_base_mac_addr_set to set the base MAC address before network interfaces are initialised.
-
- Posts: 34
- Joined: Wed Sep 21, 2016 6:40 am
Re: Set MAC Address
I'm setting the mac address in the app_main(), and it's the first code to run before I do any other initialization.
I started my code as below:
void app_main()
{
printf("set mac : 01:02:03:04:05:06\n");
uint8_t new_mac[8] = {0x01,0x02,0x03,0x04,0x05,0x06};
esp_base_mac_addr_set(new_mac);
...
}
I started my code as below:
void app_main()
{
printf("set mac : 01:02:03:04:05:06\n");
uint8_t new_mac[8] = {0x01,0x02,0x03,0x04,0x05,0x06};
esp_base_mac_addr_set(new_mac);
...
}
-
- Posts: 4
- Joined: Thu Mar 25, 2021 1:26 pm
- Contact:
Re: Set MAC Address
I know this is old but post it if maybe helpful for someone:
https://esp32tutorials.com/esp32-esp-id ... c-address/
https://esp32tutorials.com/esp32-esp-id ... c-address/
I love to build projects with ESP32 using Arduino and Esp-idf like Web servers https://microcontrollerslab.com/esp32-e ... eb-server/
-
- Posts: 6
- Joined: Tue Mar 22, 2022 4:39 am
Re: Set MAC Address
Find and Change the MAC Address of ESP32 by following this guide which works for me.
Who is online
Users browsing this forum: No registered users and 218 guests