Skip to content

ESP.deepSleep not able to wake up device #5892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
6 tasks done
mikegron opened this issue Mar 18, 2019 · 60 comments
Closed
6 tasks done

ESP.deepSleep not able to wake up device #5892

mikegron opened this issue Mar 18, 2019 · 60 comments

Comments

@mikegron
Copy link

mikegron commented Mar 18, 2019

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP-12E (NodeMCU v3)
  • Core Version: stable release (2.5.0)
  • Development Env: Arduino IDE
  • Operating System: Windows

Settings in IDE

  • Module: NodeMCU 1.0 (ESP-12E)
  • Flash Mode: ?
  • Flash Size: 4MB
  • lwip Variant: v2 Lower Memory
  • Reset Method: ?
  • Flash Frequency: 40Mhz
  • CPU Frequency: 80Mhz
  • Upload Using: SERIAL (usb)
  • Upload Speed: 115200

Problem Description

I'm trying to make deep sleep work as intended. I made a very simple sketch that just sleeps for 30 seconds. I've attached a wire from D0 to the RST pin so that the deep sleep timer could reset the board. I am connected/powered via USB.

After the specified time, a LOW signal is correctly sent to the D0 pin as the device write the boot information but nothing else is happening afterward, I have to unplug the power or manually reset the board with the reset button. I tested with 115200 or 74880 bauds if that makes a difference, to see the boot info which is in 74880.

My board is setup exactly like this: ESP8266 Deep Sleep with Arduino IDE

Sketch

void setup() {
  Serial.begin(74880);
  Serial.setTimeout(2000);
  while (!Serial) { }
  Serial.println("Started.");
  delay(5000);
  Serial.println("Going to sleep.");
  ESP.deepSleep(30e6);
}

void loop() { }

Debug Messages

image

@5chufti
Copy link
Contributor

5chufti commented Mar 18, 2019

try putting a delay(10) after the ESP.deepSleep()

@liebman
Copy link
Contributor

liebman commented Mar 18, 2019

Looking at the log messages this is working correctly. Deep sleep does not continue from the sleep, it starts with setup again. It’s basically a reset. If you have data you want to persist then you need to use RTC memory or flash. EDIT:Ok I failed to read the annotations on the log. Forget I commented. :-/

@mikegron
Copy link
Author

Hmm if I remove the cable from D0 to RST I still have the "ets Jan..." message so I guess this is printed on wake and not when receiving a reset signal. I tried resetting "manually" by hooking RST to ground and that works, I still have the same boot message but the board starts properly. So maybe D0 simply does not send the wake (LOW) signal??

@fsommer1968
Copy link

I use the following pin configuration for DO:
pinMode(D0, WAKEUP_PULLUP);
In addition instead of a direct connection from DO to RST I use a Schottky Diode (preferred) or a 680Ohm resistor.

@fsommer1968
Copy link

I recommend closing this issue

@mikegron
Copy link
Author

Setting the pin to WAKEUP_PULLUP did not change the behaviour unfortunately. Could you tell me why would adding a resistor between D0 and RST fix that?
Also as a test, setting D0 to INPUT made the board go in a reset loop (so it looks like it can work).

@fsommer1968
Copy link

fsommer1968 commented Mar 25, 2019

Wake up pin is Nodemcu pin D0 which is 8266 pin GPIO16. You are referring to GPIO_0 , this is not the Wakeup pin! Check your wiring and pin assignment: https://randomnerdtutorials.com/esp8266-deep-sleep-with-arduino-ide/ Without a resistor or diode the wiring from D0 to RST should be removed during flashing the module. In my opinion Nodemcu V3 modules have a high quiescent current. I use e.g. Wemos D1 mini which has a low dropout voltage regulator for battery applications.

@mikegron
Copy link
Author

My bad for referring to GPIO_0, indeed I meant D0 (GPIO_16), I used the same exact link you posted (I also linked it in the problem description)
Pictures just to be sure:
DSC_1240
DSC_1243

