Esp8266 Deep sleep, wakeup reason

Hello. I have some problem with reason of esp8266 wake up. I need to know when esp wakes up by timer and when by reset button. So I try to do this but reason always 5. Here it is descrpiton:

REANSON_DEFAULT_RST = 0, // normal startup by power on
REANSON_WDT_RST = 1, // hardware watch dog reset
REANSON_EXCEPTION_RST = 2, // exception reset, GPIO status won’t change
REANSON_SOFT_WDT_RST = 3, // software watch dog reset, GPIO status won’t change
REANSON_SOFT_RESTART = 4, // software restart ,system_restart , GPIO status won’t change
REANSON_DEEP_SLEEP_AWAKE = 5, // wake up from deep-sleep

Here is my code:

extern "C" {
  #include "user_interface.h"

void setup() {
  // put your setup code here, to run once:

struct rst_info *rstInfo = system_get_rst_info();
uint32_t reason = rstInfo->reason;
if ( reason != REASON_RESET ){
} else {

void loop() {
  // put your main code here, to run repeatedly:


Can someone help me?

the deep sleep timer uses RTC pin io 16 to pulse the reset pin. so you can't know in software which one was it

Are u sure? It is possible, I have already found how to do this, but there are some nuances.

I didn't test deep sleep yet, I only read about it. It starts with setup() after wake up? I would expect it continues with sketch where it left.

No, esp reloads when wake up from deep sleep. And it starts from setup(). If u need to continue from place were it left u should use light sleep

Hi, This may help.

Tom... :)