5
\$\begingroup\$

I am trying to generate a reset pulse in order to wake up an ESP8266 device.

The ESP8266 supports a "deep sleep" function, in which it consumes very little power. However, the only way to wake it up is to reset it (by pulling the reset pin low - the device will restart as soon as the pin goes high again).

So I am trying to use an external event (let's say a normally-open switch) to wake up the device. However, there is a snag - the device should wake up immediately after the switch is closed, even though the switch might remain closed for many seconds or minutes afterwards. So I need a circuit that will generate a reset pulse (low, then high after several milliseconds) whenever the switch is closed.

I thought to myself - "no problem, that should be easy!" (yes, I am that much of a newbie! :) ). And I built this circuit - which performs beautifully in the simulator...

first attempt

But of course real life does not fit the simulation... I am using a Wemos D1 Mini development board - which adds a whole new level of complexity, including a pull-up resistor on RST and a capacitor between RST and ground. So, of course, this simple circuit no longer works :(

My question is - how can I change this circuit so that it does the job? Or, if that is not possible, what type of circuit could I use instead?

I did consider a 555 as well, but a) I am not sure about the power consumption, and b) that is a 5V device, so it might be more difficult to run on batteries.

Some additional challenges:

  1. The additional circuitry should use as little power as possible (the whole idea of using deep sleep is getting the device to run for a long time on batteries)
  2. Would it be possible to use multiple switches to wake up the device? (I could then run the switches to different GPIO pins, and get the status of the pins on startup to find out exactly which event generated the wake signal)

Thank you!

\$\endgroup\$
3
  • \$\begingroup\$ Is there a reason why you used 1M resistors for your circuit beside the really long time constant of that RC circuit? It might begin to interact with your microcontroller. Also, I would consider putting the reset switch in parallel with the capacitor in between the ground and the RST port. That way, you will properly expose your ground to your RST port and not through the capacitor. You're nearly there a few tweaks should get you on track! \$\endgroup\$ May 6, 2018 at 15:05
  • \$\begingroup\$ The 1M resistors are a remnant from my original tests (in which I had a voltage divider, and I wanted it to use as little current as possible). I can use any value there, since the minimum reset pulse seems to be on the order of tens of ns. But can you explain what you mean by "interact with the microcontroller"? \$\endgroup\$
    – Bogd
    May 6, 2018 at 15:37
  • \$\begingroup\$ As for the switch, I am not sure what you mean - if I move the switch to the right of my capacitor (next to the RST pin), the pin will stay low for as long as the switch is pressed. And that is exactly what I am trying to avoid, and the reason why I have added an extra capacitor (to pull RST high again, even if the switch remains pressed). \$\endgroup\$
    – Bogd
    May 6, 2018 at 15:39

5 Answers 5

3
\$\begingroup\$

Using your basic idea, you can do something like this (just adding the one part, the circuit in the dashed box simulates what is on your dev board):

schematic

simulate this circuit – Schematic created using CircuitLab

enter image description here

The 2N7000 MOSFET is used to discharge the 100nF power-on reset capacitor on your board.

The simulation shows power-up at t=0 and then the reset switch pressed and held at t = 100ms.

Looks like you could easily go to 10nF and 10M resistors, and even less on the capacitance but take care of the MOSFET input capacitance if you try to go very low or try to substitute a different type of MOSFET (most of which will have much higher gate charge).

