Power-off from python?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
askvictor
Posts: 23
Joined: Tue Mar 22, 2016 9:08 pm

Power-off from python?

Post by askvictor » Mon Nov 28, 2016 12:07 am

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,

User avatar
dhylands
Posts: 3228
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Power-off from python?

Post by dhylands » Mon Nov 28, 2016 2:51 am

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.

User avatar
pythoncoder
Posts: 3613
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Power-off from python?

Post by pythoncoder » Mon Nov 28, 2016 9:08 am

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?
Peter Hinch

User avatar
deshipu
Posts: 1348
Joined: Thu May 28, 2015 5:54 pm

Re: Power-off from python?

Post by deshipu » Mon Nov 28, 2016 9:59 pm

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.

askvictor
Posts: 23
Joined: Tue Mar 22, 2016 9:08 pm

Re: Power-off from python?

Post by askvictor » Thu Dec 01, 2016 3:36 am

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.

askvictor
Posts: 23
Joined: Tue Mar 22, 2016 9:08 pm

Re: Power-off from python?

Post by askvictor » Thu Dec 01, 2016 3:48 am

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?

User avatar
VisualEcho
Posts: 17
Joined: Mon Jul 04, 2016 7:49 pm
Location: Ann Arbor, Michigan
Contact:

Re: Power-off from python?

Post by VisualEcho » Sat Dec 03, 2016 2:34 am

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.

Post Reply