Page 1 of 1

Power-off from python?

Posted: Mon Nov 28, 2016 12:07 am
by askvictor
I'm trying to implement what is essentially a battery protection circuit in code. I want the ESP device to periodically read its VCC level, and if it is below a certain threshold, shoot off an email then switch itself off. While I'm aware that deepsleep could work here, it would even nicer to go into complete power-off, which uses 0.5uA (compared to 10uA for deep sleep as per http://bbs.espressif.com/viewtopic.php?f=6&t=133 )

Any pointers? I could add an extra wire or two, but am trying to minimise component count as much as possible.

Cheers,

Re: Power-off from python?

Posted: Mon Nov 28, 2016 2:51 am
by dhylands
My brother and I designed a board that includes functionality to do that (among other things).

We used a MOSFET that is turned on by either a pushbutton or a GPIO line from the MCU. So the first thing that the MCU does is to turn on the GPIO line to keep the MOSFET powering the board. As long as the GPIO gets asserted before the user releases the switch then you're good.

This requires that the user press the switch again to turn it back on.

Re: Power-off from python?

Posted: Mon Nov 28, 2016 9:08 am
by pythoncoder
If the ESP8266 goes into a power down state, how do you wake it again? Do you have to power cycle the device with external hardware as @dhylands suggests?

Re: Power-off from python?

Posted: Mon Nov 28, 2016 9:59 pm
by deshipu
Deep sleep without a timer should work fine for battery protection. I think this is as good as you can get without additional external hardware, like dhylands suggests.

You "wake" it by restarting -- either by connecting the gpio16 pin to reset, and making it go low after a certain time (deep sleep with a clock, not useful in this case), or by connecting the reset pin to whatever else signal you want to be used for waking it up. Or, as in case of the battery protection, simply power-cycle it.

Re: Power-off from python?

Posted: Thu Dec 01, 2016 3:36 am
by askvictor
pythoncoder wrote:If the ESP8266 goes into a power down state, how do you wake it again? Do you have to power cycle the device with external hardware as @dhylands suggests?
You'd need a button or to short a couple of pins once the battery has been recharged.

Re: Power-off from python?

Posted: Thu Dec 01, 2016 3:48 am
by askvictor
Another thought: I currently have VCC connected to CH_PD (chip enable). Presumably as the battery voltage drops, at some point this will be below CH_PD's threshold, and the chip should power off. Do we know what that threshold is? Is it absolute, or relative the VCC?

Re: Power-off from python?

Posted: Sat Dec 03, 2016 2:34 am
by VisualEcho
If the reset threshold voltage is the same as other I/O, it's somewhere between 25% and 75% of supply voltage, and I suspect on the lower side when falling. I'm thinking there's a cheap way to do that adding a resistor and a zener diode.

I've had luck making intelligent power switches using an 8-pin Cypress PSoC4 ARM M0 chip connected to a MOSFET load switch. You can bang a couple of I2C lines to it and tell it how long to sleep, or tactile + LED for manual use.