In a project powered by batteries, the ESP8266 should go to deep sleep for long time, having RF disabled. After some number of sleep cycles, it shall restart with RF enabled, synchronize time via NTP, and again go to sleep. Think this could work with a counter saved in RTC Memory or SPIFFS.
Additionally, s.o. should be able to wake up via push button (at any time), which should result in different behaviour (running as WiFi AP, allowing for configuration of new WiFi credentials).
The question is: Is it possible to find out what did wake the ESP (timer or pushbutton)?
Edit: Using external circuitry this might be possible. To avoid this, we switch to ESP32, which is an overkill for the project, but easy to find out the source of the wakeup (and with the possibility to use touch sensors). Additionally, ESP32 allows for easy use of "Preferences" in NVR and variables in RTC memory (when using the Arduino IDE), which will survive deep sleep (RTC) and even reset/power loss (NVR).
rtc_get_reset_reason()
andESP.getResetReason()
; will try that and report on success.rtc_get_reset_reason()
always responds with "wakeup from deep sleep" - that is correct, but does not help here.