\$\endgroup\$
6
  • \$\begingroup\$ Out of curiosity, what was the intention in adding a MOSFET to discharge the input capacitance? What benefit does it bring? \$\endgroup\$ May 6, 2018 at 17:04
  • \$\begingroup\$ @SimonMarcoux Main benefit is that it makes it work. ;-) An alternative would be to greatly increase the capacitance in OP's circuit (say to 2uF from 100nF) but that would make the reset time very long or require a proportionally lower value resistor which would suck current so long as the switch is pressed. The impedance transformation from the MOSFET makes that problem goes away. \$\endgroup\$ May 6, 2018 at 17:25
  • \$\begingroup\$ @SimonMarcoux There's also another problem with that approach, it may not be obvious but the capacitor in OPs circuit causes the upper protection diode in the MCU to conduct when the switch is released (it's a manually-operated voltage doubler). That's not good, much worse with a low value resistor. \$\endgroup\$ May 6, 2018 at 17:26
  • \$\begingroup\$ This looks absolutely brilliant - thank you! I did try several approaches similar to your second idea (playing around with the capacitance and resistor value), but I couldn't get it to work. I never even though about using that MOSFET! I will try it on a breadboard, and see if I can get it to work. \$\endgroup\$
    – Bogd
    May 6, 2018 at 19:07
  • \$\begingroup\$ Until I get to test it, can you elaborate on the voltage doubler / protection diode issue? I did notice the voltage spikes when the switch is released, but I assumed I could easily send them to Vcc via a diode (I wasn't sure if the port had the protection diode or not). What were the risks there, and why was that a bad idea? \$\endgroup\$
    – Bogd
    May 6, 2018 at 19:10
2
\$\begingroup\$

A slightly modified version of your solution as pointed by Simon in the comment would work.

The key is that C1 must be much larger than the capacitor inside the board (C2 here) . The pull-up resistor must be lowered by the same order to keep the time constant the same.

Also from the comments I see a false issue with the "voltage doubler", the voltage on Reset pin will be divided between R1 and R3 to 1/10 order which means Reset pin can go at most 0.36V over V1 with a 36uA maximum current which is allowed.

R2 is there to prevent a current spike through SWX, C1 and C2 but if Wemos designers considered is not required you can skip-it to.

schematic

simulate this circuit – Schematic created using CircuitLab

For only one switch the diode and the 1M resistor are not needed

The drawback for multiple switches is that you will have to wait for all SW to be steady opened for a time to ensure that you don't loose any data but if they stay mostly opened this simple solution could work well.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ I wish I could accept multiple answers to the same question... I accepted Spehro's response because it answered the first part of my question, and didn't require additional parts (other than a MOSFET I already had :) ). I wish I could accept your answer as well, since it answers the second part. Thank you! \$\endgroup\$
    – Bogd
    May 24, 2018 at 11:20
  • \$\begingroup\$ @Bogd It's OK if that worked for you. You can up vote the answers that were useful. \$\endgroup\$
    – Dorian
    May 24, 2018 at 12:21
  • 1
    \$\begingroup\$ I tried to, but at the time I didn't have the "vote up" privilege :) . I received it in the meantime, so I was able to upvote. Thank you once again for your help! \$\endgroup\$
    – Bogd
    May 25, 2018 at 19:22
  • 1
    \$\begingroup\$ Thank you, thank you, thank you! I finally found the solution to my problem! \$\endgroup\$ Jan 12, 2022 at 18:31
1
\$\begingroup\$

Based on our conversation and on your comments, you can take a look at that schematics (Disclaimer: not my schematic).

enter image description here

The capacitor is charged to VCC until you bypass it using the switch. Once the switch is used, it will discharge the capacitor completely. If you want the discharge to be slower, you can put a resistor in series with the switch.

Regarding question 1: the only current that will be wasted is the leakage current that will pass through the reset port and through the capacitor (leakage current). Those are unavoidable unfortunately.

Regarding question 2: You can add many other switches in parallel with the first one. Each switch will be able to reset the ESP8266. However, if you want to route each switch to a GPIO, you will need a different kind of switch and configuration:

schematic

simulate this circuit – Schematic created using CircuitLab

R2 and R3 maintain a pull up status to your GPIO to ensure that it can differentiate correctly between a 0 and a 1. You could reverse VCC and ground on that sub circuit if you want the opposite (now that I think about it, it might even be better to pull down and prevent leakage current!) You could create a similar logic using a double throw switch depending on what you have readily in your hand.

\$\endgroup\$
6
  • \$\begingroup\$ If you want me to sketch out the circuit using double throw (if this is what you have in hand) let me know and I will add it with pleasure to the answer. \$\endgroup\$ May 6, 2018 at 16:59
  • \$\begingroup\$ First of all, thank you! I only have single throw switches (magnetic or mechanical contacts), so that is fine. My main question regarding your schematics is - how do they solve the "switch remains closed, yet the MCU has to wake up" issue? As far as I can tell, as long as SW1 is held down, the RESET pin is held low, thereby preventing the MCU from waking up. Am I missing something? \$\endgroup\$
    – Bogd
    May 6, 2018 at 19:02
  • \$\begingroup\$ you are not missing something on the comprehension part here. Indeed if I keep the switch down, it will be pulled to low all the time. I might have missed that piece of information when I red your question. Having a maximum ''low time'' before forcing a state change might be extremely tricky to do without completely changing the circuit's topology. The quick and dirty way to do it would be to use a timed trigger in between the reset port and the reset label of my schematic. Normally a monostable circuit would have been the choice for such an application, but it is backward from what you need. \$\endgroup\$ May 6, 2018 at 19:35
  • \$\begingroup\$ You therefore could use a monostable coupled with a logic inverter which will give you you're proper working circuit. But, I'd rather suggest that you scrap the previous circuit I proposed and work around the 555 timer circuit to attain a similar functionality. \$\endgroup\$ May 6, 2018 at 19:38
  • \$\begingroup\$ As I mentioned in previous comments, I have two issues with the 555: a) it's a 5V device, and b) I cannot find how much current it uses in a stable state. Both are very relevant for a device that needs to run a long time on batteries. \$\endgroup\$
    – Bogd
    May 7, 2018 at 7:20
0
\$\begingroup\$

I made some modifications in the first circuit to make it work with the RESET signal of the ESP01.

The RESET signal is connected to the node where the Voltimetes is connected (between the 100 ohms resistor and the diode. The 3,3k resistor must be removed, I put it to simulate the internal impedance of the RESET pin. Hope it works for you

enter image description here

\$\endgroup\$
0
\$\begingroup\$

button This works I use in my project, the second diode is needed to permit flashing with out disconnect the cable

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.