Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By martinayotte
#41961 Unfortunately, this is not true ! deepSleep awake is 5 ! (and I'm using it in my Sketch-Buffet)
Which version of ArduinoESP and SDK are you using ?

From tools/sdk/include/user_interface.h
Code: Select allenum 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 */
};

From core/esp82766/ESP.cpp
Code: Select allString EspClass::getResetReason(void) {
    char buff[32];
    if (resetInfo.reason == REASON_DEFAULT_RST) { // normal startup by power on
      strcpy_P(buff, PSTR("Power on"));
    } else if (resetInfo.reason == REASON_WDT_RST) { // hardware watch dog reset
      strcpy_P(buff, PSTR("Hardware Watchdog"));
    } else if (resetInfo.reason == REASON_EXCEPTION_RST) { // exception reset, GPIO status won’t change
      strcpy_P(buff, PSTR("Exception"));
    } else if (resetInfo.reason == REASON_SOFT_WDT_RST) { // software watch dog reset, GPIO status won’t change
      strcpy_P(buff, PSTR("Software Watchdog"));
    } else if (resetInfo.reason == REASON_SOFT_RESTART) { // software restart ,system_restart , GPIO status won’t change
      strcpy_P(buff, PSTR("Software/System restart"));
    } else if (resetInfo.reason == REASON_DEEP_SLEEP_AWAKE) { // wake up from deep-sleep
      strcpy_P(buff, PSTR("Deep-Sleep Wake"));
    } else if (resetInfo.reason == REASON_EXT_SYS_RST) { // external system reset
      strcpy_P(buff, PSTR("External System"));
    } else {
      strcpy_P(buff, PSTR("Unknown"));
    }
    return String(buff);
}
User avatar
By erniberni
#42013
Unfortunately, this is not true ! deepSleep awake is 5 ! - See more at: viewtopic.php?f=32&t=8411&start=4#sthash.4hwJAvXx.dpuf

Yes, I know. That was what I expected. But I got "6" everytime.
I'm using the Arduino IDE 1.6.5 with ESP Ver 2.0.0
I checked the Esp.cpp and found and in my version the getResetReason(void) was missing.
I copied the Esp.cpp and Esp.h from https://github.com/esp8266/Arduino/tree/5e19757d54582c57342bfb0685248d791b97d372/cores/esp8266 which seems to be a newer version, but no change
Code: Select allStart...
ResetInfo.reason = 6     <-------- this is after hw reset
going to sleep now...
....
Start...
ResetInfo.reason = 6      <------- this after deep sleep.
going to sleep now...

I used this code
Code: Select allextern "C" {
#include "user_interface.h"
}

void setup() {
  rst_info *rsti;
  Serial.begin(115200);
  rsti = ESP.getResetInfoPtr();
  Serial.println("\r\nStart...");
  Serial.println(String("ResetInfo.reason = ") + rsti->reason);
}

// the loop function runs over and over again forever
void loop() {
  Serial.println("going to sleep now...");
  system_deep_sleep_set_option(0);
  system_deep_sleep(10000000);            // deep sleep for 10 seconds
  delay(1000);
}