-->
Page 1 of 3

SOLVED: Differentiate between deep.sleep and power on reset

PostPosted: Fri Feb 26, 2016 9:44 am
by erniberni
Hello,
is it possible to differentiate in the code between a power on reset and a reset from deep sleep?
Code: Select allextern "C" {
#include "user_interface.h"
  uint16 readvdd33(void);
  extern struct rst_info resetInfo;

}

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println("Start...");
  Serial.print("Reset reason ");
  Serial.println(ESP.getResetInfo());
}

void loop() {
  Serial.println("going to sleep now...");
  Serial.println(readvdd33());
  system_deep_sleep_set_option(0);
  system_deep_sleep(15000000);            // deep sleep for 15 seconds
  delay(1000);
}


always gives
Code: Select allStart...
Reset reason Fatal exception:0 flag:6 (EXT_SYS_RST) epc1:0x00000000 epc2:0x00000000 epc3:0x00000000 excvaddr:0x00000000 depc:0x00000000
going to sleep now...
3365

Re: Differentiate between deep.sleep and power on reset

PostPosted: Fri Feb 26, 2016 9:58 am
by schufti
see here

Re: Differentiate between deep.sleep and power on reset

PostPosted: Fri Feb 26, 2016 10:05 am
by martinayotte
Or simply :
Code: Select allvoid setup() {
  rst_info *rsti;
  Serial.begin(115200);
  rsti = ESP.getResetInfoPtr();
  Serial.println(String("ResetInfo.reason = ") + rsti->reason);
}

Re: Differentiate between deep.sleep and power on reset

PostPosted: Fri Feb 26, 2016 6:29 pm
by erniberni
It doesn't matter.
The reason is "6" just at power on reset as at sleep awake.
No differentiation.