With the increasing popular of IOT technologies, there are also available development boards from many manufacturers. One of popular board is ESP32 which comes with integrated wifi and bluetooth (BLE) capability. We can use Arduino framework to program the board either using Arduino IDE or other IDE like Atom Platformio.
Sometimes we need to get hardware info from each board we develop, either to show it to user or just show them on log messages. On Esp32, to get the hardware info, use the following code:
esp_chip_info_t chip_info; esp_chip_info(&chip_info); Serial.println("Hardware info"); Serial.printf("%d cores Wifi %s%s\n", chip_info.cores, (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); Serial.printf("Silicon revision: %d\n", chip_info.revision); Serial.printf("%dMB %s flash\n", spi_flash_get_chip_size()/(1024*1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embeded" : "external"); //get chip id chipId = String((uint32_t)ESP.getEfuseMac(), HEX); chipId.toUpperCase(); Serial.printf("Chip id: %s\n", chipId.c_str());
Don’t forget to include the ESP.h header file. Happy coding!by