Ok Team I need to know if this circuit will work or if there is a better way.
Use Case: I have a piece of machinery that is controlled via a Raspberry pi zero W. It just controls a relay board to control the machine, pretty simple. The machine is moved around a lot and likely unplugged and plugged into power regularly. I need to be able to keep the pi running for short periods while the machine is moved and then shut it down and disconnect from power when not in use. I want this to happen automatically as user education will be a futile effort.
Proposed Solution: To prevent powering the pi down and up all the time I have including a LiPo battery as backup. I use a charge/boost controller that passes power through to the pi and charges the LiPo when it is connected to power then switches to battery power when there is no power (this unit).
I have a voltage divider that is connected to a GPIO pin and a script that monitors the pin. When the pin goes low the script will set a timer to shutdown the pi if the pin does not go high again within a set time (say 5 minutes).
So far this all works. But. The while the Pi is shutdown it still draws like 20mA and it will discharge my LiPo if not used for an extended time. From what I have read this will damage the battery.
So... I have I have set a GPIO pin to default LOW using the
/boot/config.txt which is set very early in the boot process and unset as the pi does it's warning flashes to shut down. What I need to do is switch something using that pin to isolate the pi from the battery power. Following this question I am proposing to isolate the pi using two transistors.
Will this work? Will I invoke the powers of the magic blue smoke? Any other ideas. I am a rookie so assume no knowledge. Thank you, truly appreciate the generosity the this community.