Add ESP.getChipId() function to get ESP32's ChipID. (#322)
* Add ESP.getChipId() function to get ESP32's ChipID. * change getChipId() to getEfuseMac()
This commit is contained in:
parent
cc73f17add
commit
a38ffe58fe
@ -212,3 +212,11 @@ bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size)
|
||||
{
|
||||
return spi_flash_read(offset, (uint32_t*) data, size) == ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
uint64_t EspClass::getEfuseMac(void)
|
||||
{
|
||||
uint64_t _chipmacid;
|
||||
esp_efuse_read_mac((uint8_t*) (&_chipmacid));
|
||||
return _chipmacid;
|
||||
}
|
||||
|
@ -76,6 +76,8 @@ public:
|
||||
bool flashWrite(uint32_t offset, uint32_t *data, size_t size);
|
||||
bool flashRead(uint32_t offset, uint32_t *data, size_t size);
|
||||
|
||||
uint64_t getEfuseMac();
|
||||
|
||||
};
|
||||
|
||||
extern EspClass ESP;
|
||||
|
14
libraries/ESP32/examples/ChipID/GetChipID/GetChipID.ino
Normal file
14
libraries/ESP32/examples/ChipID/GetChipID/GetChipID.ino
Normal file
@ -0,0 +1,14 @@
|
||||
uint64_t chipid;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
chipid=ESP.getEfuseMac();//The chip ID is essentially its MAC address(length: 6 bytes).
|
||||
Serial.printf("ESP32 Chip ID = %04X",(uint16_t)(chipid>>32));//print High 2 bytes
|
||||
Serial.printf("%08X\n",(uint32_t)chipid);//print Low 4bytes.
|
||||
|
||||
delay(3000);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user