#include <Arduino.h>
extern "C" {
#include <user_interface.h>
}
#define LED_PIN LED_BUILTIN
void setup() {
delay(1000);
pinMode(LED_PIN, OUTPUT);
Serial.begin(74880);
Serial.setTimeout(2000);
digitalWrite(LED_PIN, false);
// Wait for serial to initialize.
while(!Serial) { }
Serial.print("Chip ID: ");
Serial.println(ESP.getChipId());
rst_info *rinfo = ESP.getResetInfoPtr();
Serial.print(String("\nResetInfo.reason = ") + (*rinfo).reason + ": " + ESP.getResetReason() + "\n");
Serial.println(".");
Serial.println("I'm awake.");
delay(1000);
Serial.println("Going into deep sleep for 3 seconds");
ESP.deepSleep(3e6);
delay(5000);
}
void loop() {
//empty
}
When I run this code on a D1 mini board (GPIO16/D0 NOT connected to RST) I get the following output
Chip ID: 11442368
ResetInfo.reason = 6: External System
.
I'm awake.
Going into deep sleep for 3 seconds
ets Jan 8 2013,rst cause:5, boot mode:(3,0)
ets_main.c
After this, I have to press the reset button twice before the board resets and will get the following output.
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 3584, room 16
tail 0
chksum 0xb0
csum 0xb0
v2843a5ac
~ld
Chip ID: 11442368
ResetInfo.reason = 5: Deep-Sleep Wake
.
I'm awake.
Going into deep sleep for 3 seconds
Now I connected GPIO16/D0 to RST and run the sketch again.
Chip ID: 11442368
ResetInfo.reason = 6: External System
.
I'm awake.
Going into deep sleep for 3 seconds
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 3584, room 16
tail 0
chksum 0xb0
csum 0xb0
v2843a5ac
~ld
Chip ID: 11442368
ResetInfo.reason = 5: Deep-Sleep Wake
.
I'm awake.
Going into deep sleep for 3 seconds
ets Jan 8 2013,rst cause:5, boot mode:(3,6)
ets_main.c
I still had to press the reset button once to make the board to wake up again.
Any suggestion what I'm doing wrong?
BTW: The board used, is a fresh new D1 Mini NodeMcu with ESP8266MOD 12F board just connected via USB to Computer. On top, I use Arduino IDE if this might be helpful.