ESP8266 Developer Zone The Official ESP8266 Forum 2020-02-28T11:53:12+08:00 https://bbs.espressif.com:443/feed.php?f=6&t=2383 2020-02-28T11:53:12+08:00 2020-02-28T11:53:12+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=73877#p73877 <![CDATA[Re: We really need a way to differenciate RESET and Wake Up from Deep Sleep]]> https://github.com/espressif/ESP8266_RTOS_SDK

Statistics: Posted by Her Mary — Fri Feb 28, 2020 11:53 am


]]>
2020-02-09T23:54:37+08:00 2020-02-09T23:54:37+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=73296#p73296 <![CDATA[Re: We really need a way to differenciate RESET and Wake Up from Deep Sleep]]>

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.

Statistics: Posted by Guest — Sun Feb 09, 2020 11:54 pm


]]>
2016-12-11T22:21:35+08:00 2016-12-11T22:21:35+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=10872#p10872 <![CDATA[Re: We really need a way to differenciate RESET and Wake Up from Deep Sleep]]>
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.

Thanks!

Gary

Statistics: Posted by garyeb — Sun Dec 11, 2016 10:21 pm


]]>
2016-12-11T13:00:35+08:00 2016-12-11T13:00:35+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=10862#p10862 <![CDATA[Re: We really need a way to differenciate RESET and Wake Up from Deep Sleep]]> 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!

Statistics: Posted by Guest — Sun Dec 11, 2016 1:00 pm


]]>
2016-12-01T02:39:39+08:00 2016-12-01T02:39:39+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=10742#p10742 <![CDATA[Re: We really need a way to differenciate RESET and Wake Up from Deep Sleep]]>
I did more research this morning and found an excellent example of a project (http://www.esp8266.com/viewtopic.php?f=13&t=8315) that confirmed my thought that there is no easy way to differentiate between a deep sleep wakeup and an external reset event. In his code, the author acknowledges this and checks for an external event by reading another GPIO pin being driven by additional circuitry from a water sensor. Since my button is just a momentary switch, asserting a signal long enough for the ESP8266 to wake up and start my app (75ms?) requires additional circuitry. It would be much nicer if the SDK had a value that I haven't found that would help but it appears a hardware solution is in order. I need to brush up on my basic electronics skills to build this circuit since I'm a software guy.

Gary

Statistics: Posted by garyeb — Thu Dec 01, 2016 2:39 am


]]>
2016-11-30T23:01:56+08:00 2016-11-30T23:01:56+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=10741#p10741 <![CDATA[Re: We really need a way to differenciate RESET and Wake Up from Deep Sleep]]>
The reset cause always returns '5' (deep-sleep wakeup) even if the reset button is pressed on my WeMos D1 Mini. In the latter case, I want it to return '6' (hardware reset) so I know it was a user event and can take the required action. If I comment out the 'deepSleep' line in my code below and never go to sleep, pressing the reset button returns a '6' as expected. The problem appears to be that once 'deepSleep' is entered, a '5' is always returned. This seems to be a common problem for folks trying to develop battery-powered ESP8266 devices using deep-sleep to conserve power. When I enter my program either from deep-sleep wakeup or a hardware reset, I need to determine if it was an external event. I tried checking the value of the RTC and system time counters but they are the same whether hardware reset or deep-sleep wakeup.

All this makes sense if the ESP8266 deep-sleep wakeup code is simply toggling the reset pin which is the same thing as pressing the reset button does. However, it leaves the problem of detecting user events from system events unsolved. Any ideas here would be a great help.

Gary

Code:

#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() {}

Statistics: Posted by garyeb — Wed Nov 30, 2016 11:01 pm


]]>
2016-11-30T22:19:55+08:00 2016-11-30T22:19:55+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=10735#p10735 <![CDATA[Re: We really need a way to differenciate RESET and Wake Up from Deep Sleep]]> Statistics: Posted by Guest — Wed Nov 30, 2016 10:19 pm


]]>
2016-11-30T07:27:48+08:00 2016-11-30T07:27:48+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=10733#p10733 <![CDATA[Re: [SOLVED} We really need a way to differenciate RESET and Wake Up from Deep Sleep]]>
Regards,
Gary

