Hello,
Is there a unique serial number somewhere in an ESP32 chip? I want to provide a way to distinguish multiple ESP32-based devices on a field bus and would have used a serial number for that. Other microcontrollers provide such a number that is different in each device without any customisation work. It's set in the factory. I couldn't find any information about this for ESP32. Does it exist? And how can I retrieve it? Any format is fine (binary or text).
Or will I have to implement my own serial numbers in code and with EEPROM or similar?
Unique hardware serial number
Re: Unique hardware serial number
Each chip is pre-programmed with a unique MAC address, which you can read by calling esp_efuse_mac_get_default function:
https://docs.espressif.com/projects/esp ... tP7uint8_t
https://docs.espressif.com/projects/esp ... tP7uint8_t
Re: Unique hardware serial number
Thank you, that should work.
But will the function write 6 or 8 bytes to the provided memory? That's entirely unspecified and a likely source of crashes. AFAIK, MAC addresses are always 6 bytes. Not sure why the function would write 8 bytes.
But will the function write 6 or 8 bytes to the provided memory? That's entirely unspecified and a likely source of crashes. AFAIK, MAC addresses are always 6 bytes. Not sure why the function would write 8 bytes.
Re: Unique hardware serial number
Hi,
I'm having the same challenge as you.
I decided to not count on the mac address and write my own serial for each device.
But during my research I did found that my esp32 (s2) has a field in efuse by the name optional unique id.
OPTIONAL_UNIQUE_ID (BLOCK2) Optional unique 128-bit ID
This might be helpful but I can't find any documentation about it so I can't know for sure that it's unique.
If you'd like to go the same route as me wait few minutes till my post gets approved and you'l be able to write your own serial number to efuse.
I'm having the same challenge as you.
I decided to not count on the mac address and write my own serial for each device.
But during my research I did found that my esp32 (s2) has a field in efuse by the name optional unique id.
OPTIONAL_UNIQUE_ID (BLOCK2) Optional unique 128-bit ID
This might be helpful but I can't find any documentation about it so I can't know for sure that it's unique.
If you'd like to go the same route as me wait few minutes till my post gets approved and you'l be able to write your own serial number to efuse.
Re: Unique hardware serial number
According to the ESP-IDF documentation:
Alternatively, at run time, if you're using the latest ESP-IDF master ersion, you could call esp_mac_addr_len_get providing the MAC type as a parameter (e.g., ESP_MAC_WIFI_STA).
So, you could test the macro CONFIG_IEEE802154_ENABLED (for IEEE 802.15.4) to determine if you are fetching a 6-byte versus an 8-byte MAC when calling `esp_efuse_mac_get_default`.If CONFIG_IEEE802154_ENABLED is set then for these types: ESP_MAC_IEEE802154, ESP_MAC_BASE, ESP_MAC_EFUSE_FACTORY and ESP_MAC_EFUSE_CUSTOM the MAC size is 8 bytes. If CONFIG_IEEE802154_ENABLED is not set then for all types it returns 6 bytes.
Alternatively, at run time, if you're using the latest ESP-IDF master ersion, you could call esp_mac_addr_len_get providing the MAC type as a parameter (e.g., ESP_MAC_WIFI_STA).
Who is online
Users browsing this forum: No registered users and 87 guests