This circuit can control the power to a raspberry pi, using a few GPIO pins and 2 buttons. The raspberry pi needs to send a high pulse to R after startup, and hold pin H high until shutdown. A N/O momentary switch connected to GI and GO will turn the power on. A second button connected to one of the RPi GPIO pins can be used in software to shut down the pi. When the OS shuts down the GPIO pin holding H high will go into hi-z(input) mode. About 5 seconds after the H pin goes low the power will be cut. This circuit consumes 3ma of current at 5.1 Volts while off. I still need to rework the latching section to reduce power consumption.