Statistics: Posted by garyeb — Wed Nov 30, 2016 7:27 am


]]>
2017-05-20T11:32:46+08:00 2016-09-20T02:24:13+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=9884#p9884 <![CDATA[Re: [SOLVED} We really need a way to differenciate RESET and Wake Up from Deep Sleep]]>
You could replace the nRESET with the PD pin for wakeup, and then the nRESET pin will stand alone for free usage.
When wakeup from deep sleep, the GPIO16 will pullow and then release the PD/CH_EN (pulled up by an extern resistance) to perform a reset, just like a powe on reboot other than a reset via reset pin. Hope in this way , you could free the nRESET pin and differentiate the two type of reset.

We have a module of esp8266 doing such. You may find them at http://www.ebay.com/itm/282162857143 or http://www.ebay.com/itm/282162896341, which uses above way to wakeup from deep sleep and verified.

For more detail you could follow this discussion further or drop me a message.

Hope it will be helpful

Yiming

Statistics: Posted by Guest — Tue Sep 20, 2016 2:24 am


]]>
2016-07-22T17:34:36+08:00 2016-07-22T17:34:36+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=8064#p8064 <![CDATA[Re: [SOLVED} We really need a way to differenciate RESET and Wake Up from Deep Sleep]]> Yes, we use system_get_rst_info()
The problem is still open because this function did not return all the reason of a reset.
Gilles

Statistics: Posted by gilmic — Fri Jul 22, 2016 5:34 pm


]]>
2016-07-04T12:44:26+08:00 2016-07-04T12:44:26+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=7703#p7703 <![CDATA[Re: We really need a way to differenciate RESET and Wake Up from Deep Sleep]]>
Yes I have been around for a couple of months now. I am mainly working on application notes and support firmware and will be visiting the forum sometimes. Feel free to leave a mail if you wish to!
But if the answers to the questions will help the community, it is nice to discuss here in forums. :)

Statistics: Posted by Guest — Mon Jul 04, 2016 12:44 pm


]]>
2016-07-03T23:51:27+08:00 2016-07-03T23:51:27+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=7689#p7689 <![CDATA[Re: We really need a way to differenciate RESET and Wake Up from Deep Sleep]]>
pratik wrote:
Hello Gilles,

Did you try the function system_get_rst_info() yet? It returns a structure with all the relevant parameters and also the reset causes.
If you have not tried this yet, I would suggest you to look this function up in the documentation of the SDK you are using. You will also find the information on the corresponding structure that it returns.

Note that this function and all structures are defined in SDK/include/espressif/esp_system.h and they are very self explanatory. :)
Please update the thread if this worked for you, it will help others if this is a common issue...


hi Pratik,
see you joined last days, welcome!
just in time, see your email adress, too.
are you working for espressif or at espressif?
can we use it to send special question or better here in forum?
best wishes
rudi ;-)

Statistics: Posted by rudi — Sun Jul 03, 2016 11:51 pm


]]>
2016-07-03T15:29:31+08:00 2016-07-03T15:29:31+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=7679#p7679 <![CDATA[Re: We really need a way to differenciate RESET and Wake Up from Deep Sleep]]>
Did you try the function system_get_rst_info() yet? It returns a structure with all the relevant parameters and also the reset causes.
If you have not tried this yet, I would suggest you to look this function up in the documentation of the SDK you are using. You will also find the information on the corresponding structure that it returns.

Note that this function and all structures are defined in SDK/include/espressif/esp_system.h and they are very self explanatory. :)
Please update the thread if this worked for you, it will help others if this is a common issue...

Statistics: Posted by Guest — Sun Jul 03, 2016 3:29 pm


]]>
2016-07-03T15:12:18+08:00 2016-07-03T15:12:18+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2383&p=7675#p7675 <![CDATA[We really need a way to differenciate RESET and Wake Up from Deep Sleep]]> I used GPIO16 to reactivate the chip from DeepSleep. Works well!
But I do not have a method to differentiate a DeepSleep awakening compared to a regular reset from a switch. (Both are connected together)
Is there (somewhere in the chip or in the code) a way to know if the chip is back from rebooting? Can be a registry value, or a timer value, or .....
I use Uint32 time_in_us to program the duration of the DeepSleep.
Is the value has decreased over DeepSleep countdown? If so, can you read this value back when the chip reset?
if the value is equal to zero, then we can say that the chip is back with a DeepSleep.
if the value is zero, then we can say that the chip is coming back from RESET (I know that it's not 100% accurancy but it can give us a good feedback)

This problem is recurring in the forum. HELP
Regards
Gilles

Statistics: Posted by gilmic — Sun Jul 03, 2016 3:12 pm


]]>