- Tue Nov 29, 2016 2:36 pm
#58861
I need to differentiate between an automatic wake-up from deep sleep and restarting after a reset button is pushed on a WeMos D1 Mini (user event). The design is for a very simple, battery-powered button device. The following code always reports a reason code '5' whether waking from deep sleep or receiving a hardware reset signal. If the deep sleep function call is removed, '6' is always returned on a hardware reset. It appears the reset value is set once deep sleep is entered and a hardware reset does not change it. Any ideas? A hardware solution is fine as long as I can detect a user event (pressing a momentary switch).
Thanks.
Code: Select all#include <Arduino.h>
extern "C"
{
#include "user_interface.h"
}
void setup()
{
rst_info *rsti;
rsti = ESP.getResetInfoPtr();
Serial.begin(115200);
Serial.println();
Serial.println("Starting...");
Serial.println(String("ResetInfo.reason = ") + rsti->reason);
Serial.println("Sleeping...");
ESP.deepSleep(5000000, WAKE_RF_DISABLED);
}
void loop() {}