@mikegron
Copy link
Author

It looks like the board is waking up in flash mode somehow, same as if I hold the flash button at the same time as the reset button. Although I did try setting D3 (GPIO 0) and D4 (GPIO 2) as INPUT_PULLUP, or attaching a cable from 3.3V to D3 (to make sure it's high). I have no ideas now..

@devyte
Copy link
Collaborator

devyte commented Mar 26, 2019

Are you physically resetting the board after flashing over serial?

@mikegron
Copy link
Author

Yeah, I also tried using a power supply, same result :/

@fsommer1968
Copy link

fsommer1968 commented Mar 27, 2019

I tried with a Nodemcu 0.9 (ESP12) module and the connection from DO to RST, and you sketch works:
17:00:32.789 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
17:00:32.789 ->
17:00:32.789 -> load 0x4010f000, len 1384, room 16
17:00:32.789 -> tail 8
17:00:32.789 -> chksum 0x2d
17:00:32.789 -> csum 0x2d
17:00:32.789 -> v951aeffa
17:00:32.789 -> ~ld
17:00:32.857 -> Started.
17:00:37.853 -> Going to sleep.
17:01:06.604 ->
17:01:06.604 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
17:01:06.604 ->
17:01:06.604 -> load 0x4010f000, len 1384, room 16
17:01:06.639 -> tail 8
17:01:06.639 -> chksum 0x2d
17:01:06.639 -> csum 0x2d
17:01:06.639 -> v951aeffa
17:01:06.639 -> ~ld
17:01:06.706 -> Started.
17:01:11.687 -> Going to sleep.

But when i forget the connection from D0 to RST this happens:
17:01:45.529 -> Going to sleep.
17:02:14.316 ->
17:02:14.316 -> ets Jan 8 2013,rst cause:5, boot mode:(3,6)
17:02:14.316 ->
17:02:14.316 -> ets_main.c

So from my point of view there might be something with your board or the board description in Arduino for the ESP12E module is wrong.

@mikegron
Copy link
Author

mikegron commented Mar 27, 2019

Thank you for testing! There is probably something wrong with the board you're right..
I checked the pins (with nothing else connected) with a multimeter and I find the measures odd:
The RST pin always stays at 3.3V.
When running, the D0 pin is at 0V. When sleeping, the D0 pin is at 3.3V. When waking up, the D0 pin is set to 0V continuously. However, to wake the board with the RST pin, I need to set it to 3.3V -> 0V -> 3.3V. For instance, connecting RST to ground does not reset the board, but removing the connection will reset it. But, disconnecting the D0 pin while it's at 0V does not have the same effect (like if 0V was not gound).
Do you see anything wrong with that?

@fsommer1968
Copy link

fsommer1968 commented Mar 28, 2019

Hm measuring dynamic signals with a multimeter where typically a logic analyser, a scope, or at least a logic tester is required is not more than a bad guess.
I think you should look around for other using Nodemcu V3 with Deep Sleep. I have described what I was able to test (in addition Wemos D1 mini works well with DS, too). And so far I cannot see that there is something wrong with this Arduino release for 8266.
As explained earlier: maybe the board description needs an update for this specific board. I would look for the schematics of this board to check, set the board in the Arduino GUI to to generic 8266 and set each option manually.
If you are not able to do this, go and take a 8266 board that is proven to work.

@mikegron
Copy link
Author

Ok so I tested the exact same sketch with a Wemos D1 R1 and it worked perfectly... I'm gonna close this issue and try to figure out what is wrong with the NodeMcu v3 !
Thanks a lot for your help.

@5chufti
Copy link
Contributor

5chufti commented Mar 31, 2019

To me that is an old version where the reset circuit does prevent the pulse form gpio16 to be recognized correctly. The new nodemcus have a different layout with one free (not assembled) resistor location to bridge when using deep sleep

@petrilloa
Copy link

I have a similar issue with a bunch of ESP12F from Espressif.
We build more than 100 sensors with ESP12F from AI, and doesn´t have any problem to wake up from deep sleep, GPIO16 direct connection to RESET.
With the new batch, the factory send us ESP8266MOD (phisically looks the same as the old ones, and justo like an ESP12F), but trying a simple sketch to wake up, the devices hangs until we press reset.

We have a 3.3v from MCP1700, 1000uF and 0.1nF capacitor from VCC to GND. (input 3xAA Batteries)
GPIO15 pulldown with 10k
GPIO0 pullup with 10k
GPIO2 pullup with 10k

To connect the reset we try...

1-Connect Reset to GPIO16 with wire
2-Connect Reset to GPIO with 330 ohms resistor
3-Connect Reset to GPIO with Diode (normal and schottky).

Debbug:

AI ESP8266 12-F (WORKING)

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v951aeffa
~ld
Chip ID: 276350

ResetInfo.reason = 5: Deep-Sleep Wake
.
I'm awake.
Going into deep sleep for 3 seconds

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v951aeffa
~ld
Chip ID: 276350

ResetInfo.reason = 5: Deep-Sleep Wake
.
I'm awake.
Going into deep sleep for 3 seconds

Espressif ESP8266 12-F (NOT WORKING)

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v951aeffa
~ld
Chip ID: 6198051

ResetInfo.reason = 5: Deep-Sleep Wake
.
I'm awake.
Going into deep sleep for 3 seconds

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

Please any help!?

@fsommer1968
Copy link

Hi petrilloa,
that is sad! Try to get schematics for both boards and compare them. Beside the GPIO16 and reset I would check the SPI flash connection.

@petrilloa
Copy link

There is a custom PCB, with a bare ESP12F. Si there is not diff schematics.

@Skipper-is
Copy link

Same board, Lolin NodeMCU v3. Exactly the same issue. I've got 3 of the same board, and they all exhibit the same behaviour described here.

@ArsineMan
Copy link

Same Problem. I purchased 10 of these guys. So far 3 are functional and 4 are not. I literally just plug them into the same breadboard location and load the exact same sketch. I stuck an oscilloscope on the D0 pin and noted the working boards do drop all the way to 0 whereas the broken ones do not.

@devimc
Copy link

devimc commented Jul 28, 2019

I updated my platformio framework and its packages (framework-arduinoespressif8266) and now I'm facing this issues 😢 , but if I revert everything to 2018-12-03, ESP.deepSleep works again 😄 , this means that something changed in the library or toolchain 🤔

@ArsineMan
Copy link

@devimc, that's interesting. I assumed it was my hardware so I bought from a different vendor and its started working.

@ptutt1
Copy link

ptutt1 commented Aug 25, 2019

I have a Lolin Nodemcu v3 and have same issue as described. Will enter deep sleep but will not come out. Interestingly, it is drawing around 72ma when running, then around 250ua when in deep sleep. After it attempts to wake up, I can see the on board led flash, it uses around 36ma. My guess is as other has mentioned it wakes into flash state. I also find that I have to press the reset button twice to wake it from deep sleep. I can also need to ground RST twice to exit deepsleep.

I also captured D0 output on oscilloscope and can see it seems to be correctly grounding to trigger the reset, but as mentioned, if reset needs to happen twice, then it's not going to work.

IMG_20190819_135027

Easiest fix seems to be getting new hardware that supports deepsleep properly.

@5chufti
Copy link
Contributor

5chufti commented Aug 30, 2019

have a look at #6007

@magc2806
Copy link

Hello ! I am having this exact problem with my Amica NodeMCU Esp8266. Has anyone found a solution for this or I must change my board? How do I know my board's version ? And which ones dont have this problem? thank you in advance

@ptutt1
Copy link

ptutt1 commented Mar 30, 2020

@magc2806 in my case I purchased a WeMos ESP8266 D1 Mini and there was no problem. My problem was with the Lolin Nodemcu v3 but I can't comment on other boards.

@worksasdesigned
Copy link

Same issue with the "xxxxMOD" Version. 12F is running perfectly smooth.
Just took me 4 hours to find this post and another 5 min to exchange the WeMos with an other batch.

@Craig1516
Copy link

I am revisiting two, or three, batches of ESP12's from 2019'ish. Some work after deepsleep, some do not. Double resets do work, but... the first reset ends badly with high power consumption (33 mA). Sadly, my QC is sloppy and I have several protypes on several boards from several purchased batches. And with 16 surface mounts these chips do not come off the PCB nicely. Testing, testing, testing... so important.

@ole1986
Copy link

ole1986 commented Sep 2, 2021

I also noted the same.
While using deep sleep in a short period (1 min) it seem to work AS expected.

When I use deep sleep for 1h with a powerbank as power supply it never wake up.

@5chufti
Copy link
Contributor

5chufti commented Sep 2, 2021

did you check that it is not the powerbank that shuts down and hinders the esp to wake up?

@ole1986
Copy link

ole1986 commented Sep 3, 2021

I have now double checked while connecting to debugging computer for more than an hour.
Unfortunately it keeps staying in deep sleep.

Trying to reduce it to 30 minutes now!

Below is the code example and output

// where settingData.interval is 60 minutes
Serial.println("Going into deep sleep for " + String(settingData.interval) + " minutes");
ESP.deepSleep(settingData.interval * 60 * 1000000);

Output

Going into deep sleep for 60 minutes

@Craig1516
Copy link

Seems like 30 minutes should work for you. I think the max sleep time is a bit over 35 minutes. The technicals (2^31) are discussed here.

Maybe your powerbank as mentioned by Schufti? A multimeter should show you if that is the problem.

@Craig1516
Copy link

Here is another fun story. He found that by swapping to a different ESP it solved his sleep problem.

@ole1986
Copy link

ole1986 commented Sep 9, 2021

As a side note. It's wasnt the powerbank but the esp when configuring it to approximately 1 hour.

When setting up to 30 min deep sleep and wake up works so far with the powerbank

But shouldn't it be a 64bit range with newest API?

@FBMinis
Copy link

FBMinis commented Nov 23, 2022

I have just landed here from Google and it was the powerbank that would allow the ESP-07S to deepsleep. After testing with a phone charger and 2xAA it worked.

@amadeuspzs
Copy link
Contributor

amadeuspzs commented Feb 11, 2024

Can confirm this behaviour with some implementations of ESP8266MOD on a Wemos D1 Mini clone.

Trying on a NodeMCU (ESP-12F) worked, so it does look like, while frustrating and somewhat incomprehensible, different hardware implementations affect the correct functioning of deepSleep mode.

For anyone else facing this issue, try a different hardware implementation.

Edit: it appears this is a known issue for D1 Mini's:

Some ESP8266s have an onboard USB chip (e.g. D1 mini) on the chips’ control line that is connected to the RST pin. This enables the flasher to reboot the ESP when required. This may interfere with deep sleep on some devices and prevent the ESP from waking when it’s powered through its USB connector. Powering the ESP from a separate 3.3V source connected to the 3.3V pin and GND will solve this issue. In these cases, using a USB to TTL adapter will allow you to log ESP activity.

From https://esphome.io/components/deep_sleep.html

@jtauscher
Copy link

jtauscher commented Jul 19, 2024

Issue can be fixed by adding 10k resistor to second pin (GPIO7) next to the 3.3V pin.

20240719_121049

@TomasBelo
Copy link

@jtauscher Thanks! This fixed the issue.

@5chufti
Copy link
Contributor

5chufti commented Jul 19, 2024

do yourself a favour and use the technically correct method to connect rst and gpio16:
a schottky diode, cathode (ring) to gpio16 (despite what the datasheet says);
this will greatly improve your flashing (and wakeup) experience.

@lionel-gattegno
Copy link

Hi @5chufti can you please elaborate? how will it improve flashing and wakeup experience? (I'm brand new to electronics and super interested to learn...)

@5chufti
Copy link
Contributor

5chufti commented Aug 1, 2024

Hi @5chufti can you please elaborate? how will it improve flashing and wakeup experience? (I'm brand new to electronics and super interested to learn...)

a) with hard link, external reset circuitry will 99.9% fail to reset ESP module (has to work against "strong HIGH" from gpio16 , so automatic flashing from IDE will work at all.
b) with resistor, external reset circuitry will still have to work against "strong HIGH" from gpio16 through resistor.
Experience shows that experimental values for resistor may work with one batch of modules but fail on other.

with diode, both cases are solved electronically correct and compatible with 99.9% modules encountered.

@jtauscher
Copy link

I don't think a diode will solve this issue. It's not a problem of RST or GPIO16.

@5chufti
Copy link
Contributor

5chufti commented Aug 2, 2024

there are modules with "suboptimal" internal circuitry on rst (RC network) which react erratically to the reset signal from gpio16 as allready discovered and discussed on gh in history. They suffer due to misshaped (thus shortened) pules on rst. Even this might improve with any action to keep pulse (edge) in shape!
p.s.: I never hinted that it solves the problem with improper load / incompatible flash ic (?) on sd_d0 - but that it is general good practise to design circuits according to minimal electronic standards keeping singal levels in mind.

@jtauscher
Copy link

For my experience the pulse is too short or not "low enough". So maybe you are right but still I don't understand how a diode would help. With the additional R at GPIO7 it simply helps to get a decent LOW at RST. It worked for me on 2 modules so far. So it seems to be the simplest and yet reliable solution.

@5chufti
Copy link
Contributor

5chufti commented Aug 2, 2024

I really can't see how a pull-up on gpio7 can improve the timing related to gpio16/rst.
I think that there is a more complex underlying problem that keeps the esp from properly starting up after the wake-up reset.
One would have to decap the module and replace the flash for a known good one to get a more clear picture. Or experiment with differend flash modes or ...

p.s.: and it most likely is no new problem, there have been lots of reports on "zombie mode" in former days of esp hype.

@simonadamprog
Copy link

Hi @mikegron,
Could you figure out what was the issue with the NodeMCU esp8266 esp12e?
I'm trying to figure out this deep sleep for weeks now and have read these comments multiple times. 😅
I've tried everything mentioned under this issue, no luck.
I have two of these beauties, Both are Amica NodeMCU v3s. And both are behaving the same.
D4 and D0 LED lights blink one when it wants to reset (just with wire between D0 and RST), but nothing happens after. When I place a shottky or 10kOhm between D0 and RST, the D0 led stays on (low), and not restarting. Tried a pullup and a pulldown on SDD0. Setting the D0 to WAKEUP_PULLDOWN, WAKEUP_PULLUP. All of this combination.
I just think now to don't go to deep sleep with them, just use them on normal mode, two eats max 500Wh per a month, I could live with that.
But still, it would be nice to figure out... And eat just 5-10Wh per month.

@arwooldridge
Copy link

@5chufti I tried the Schottky diode (GPIO16 to RST), it did not cure my wake from sleep issue, but it does allow programming without having to remove the link.

@5chufti
Copy link
Contributor

5chufti commented Sep 29, 2024

Hi,
as I learned from others who had similar problems and disected their modules, there are some modules with incompatible circuitry (rc combination) at the reset pin that needs longer reset pulse than the gpio16 provides. This could only be "fixed" by an additional monoflop that costs more money and battery power than a new known good ESP8266 ...

p.s.: if it ain't reset properly with a direkt link, the diode won't fix it. The diode just is a more compatible (and technically correct) replacement for an "average resistor" that makes reset and reprogramming flakey.

@arwooldridge
Copy link

arwooldridge commented Sep 29, 2024 via email

@5chufti
Copy link
Contributor

5chufti commented Sep 29, 2024

depending on your needs, you could try sth like esp8266 D1 mini pro where all components are discrete (no module) and superfluous parts on reset could be removed.
Or maybe spend (little) more money and go for some reputable vendors on ebay or amazon.

@arwooldridge
Copy link

arwooldridge commented Sep 30, 2024 via email

@simonadamprog
Copy link

simonadamprog commented Oct 1, 2024

With logic analyzer I could gather this information (with schottky diode - ring facing to D0):
image
Looks D0 works fine, but RST is kinda messing around a little bit until it goes back to high again.
Maybe can someone upload the same for a flawless sleeper-waker?

@5chufti
Copy link
Contributor

5chufti commented Oct 3, 2024

unfortunately a logic analyser is not a proper tool for this kind of problem as it will not show the ramp on the rst signal.
But apart from that, one would need to see the actual signal after the internal circuitry right on the pin of the chip.
As I allready wrote: if wake up does not work with a hard link D0-RST, there is nothing that can be done "from outside".
Get any of the boards that don't use modules so one can modify/remove interfering components or buy where you can be certain to get a board with quality module.

p.s.: all this is not related to the problem with improper load / incompatible flash ic (?) on sd_d0 fixed with resistor as shown several entries above...

@Bly16
Copy link

Bly16 commented Jan 1, 2025

Another weird thing I noticed, manual RST (button, but pin as well) works every second attempt, no idea why, So if i use my code, it fails at the first try and doesn't work further, but if I push a button it actually resets only for one more iteration etc.
Am I the only one with this kind of issue?

@nbbraun
Copy link

nbbraun commented Mar 28, 2025

I've got five of these NodeMCU 8266. One of them works with the ESP.deepSleep() as it should. The other four won't, they do what they should do as long as I do not try deepSleep. Can't figure out why.

@GainEternal
Copy link

A note for those still looking for an answer to this.
tl;dr the solution @jtauscher provided above also worked for me: connecting GPIO7 to the 3.3V rail fixed the "reset twice" issue. Read below for more details.

Background:
I recently bought several ESP-12F units from Ali Express. I already had a NodeMCU v1.0 which I used for prototyping. I switched to a ESP-12F unit after getting the code stable enough. I actually used the NodeMCU to program the ESP-12F unit, testing some simple code to make sure it worked properly. It did, until I tried the deepsleep function. The ESP-12F would not come out of deepsleep by itself. I triple checked the wiring and pull-ups and pull-downs; they were all correct.

Troubleshooting:

  • I found that by manually connecting the RST pin to GND twice (i.e., LOW, HIGH, LOW, HIGH), the board would reset.
  • When the GPIO16 pin was connected, and after it finished the timed deep sleep, the "LOW" pulse provided by GPIO16 counted as 1 of the 2 reset pulses required to actually reset the ESP-12F.

After breaking out the oscilloscope, I made the following observations:

  • GPIO16 does go quite low (few hundred mV) at the end of timed deep sleep when disconnected from the RST pins, but doesn't go nearly as low (1.5V) when directly connected to RST. As a note, though 1.5V is quite high, the unit still appears to recognize it as a LOW-to-HIGH transition.
  • Connecting GPIO16 to RST through a diode does change the waveforms, but does not significantly lower the voltage RST actually sees.

I ran the same program (running deepSleep for 3 seconds over and over) on the NodeMCU and used it's GPIO16 to drive both the NodeMCU RST pin and the ESP-12F RST pin simultaneously.

  • During this, I observed that I no longer needed to manually short the RST pin on the ESP-12F to GND, but the chip still took 2 of the deepsleep cycles on the NodeMCU to do 1 proper reset.

Solution (but not rationale):
After some searching online, I came across this issue and read till I saw @jtauscher's comment. So I connected GPIO7 to the 3.3V rail through a 10k resistor. Voila! The ESP-12F began to work correctly. The signal coming from GPIO16 is still just as bad, but the chip properly resets. I have not dug into the root cause of this, nor why this is a solution. I am wondering how @jtauscher came across it.

I hope this helps anyone else coming across this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests