Go Down

Topic: Enhanced mode Mosfet to connect Reset to button when in Deep Sleep (Read 594 times) previous topic - next topic

ShermanP

Yes, I breadboarded it using a 2N4401, and found that a 100K pullup resistor worked fine.  A 220K did not.

One thing to be careful about is the deep sleep current draw if you use the software solution you found.  The pullup resistor solution won't use any current during sleep, only when in active mode (33uA for a 100K pulled up to 3.3V).  If the software solution turns on the entire GPIO electronics, it may draw a lot of current in sleep mode.  But I'll be interested to see what you come up with on that.

Edit:  In my previous post I said setting D2 to Input would enable the reset function.  I meant D5, and have corrected it in that post.  So set D5 to Input to enable the button to reset, or to Output Low it disable it.  Actually, in deep sleep D5 is automatically floating, so your code doesn't have to do anything but bring it Low when your code starts up.

mightymouse123

Thanks for trying that out. I was using a 10k resistor and it was working fine. Would a 100k resister or a 10k resistor use more voltage when the ESP is on? Is there a reason to use a 100k resistor over a 10k? I have never measured current draw with my multimeter before so I am going to have to set that up next :)

ShermanP

When you're in active mode, D5 will ground the bottom of the pullup resistor, and current will flow through it.  A 3.3V drop across a 100K resistor will sink 33uA of current.  A 10K resistor will sink 10 times as much - 330uA.   In sleep mode, D5 will be floating, so that current will flow through the transistor when you push the button.  The upper limit for the resistor is determined by the amount of current the transistor needs to sink to reset the device, which will depend on the base current provided by the pullup resistor, the transistor's gain, and the value of whatever pullup resistor is on the Reset line. Basically, you want the largest resistor that still works reliably.

mightymouse123

Thanks. I will go with a 100k resistor. I researched the software register and though the manual mentions it - in practice It does not seem to actually work. So going with the external pullup. Thanks so much for all your help everyone.

mightymouse123

So I created the circuit and I am using a lot more power in deep sleep then I expected. Part of the problem is that I have a 64 pixel NeoPixel array attached that even when not showing anything draws 20mA but the rest of my circuits is still drawing 13mA for the esp8266, a voltage divider battery measurement connected to A0, the transistor and a low quiescent LDO(MCP1700-330E). I was hoping to be in the uA area when in sleep so it looks like I probably need to disconnect all the power completely and then have the button turn it back on.  So I was wondering if there was a circuit that could completely cut the power until the button is pressed. Once the button is pressed the controller would activate something on a pin like D5 to have the button go back to its normal usage on D2 until it came time to go to sleep. Maybe there is a way to still do it with the transistor but it seems like I might need something else.
Thanks for any input.

mightymouse123

Well it looks like I probably need something like this. Extreme Power Saving (0µA) with Any Microcontroller: Latching Power Circuit | Random Nerd Tutorials

It seems that I can connect the button to D2 and it won't do anything to the latching circuit after the latch is set but that is the part I still need to figure out. 

wvmarle

I have a 64 pixel NeoPixel array attached that even when not showing anything draws 20mA
I thought they draw almost double that in quiescent current!
indeed to really save power you have to power them down - switch the Vcc line (high side) with a p-MOSFET.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

ShermanP

The attached circuit would probably work.  Pushing the button turns on the power, and when the processor comes up it turns on the NPN transistor, which keeps the power on when the button is released.  Then the button can be used for other input.  When the session is over, the processor turns off the NPN and the power shuts off.




mightymouse123

I don't have all the parts on hand to breadboard this circuit. But I will work towards testing this out. Thanks for all your help.

mightymouse123

Thanks ShermanP and everyone else for all of your help. I used ShermanP's latest circuit and got the PCB back yesterday. The  circuit worked great. I was a little worried about the latching speed for pulling D5 high as I did not know how fast my first line of code would run on the ESP8266. But it actually works great.  Even if I tap it pretty fast it still boots up and latches. I turn it off by setting D5 Low.

Thanks again for all of your help everyone.

ShermanP

I'm glad it's working for you.

If the ESP8266 is connected to USB, its bootloader may take some time seeing whether the computer is trying to communicate with it.  Then you may need to hold the button down for a while.  But with no USB connection, it will get to that first instruction pretty fast, as you have found.

Go Up