This is now an SDK issue!
It is actually basic digital design stuff. Let me try to explain...
ESP8266 wakes from deep sleep by resetting itself, where it is the same recent as a user reset using a button. But when deep sleep is enabled, the chip RESETS ITSELF.
So in the hardware, once deep sleep is enabled - the chip expects the next reset event to be a wake-up reset. And if the user pulls the line low at this stage when deep sleep is enabled - the chip will think the GPIO caused this, not the user!
What you can do is you can use an external latch (a simple MOS and capacitor based one, will cost less than a button itself!) which stays high for say 5 seconds after the USER presses the reset button. The ESP8266 can then read this and determine if a button was pressed recently!
This is additional circuit design that is necessary to detect a button press. The ESP8266 has no internal hardware to distinguish (if deep sleep is enabled) whether a physical button press caused reset or a system wakeup caused a reset because they both do the same thing - alter reset pin!
After posting my question, a friend suggested precisely the external latch solution you offered as an alternative for this application. It will also have a much lower power consumption since the ESP is powered of until the button is pushed. As soon as my MOSFET order arrives, I will test the solution.
The ESP8266 has no internal hardware to distinguish (if deep sleep is enabled) whether a physical button press caused reset or a system wakeup caused a reset because they both do the same thing
That is not true.
The ESP8266 does have the internal hardware necessary to distinguish, and that is the RTC.
The RTC is running while in deepsleep. You put it into deepsleep for a given amount of time. When it wakes up, it could know, if it wanted to, how much time has elapsed since it went to sleep. All it needs to do is read the RTC before it resets it.
There is actually a low-level function whose name I can't remember, which gives you the elapsed time (can't remember if in micro or milliseconds) of the RTC since reset. Unfortunately, the SDK resets it first thing at startup (I saw it in the source code somewhere), so it always gives you the time since boot (which makes it exactly equivalent to another function that is supposed to be a different one - also cannot remember the name). So we, users, have no way to tell because the designers of the SDK decided to not allow us, not because the board doesn't have the internal hardware to allow it, which it does have.
This is a design flaw in the espressif SDK. And a huge one. Please fix it.
Who is online
Users browsing this forum: No registered users and 2 guests
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
We also have a RTOS version and a MESH version too!
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!