Electronic – Turn on microcontroller by sensor, auto power off – how

low-powermicrocontroller

To minimize battery power consumption I want the microcontroller only to be powered when a sensor's output is high. After the microcontroller finishes a task, it should cut its power off again.

I found schematics for latching power circuits activated by buttons, as for example this:
https://randomnerdtutorials.com/latching-power-switch-circuit-auto-power-off-circuit-esp32-esp8266-arduino/

latching power circuit

Would it be enough to just replace the button in the schematic above with a NPN transistor of which the base is connected to the sensor output? (The sensor has to be powered, of course)

I know that this is an easy question, but I'm a beginner and didn't find any full circuits with the functionality I want so I want to be sure.

Alternatively:
For the button-activated auto-off circuits there is a ready-to-use product/module:
https://www.pololu.com/product/2808
Do you maybe know if something similar exists for my use-case?

Best Answer

It ought to be sufficient to connect your sensor signal to the junction of the 220k and the 10k resistors.

All you need is a high signal to cause the whole thing to switch on.


I hope you realize that the very first thing your processor has to do is to set a high signal on pin 2 of the connector. You also have to do this faster than the length of the sensor pulse.

If the sensor only goes high for 1 millisecond, then your processor has to switch its output high before that 1 millisecond expires.

You must maintain that high state until the processor finishes its task. When you switch it low again, this circuit will shutoff power to your processor.

By itself, this circuit isn't a latch. It lets your processor operate it as a latch, but it isn't a latch by itself.