Skip to content

Commit 4a4f2c6

Browse files
Rewind the method of reading chipid to the previous one, making it easier to query the license
1 parent 877f9f5 commit 4a4f2c6

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed
Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
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;
1+
/* The true ESP32 chip ID is essentially its MAC address.*/
2+
3+
uint64_t chipId = 0;
144

155
void setup() {
16-
Serial.begin(115200);
6+
Serial.begin(115200);
177
}
188

199
void loop() {
20-
for(int i=0; i<17; i=i+8) {
21-
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
22-
}
23-
24-
Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
25-
Serial.printf("This chip has %d cores\n", ESP.getChipCores());
26-
Serial.print("Chip ID: "); Serial.println(chipId);
27-
28-
delay(3000);
29-
10+
chipId=ESP.getEfuseMac();
11+
Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
12+
Serial.printf("This chip has %d cores\n", ESP.getChipCores());
13+
Serial.printf("ESP32ChipID=%04X",(uint16_t)(chipId>>32));//print High 2bytes
14+
Serial.printf("%08X\r\n",(uint32_t)chipId);//print Low 4bytes.
15+
delay(3000);
3016
}

0 commit comments

Comments
 (0)