File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
libraries/ESP32/examples/ChipID/GetChipID Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change 1- uint64_t chipid;
1+ /* The true ESP32 chip ID is essentially its MAC address.
2+ This sketch provides an alternate chip ID that matches
3+ the output of the ESP.getChipId() function on ESP8266
4+ (i.e. a 32-bit integer matching the last 3 bytes of
5+ the MAC address. This is less unique than the
6+ MAC address chip ID, but is helpful when you need
7+ an identifier that can be no more than a 32-bit integer
8+ (like for switch...case).
9+
10+ created 2020-06-07 by cweinhofer
11+ with help from Cicicok */
12+
13+ uint32_t chipId = 0 ;
214
315void setup () {
416 Serial.begin (115200 );
517}
618
719void loop () {
8- chipid=ESP. getEfuseMac (); // The chip ID is essentially its MAC address(length: 6 bytes).
9- Serial. printf ( " ESP32 Chip ID = %04X " ,( uint16_t )(chipid>> 32 )); // print High 2 bytes
10- Serial. printf ( " %08X \n " ,( uint32_t )chipid); // print Low 4bytes.
20+ for ( int i= 0 ; i< 17 ; i=i+ 8 ) {
21+ chipId |= ((ESP. getEfuseMac () >> ( 40 - i)) & 0xff ) << i;
22+ }
1123
1224 Serial.printf (" ESP32 Chip model = %s Rev %d\n " , ESP.getChipModel (), ESP.getChipRevision ());
1325 Serial.printf (" This chip has %d cores\n " , ESP.getChipCores ());
14-
26+ Serial.print (" Chip ID: " ); Serial.println (chipId);
27+
1528 delay (3000 );
1629
1730}
You can’t perform that action at this time.
0 commit comments