Page 1 of 1
ESP32 how to read the MAC Adress
Posted: Thu Oct 23, 2025 5:28 pm
by stefan.erni
Hi to All
in the supplemetary code I includet
#include "esp_mac.h"
In the main I creat a variable Byte MAC[6]
and a c-code:
Code: Select all
esp_efuse_mac_get_default(FCV_MAC);
But I get not the mac adress in MAC[0]...MAC[5]
Re: ESP32 how to read the MAC Adress
Posted: Thu Oct 23, 2025 9:02 pm
by mnfisher
The read should work AOK - I tested on a esp32-wrooom - and the result looks okay....
This just outputs the MAC to UART..
Martin
Re: ESP32 how to read the MAC Adress
Posted: Fri Oct 24, 2025 10:36 am
by stefan.erni
Hi Martin
Yes perfect!
It's working on two ESP32 wroom:
read from first ESP32 wroom:
MAC address A0:B7:65:60:55:40
read from second ESP32 wroom:
MAC address A0:B7:65:6C:74:EC
on my program was the handle from the string.
I suspect that some string functions do not work with string bigger than [20] on the ESP32.
I changed it a little and now it works with my program.
I will test the string functions I used before and post if I find one with problems.
Code: Select all
MAC_strg1 = NumberToHex$(MAC[0])
MAC_strg1 = RemoveFromString$(MAC_strg1,2,0)
mac_string = MAC_strg1 + ":"
MAC_strg2 = NumberToHex$(MAC[1])
MAC_strg2 = RemoveFromString$(MAC_strg2,2,0)
mac_string = mac_string + MAC_strg2 + ":"
MAC_strg3 = NumberToHex$(MAC[2])
MAC_strg3 = RemoveFromString$(MAC_strg3,2,0)
mac_string = mac_string + MAC_strg3 + ":"
MAC_strg4 = NumberToHex$(MAC[3])
MAC_strg4 = RemoveFromString$(MAC_strg4,2,0)
mac_string = mac_string + MAC_strg4 + ":"
MAC_strg5 = NumberToHex$(MAC[4])
MAC_strg5 = RemoveFromString$(MAC_strg5,2,0)
mac_string = mac_string + MAC_strg5 + ":"
MAC_strg6 = NumberToHex$(MAC[5])
MAC_strg6 = RemoveFromString$(MAC_strg6,2,0)
mac_string = mac_string + MAC_strg6 + ":"
Re: ESP32 how to read the MAC Adress
Posted: Fri Oct 24, 2025 2:16 pm
by mnfisher
Hi Stefan,
Default string size is 20 - and if somewhere there is a 'make a copy' box checked that might explain things? Passing strings by reference (not copying them) is usually the preferred option - and quicker too - but the default seems to be to pass by value.
Martin
Re: ESP32 how to read the MAC Adress
Posted: Fri Oct 24, 2025 3:07 pm
by stefan.erni
Hi Martin
Yes, I haven't made all the strings that long now.
And it's working nice.
But I have a small issue with the UART.
The red data is without a interrupt, the green data with an interrupt in the program .
This interrupt is doing nothing but the the data I send is thisway ok
I don't know why I have these problem but i just add it.
My program:
Test on terminal program:
The red data is without interrupt, the green with interrupt,

- 2025-10-24_15-49-41.PNG (38.01 KiB) Viewed 1366 times

- 2025-10-24_15-51-35.PNG (61.88 KiB) Viewed 1366 times
Re: ESP32 how to read the MAC Adress
Posted: Fri Oct 24, 2025 10:02 pm
by mnfisher
I can't replicate the issue (I think you've mentioned it before) - I tried PuTTY and idf.py - p COM6 -b 115200 monitor - and both work as expected with / without the interrupt.
Which terminal program are you using? There is definitely some repeated data that is 'correct' (A0:B7:) - but then everything goes a bit awry. Try a different terminal prog - see if you get the same issue?
Martin
Re: ESP32 how to read the MAC Adress
Posted: Mon Oct 27, 2025 10:29 am
by stefan.erni
Hi Martin
It look like a problem on my computers
That's not such a big problem, I always use an IRQ in my program. However, I shouldn't send any data before I activate it.
With IRQ:

- 2025-10-27_10-59-08.PNG (25.45 KiB) Viewed 1236 times
Without IRQ:

- 2025-10-27_11-01-11.PNG (32.95 KiB) Viewed 1236 times
I created a program for AppDevelopper FC11 to obtain the characters.
and improved the macro a little: