Page 1 of 1
How to get ESP-32 Chip ID using SDK?
Posted: Wed Apr 19, 2017 6:57 am
by iwemos
I want to get ESP-32's Chip ID.
How to get ESP-32 Chip ID using SDK?
Re: How to get ESP-32 Chip ID using SDK?
Posted: Wed Apr 19, 2017 8:30 am
by ESP_igrr
The chip ID is essentially its MAC address. You can use esp_efuse_read_mac function declared in esp_system.h
Re: How to get ESP-32 Chip ID using SDK?
Posted: Fri Apr 21, 2017 2:14 am
by iwemos
I use this code:
Code: Select all
uint8_t chipid[6];
esp_efuse_read_mac(chipid);
Serial.printf("%X\n",chipid);
But the chipid always is 3FFCC82C with different ESP32 IC, why?
Re: How to get ESP-32 Chip ID using SDK?
Posted: Fri Apr 21, 2017 2:27 am
by ESP_Angus
The MAC address is an array of bytes not a single integer, so when you printf in this way you're printing the address of the array in RAM.
Try something like
Code: Select all
Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x\n",chipid[0], chipid[1], chipid[2], chipid[3], chipid[4], chipid[5]);
Re: How to get ESP-32 Chip ID using SDK?
Posted: Fri Apr 21, 2017 3:28 am
by iwemos
Thank you.
Re: How to get ESP-32 Chip ID using SDK?
Posted: Thu Apr 26, 2018 9:59 am
by meneldor
Hello,
As esp_efuse_read_mac is deprecated but esp_efuse_mac_get_default returns 0 what to use to get the unique id for the chip?
EDIT: sorry, esp_efuse_mac_get_default doesn't return 0,my fault. What's the difference between this function and esptool's chip_id which has some additional chars?
Re: How to get ESP-32 Chip ID using SDK?
Posted: Thu Apr 26, 2018 11:53 pm
by ESP_Angus
The esptool.py chip_id function is printing the MAC address CRC byte in the highest byte of the output, and losing the lowest byte of the MAC entirely. This is a bug, probably the chip_id function should do nothing on ESP32 (or alias to read_mac).
Re: How to get ESP-32 Chip ID using SDK?
Posted: Sun Apr 29, 2018 11:40 am
by meneldor
Thanks, Angus. I will use only the MAC as unique id.
Re: How to get ESP-32 Chip ID using SDK?
Posted: Sun Apr 29, 2018 11:25 pm
by ESP_Angus
Update to this, in v2.4.0 (currently in development on the master branch), "esptool.py chip_id" will alias to read_mac for ESP32.
(chip_id on ESP8266 is still the 3 least significant bytes of the MAC, so it's still possible to have an equivalent 24-bit "ID" on ESP32 if you need one. But better to use the full MAC if you can, as the lower 24-bits may collide.)
Re: How to get ESP-32 Chip ID using SDK?
Posted: Fri Dec 01, 2023 9:20 am
by RiverS_16
hello,
I had a query regarding MAC Address ,
1.is MAC Address configurable? as i read in the documentation esp_base_mac_addr_set () can be used to set custom base address.
2.which API to use to get UID of the chip.