Esp Api
Esp Api
ESP.deepSleep(microseconds, mode) will put the chip into deep sleep. mode is one of
WAKE_RF_DEFAULT, WAKE_RFCAL, WAKE_NO_RFCAL, WAKE_RF_DISABLED. (GPIO16 needs to be
tied to RST to wake from deepSleep.) The chip can sleep for at most
ESP.deepSleepMax() microseconds. If you implement deep sleep with WAKE_RF_DISABLED
and require WiFi functionality on wake up, you will need to implement an additional
WAKE_RF_DEFAULT before WiFi functionality is available.
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.random() should be used to generate true random numbers on the ESP. Returns an
unsigned 32-bit integer with the random number. An alternate version is also
available that fills an array of arbitrary length. Note that it seems as though the
WiFi needs to be enabled to generate entropy for the random numbers, otherwise
pseudo-random numbers are used.
ESP.checkFlashCRC() calculates the CRC of the program memory (not including any
filesystems) and compares it to the one embedded in the image. If this call returns
false then the flash has been corrupted. At that point, you may want to consider
trying to send a MQTT message, to start a re-download of the application, blink a
LED in an SOS pattern, etc. However, since the flash is known corrupted at this
point there is no guarantee the app will be able to perform any of these
operations, so in safety critical deployments an immediate shutdown to a fail-safe
mode may be indicated.
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 getVcc:
ADC_MODE(ADC_VCC);
TOUT pin has to be disconnected in this mode.
Note that by default ADC is configured to read from TOUT pin using analogRead(A0),
and ESP.getVCC() is not available.