Skip to content

DS_CAP_SYS_RESET

Denis Stepanov edited this page May 14, 2021 · 4 revisions

DS_CAP_SYS_RESET — Reset Information

Description

This capability adds support for reading the last reset reason. The following method is provided:

uint32 System::getResetReason();                 // Return reset reason

This is just a thin interface to the built-in function ESP.getResetInfoPtr(). The return codes are defined in ESP8266 Arduino headers:

enum rst_reason {
    REASON_DEFAULT_RST      = 0,    /* normal startup by power on */
    REASON_WDT_RST          = 1,    /* hardware watch dog reset */
    REASON_EXCEPTION_RST    = 2,    /* exception reset, GPIO status won’t change */
    REASON_SOFT_WDT_RST     = 3,    /* software watch dog reset, GPIO status won’t change */
    REASON_SOFT_RESTART     = 4,    /* software restart ,system_restart , GPIO status won’t change */
    REASON_DEEP_SLEEP_AWAKE = 5,    /* wake up from deep-sleep */
    REASON_EXT_SYS_RST      = 6     /* external system reset */
};

Requires

Cooperates With

None.

Conflicts With

None.

Usage

MySystem.h:

#define DS_CAP_SYS_RESET    // Enable software reset interface

#include "System.h"         // System global definitions

sketch.ino:

#include "MySystem.h"

using namespace ds;

void setup() {
     bool deep_sleep = System::getResetReason() == REASON_DEEP_SLEEP_AWAKE;
}

void loop() {
}

Mandatory Calls

System::begin() Not required
System::update() Not required

Examples

Bugs

  • Returning reset reason as a string, as well as allowing triggering a reset would be obvious additions (issue #7).

Availability

Version 1.0 or later.

See Also

None.