-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Deep sleep and wake up using interrupt #1488
Comments
check esp api in https://github.com/esp8266/Arduino/blob/master/doc/libraries.md#esp-specific-apis
|
That doesn't really answer my question. I understand that if order to wake up from a deep sleep timer, GPIO16 needs to be wired to RST, but is it possible to wake up before that, using an external event on some GPIO line? |
@shayo With ESP.deepSleep(0), esp will be going to sleep forever. |
But, if GPIO16 triggers the 'wake from deep sleep' by firing a Reset, why can't a Low pulse on RST achieve the same result? Am I missing something? CHAE-PIL LIM [email protected] wrote:
|
|
@duncan-a External interrupt to rst is ok. But @shayo's question is "using an external event on some GPIO line". @Links2004 GPIO16 is in HIGH during deepSleep. I will use CH_DP when I use esp-01. GPIO16 to RST has one advantage when wake up---> wifi connect with static ip : 150 ~ 210msec |
As an option, you can have the ESP in deep sleep waiting for the RTC to trigger pin 16 for wakeup and use the reset button at the same time as manual reset. Reading the reset cause can tell you which event woke up the ESP :) then you can programmatically split and act different on both. |
@chaeplin ... thanks for the schematic and comments. I'm curious ... when you say "flip flop" does this mean it fires the reset on both opening AND closing the switch? |
@Humancell It's monostable flip flop. check here -> http://www.bowdenshobbycircuits.info/page9.htm |
Thank you ... I saw that you had posted about your solution here also: https://github.com/chaeplin/esp8266_and_arduino/tree/master/_48-door-alarm-deepsleep I"m working on a similar idea, and am curious ... with your door sensor, it appears that you have the deep sleep timer still working, but then you can be triggered by the reed switch opening ... or closing? And with the added circuitry (did you use the monostable flip-flop with your reed switch door sensor?) what is the final deep sleep current that you are seeing? Do any of these components add to the current draw during deep sleep? |
@Humancell Trigged when opening, cause the type of reed switch is normally opened(Q3 is added to invert signal). With C2, R4 and R9, a low signal is converted to reset pulse(Arduino reset method), so no more monostable flip-flop is needed. My µCurrent GOLD shows 0A while in deepsleep. |
Ok ... this makes sense. So the reed you are using is open, and then closes with the magnet nearby? If I need to do the reset on the reed switch both opening AND closing? I want to create an event when the door opens ... AND when it closes ... which obviously adds complexity. Is this where the flip-flop comes into play? Sorry for being slow on this ... |
@Humancell _48-door-alarm-deepsleep is doing what you want. I think attiny85 with pin change interrupt is more easier than R/C/TR circuit. https://github.com/chaeplin/esp8266_and_arduino/tree/master/_28-attiny85-nrf24-3pin-ir sch : attiny85 + esp01 |
Thank you for the wealth of links and information. This is exactly what I was looking for. Now I can dedicate an ATtiny85 to be a strictly "interrupt-woken" peripheral that will produce the low-pulse required to wake the ESP-12F. I can then also use the ESP-12F deep sleep timer to wake at regular intervals to produce "heartbeats" from the sensor when the door is open or closed for extended periods. With your suggestion on pins above, would I be passing the ESP deep sleep sugnal on pin 16 through the ATtiny85 also? Is that what your pin #3 is above? So teh ATtiny85 would wake on either the reed switch to ESP GPIO wake signal? |
@Humancell I use esp-01 for the circuit. Pin no 3 is used to present state of door to esp GPIO 1(Attiny85 control debounce). As you use ESP-12F, GPIO16 can be used to signal ATtiny85 as your suggestion. |
@chaeplin Hi, |
@Ukritkhonglao
|
Hi @chaeplin, I tried to implement your schemes (your edited version of monostable flip flop and the version in github) and in both cases didn't work. I have used 3904 instead of 4401,... could be by this? Other point is the capacitors... which is the polarity? thanks in advance for your help |
Isn't it easier and more power efficient to let the attiny control the vcc of the esp using a transistor? |
@chaeplin I am using D0 for something other than wake from deepsleep. D0 is set to be permanently low for this other function. Is there any way that I can still use D0 to wake from deepsleep i.e. by changing pinMode on the fly or setting D0 high or low just before it goes to sleep? I have tried several combinations but haven't been able to get D0 to be "multi purpose". |
Hello everybody, I'm doing a project where I have several buttons waiting to be pushed, once a button is pushed, I need to send the button number to a server using the ESP8266. I want to have everything sleeping while it is waiting for activity. I like the ATTiny85 option but don't know if I should use it for cutting power to the ESP8266 using a transistor, or if I should use it to wake it up. |
EDIT : OK GUYS I ANSWER : Hi guys, @chaeplin i've don't understand well some issues :
yes
yes but i've used gpio12
yes but i've used gpio13
No idea
Q3 and E is 2N4401 transistors ?
used _48-door-alarm-deepsleep Thanks a lot for your answer and sorry for my bad english and for my useless questions.... |
Guys, someone has implemented a working circuit to wake esp on reed open or close? with attiny or with R/C/TR circuit ? |
@oriolrius no sorry, i'm searching for an answer yet...... please update this post if you understand the right way... |
@dariocdj I decided to start trying with ATTiny85 based solution because it seems better IMHO. I don't like to implement logic using passive electronics. I prefer to have a master-slave configuration based on two MCU. I don't expect having anything done before a month because I have other priorities. Anyway when I finish that I'll publish my solution on my blog page (http://oriolrius.cat). Regards. |
Dear all, thanks a lot for your information. I'm really new on esp programming. I have a question: To record temperature data every a known interval of time, the dsleep() function is perfect (connecting GPIO16 to the RESET). But I also need to acquire data from a rain gauge (that have a reed switch). But I don't understant how I can do it. I want use reed input as external trigger as interrupt, so when the rain activate the reed, it can reset the ESP, without wait the RTC set time. Even more obscure for me, the possibility to use RTC memory to store data. Rain data could be stored in the RTC memory and send it when the ESP wake from deepsleep. Do you have same advice? |
@chaeplin you inspired me, thanks for sharing your info! I want to trigger a wake up by a PIR sensor, but only when in deep sleep. So i came up with the idea to use a relay and i think that my below scheme could work. It's still a draft though, i haven't got all the parts yet to setup a test, but maybe someone already has some ideas or suggestions regarding this? I'm no expert in electronics so i could be disapointed when i put this all together!? |
I had good success simply controlling power to the ESP8266. My sensor used a LiPo battery with a boost/buck regulator that had an enable pin. I used the regulator enable as a power switch to the ESP01. In my case, I used a normally open reed switch connected to an ATiny85 which was in sleep mode. When the switch closed, it grounded a pin on the ATiny generating an interrupt. The ATiny then enabled the regulator which in turn starts up the ESP01. The ATiny85 only uses a few uA in sleep mode, the Microchip regulator only uses 2 uA in standby... I'm using a 400ma LiPo and a supercap to off load in-rush current during startup. I configured the ESP01 to use N-mode wifi to limit power to 120ma during posts. I removed the power led from the ESP01 as well. At power-on, the ESP01 sets its GPIO_0 high to indicate it's busy. It then reads the door state on its RX pin and posts json updates. Once its all done it goes into deep-sleep which causes GPIO_0 low. The ATiny detects this and shuts off power and goes back into sleep. A watchdog on the ESP01 forces a deep-sleep after 15 seconds in case it cannot associate with the AP or the door is propped open. |
Interesting discussion, but closing per #3655 . |
If someone is looking for waking ESP8266 from deepsleep with multiple buttons interrupt, have a look on to the following link. |
by using a nodemcu board, the easiest way to wake it up during the deepSleep time, is by connecting the two contacts of the build in RST button through an intterupt or even mor simple RST pin to GRND. Maybe this will help |
The schematics shown above in this post seem to be problematic for the Wemos D1mini ESP8266, because the D1mini has an inbuilt 100nF-Capacitor to ground and 10k-Pullup-Resistor on its RST pin. (IE. any reset circuit needs to both discharge this 100nF capacitor, and be capable of sinking both this discharge current, the current from the 10k-pullup, and another several mA of current from the RST pin itself, and still generate a reset pulse which drops to approx 0.8V). The below circuit achieves this by using the STM1061 [2.2V trigger] (a voltage monitor with an open-drain output) to isolate the RST-pin/100nF-inbuilt-capacitor from the RC timing circuit. (I use this circuit to monitor the interrupt output from the TLS2561 and TLS2591 light sensors, which have an open-drain output with is active-low .) The STM1061 has an SOT23-3 package, but is relatively easy to mount on an SOT23-3 adapter for breadboard or stripboard use. The RED section in the above schematic (the Schottky-Diode) is optional (ie. only needed if you want ESP8266 to be woken from DeepSleep by internal timer). GPIO16 is OpenCircuit during normal ESP8266 operation, but goes HIGH during DeepSleep (biasing the 2N2222 which thereby enables the interrupt circuit). The Schottky-Diode is necessary so the STM1061 can still pull the RST-pin low even when GPIO16 is HIGH. The 360R resistor limits the peak discharge current to approx 9mA. The Reset-Pulses generated by this circuit with a D1mini are shown below. Note that even though the pulse from GPIO16 only drops to 1.0V, this still seems to work fine on all my D1mini units. |
Hi,
I saw the option to enter deep sleep for a predefined amount of time ( ESP.deepSleep)
Is it possible to wake up during that time with an external interrupt?
If so, how?
Thanks,
Shay
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: