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/
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?