Description
Some ESP-specific APIs related to deep sleep, RTC and flash memories are available in the ESP object. These may be useful, we have already looked at the restart one
Code
[codesyntax lang=”cpp”]
/* ESP.restart() restarts the CPU. ESP.getResetReason() returns a String containing the last reset reason in human readable format. ESP.getFreeHeap() returns the free heap size. ESP.getHeapFragmentation() returns the fragmentation metric (0% is clean, more than ~50% is not harmless) ESP.getMaxFreeBlockSize() returns the maximum allocatable ram block regarding heap fragmentation ESP.getChipId() returns the ESP8266 chip ID as a 32-bit integer. ESP.getCoreVersion() returns a String containing the core version. ESP.getSdkVersion() returns the SDK version as a char. ESP.getCpuFreqMHz() returns the CPU frequency in MHz as an unsigned 8-bit integer. ESP.getSketchSize() returns the size of the current sketch as an unsigned 32-bit integer. ESP.getFreeSketchSpace() returns the free sketch space as an unsigned 32-bit integer. ESP.getSketchMD5() returns a lowercase String containing the MD5 of the current sketch. ESP.getFlashChipId() returns the flash chip ID as a 32-bit integer. ESP.getFlashChipSize() returns the flash chip size, in bytes, as seen by the SDK (may be less than actual size). ESP.getFlashChipRealSize() returns the real chip size, in bytes, based on the flash chip ID. ESP.getFlashChipSpeed(void) returns the flash chip frequency, in Hz. ESP.getCycleCount() returns the cpu instruction cycle count since start as an unsigned 32-bit. This is useful for accurate timing of very short actions like bit banging. ESP.getVcc() may be used to measure supply voltage. ESP needs to reconfigure the ADC at startup in order for this feature to be available. Add the following line to the top of your sketch to use */ void setup() { Serial.begin(115200); Serial.print("SDK version:"); Serial.println(ESP.getSdkVersion()); Serial.print("Core version:"); Serial.println(ESP.getCoreVersion()); Serial.print("CPU ferquency:"); Serial.println(ESP.getCpuFreqMHz()); Serial.print("Chip ID:"); Serial.println(ESP.getChipId()); Serial.print("Reset Reason:"); Serial.println(ESP.getResetReason()); Serial.print("Free heap:"); Serial.println(ESP.getFreeHeap()); } void loop() {}
[/codesyntax]
Output
Open the serial monitor
SDK version:2.2.1(cfd48f3)
Core version:2_4_2
CPU ferquency:80
Chip ID:1947093
Reset Reason:External System
Free heap:51880