1
\$\begingroup\$

I would like to be able to use a switch to power on the ESP8266 (ESP-12F) and then be able to power-off the unit via GPIO pin in software.

I tried using a switch connected to CH_PD, and holding CH_PD high with GPIO#13, however, there is a long (6-10+ sec) power-up delay before I can "latch" CH_PD high with a GPIO pin. Since the switch on/off time would potentially be shorter than this delay, I think I need another circuit to reliably interface with CH_PD to get the functionality I want.

-Voltage source would be ~3.3V -Ideally state of on-off switch can be checked by the ESP8266 for further control

\$\endgroup\$
4
  • \$\begingroup\$ Does the built-in sleep capability not reduce current consumption enough? \$\endgroup\$ Commented Aug 25, 2016 at 8:17
  • \$\begingroup\$ It looks like deep-sleep power consumption is 10uA and power-off is 0.5uA. I would like to run it off of batteries as long as possible. \$\endgroup\$
    – bbglazer
    Commented Aug 25, 2016 at 9:19
  • \$\begingroup\$ A simple MOSFET will not work as the protection diodes in this or any other typical modern IC provide a path which will turn it back on - you need something inverting to avoid that. Consider an RT9701 or similar USB VBus switch - this looked like it was going to work, though the overall effort where that was tried failed as the chosen cell could not supply the ESP8266's very high startup current. \$\endgroup\$ Commented Aug 26, 2016 at 0:44
  • \$\begingroup\$ Are you sure about that 6-10 second delay? What software are you using on the ESP? I just did an experiment running with the github.com/esp8266/Arduino core and enabling a GPIO first thing in the setup() function, which shows a delay of about 20us between the rising edge on CH_PD and the GPIO going high. \$\endgroup\$ Commented Jan 1, 2019 at 16:36

2 Answers 2

1
\$\begingroup\$

This is a good resource about the Power on / Power off circuits for uC. I think what you need is described in section: "Latching push button ON/OFF power switch using a MOSFET high side switch"

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

A few ideas based on my real-world experiences with this type of design.

A. The solutions divide themselves into three classes:

Class I: Using an external circuit to control battery power to the micro.

Class II: Using the micro itself to control power to itself. E.g. Sleep Mode invocation and exit.

Class III: A hybrid of Class I and Class II. E.g. Turning on the micro with an external circuit or device (e.g. a momentary push button), then turning off the power using a facility of the micro (e.g. a GPIO pin).

There are downsides to each approach. Class I schemes draw battery power constantly, however miniscule. This is also the case for Class II schemes. Depending on the actual microprocessor and the cleverness of the circuitry, Class III schemes are fraught with problems because it is not a trivial matter to un-power a micro using its own resources.

Also, consider the actual impact of a tiny constant current draw on battery life. Some batteries can sustain a certain very low current draw without serious impact on their shelf life. Some battery spec sheets will contain this information, or at least hint at it. You can easily experiment with this by connecting high-value resistors across the candidate battery, let it operate like this for a long period while testing its voltage briefly every day or two.

You will also need a credible, reliable and accurate way of measuring sub micro-amp currents to determine the actual current draw of your circuitry. Most low cost DVMs do not do a good job with this. A cheap solution is an old-fashion electro-mechanical "galvanometer". Calibrate it using series high value resistors and a voltage supply.

Most low-power products use Class-II because of low parts count, cost, simplicity and known design issues (usually found in data sheets and application notes). With the right combination of battery and micro, this is probably as good as you can do without a lot of design and debug headaches. "As good" = reasonable battery life. However, I believe you can improve on this with a carefully thought-out and implemented Class I circuit of the type described in the article cited by ursusd8.

If you are up for a real challenge you should pursue the Class III approach you allude to in your question. You will likely find that turn-on is reliable, but that turn-off can create all sorts of unintended results. The typical problem is that the micro will manage to turn itself back on again as its supply voltage is dropping. This happens because for this brief period of time (while the supply voltage is collapsing), the micro is operating outside of its specified operating voltage range - the voltage range within which it was originally designed to operate properly. (E.g. How many micros are specified to operate at less than one volt?) Perform some basic experiments with your selected micro and power switch hardware (MOSFET, etc.) before you get too committed to the selected micro. Be prepared to learn more than you ever wanted to know about micro-processor data sheets and what they don't tell you about operation under marginal power conditions.

If you are looking for the absolute best low-drain solution, I think you will find it in Class I. However, be prepared to perform a lot of experiments with different devices, be equipped with a proven current measurement capability, and verify results with the selected device having different date codes because leakage currents of discrete logic devices vary significantly from piece-to-piece and production run-to-production run.

\$\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.