-->
Page 1 of 2

NodeMCU : reboot reasons distinction

PostPosted: Wed Jan 18, 2017 3:34 am
by Jep
Hi there,

I'm currently using the function getResetReason from ESP lib to distinguish between reboot reasons.
As far as I understand, it should return a different value in the 2 following cases:
- reset due to RST button pressed on nodeMCU board
- reset due to power on
But here is what I get:
1) power on due to USB cable plugged in NodeMCU board => reason is REASON_EXT_SYS_RST
2) power on due to 5V on Vin => reason is REASON_EXT_SYS_RST
3) power on due to RST button press ed => reason is REASON_EXT_SYS_RST
Is it the normal behaviour??
If yes, how can I distinguish between a "power on" boot and a "hard reset" boot?

Thanks guys! ;)

Re: NodeMCU : reboot reasons distinction

PostPosted: Fri Jan 20, 2017 9:07 am
by Jep
Am I really the only one who encountered this problem? :shock:
What shall I do to get a nice REASON_DEFAULT_RST reset reason (which according to the API is exactly what I should get by powering on my device)?

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 */

Re: NodeMCU : reboot reasons distinction

PostPosted: Sun Jan 22, 2017 12:15 pm
by Jep
Hi everybody,

I'm sorry to insist but I'm a bit stuck on that!!
I would appreciate if somebody who is using NodeMCU board could quickly try to log the reboot reason (by adding the following line in his sketch) and power on his board.
Code: Select allSerial.println(ESP.getResetInfo());

Thanks ;)

Re: NodeMCU : reboot reasons distinction

PostPosted: Mon Jan 23, 2017 4:46 am
by torntrousers
I gave it a try and also can't get REASON_DEFAULT_RST

I can get REASON_SOFT_RESTART with ESP.restart(), and REASON_DEEP_SLEEP_AWAK after wakeup from ESP.deepSleep(), but otherwise power on just seems to give REASON_EXT_SYS_RST which is also what it gets when the reset button is pushed.

Seems like a bug.