Set MAC Address

embedded_systems
Posts: 10
Joined: Tue May 09, 2017 6:42 pm

Set MAC Address

Postby embedded_systems » Fri Jun 16, 2017 9:35 pm

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?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Set MAC Address

Postby ESP_igrr » Sat Jun 17, 2017 3:01 am

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.

teckhaokoh
Posts: 34
Joined: Wed Sep 21, 2016 6:40 am

Re: Set MAC Address

Postby teckhaokoh » Tue Oct 10, 2017 9:00 am

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.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Set MAC Address

Postby WiFive » Tue Oct 10, 2017 9:58 am

call esp_base_mac_addr_set to set the base MAC address before network interfaces are initialised.

teckhaokoh
Posts: 34
Joined: Wed Sep 21, 2016 6:40 am

Re: Set MAC Address

Postby teckhaokoh » Wed Oct 11, 2017 2:15 am

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);
...
}

Bilalmalikuet
Posts: 4
Joined: Thu Mar 25, 2021 1:26 pm
Contact:

Re: Set MAC Address

Postby Bilalmalikuet » Wed Feb 08, 2023 11:58 am

I know this is old but post it if maybe helpful for someone:
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/

Squirrelbd
Posts: 6
Joined: Tue Mar 22, 2022 4:39 am

Re: Set MAC Address

Postby Squirrelbd » Sat Aug 10, 2024 3:50 pm

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 369 guests