I have a RPI2B controlling a mobile CCTV setup. System runs on 12V (solar panels + batteries) with a low voltage disconnect (LVD) and PI powered by a buck step-down converter. RPI drives a relay via a MCP23017 port expander + transistor etc on a custom board. The relay toggles +12V source for the buck from either the LVD or directly from the battery. A simplified diagram of the circuit is shown below.
When PI powers up, a python program starts which toggles the relay setting the +12V source to the battery (directly). If the battery voltage drops below a certain voltage, the LVD cuts out which is picked up by RPI via the GPIO IN. Pi does some magic and then shuts down. As one of the last things before power off the relay goes off and toggles the +12V source to LVD so PI loses power. This allows for the PI to startup automagically once the battery recharges and LVD turns on.
When shutting down I don't explicitly turn off the relay. It goes off by itself almost at the very end of the shutdown. Unfortunately while testing I can see that the ACT LED on the PI continues to flash for about second after the relay disconnects. This leaves me with about a second of power shortage.??
Q1. At what point exactly in the shutdown process is it safe to lose power?
Q2. Can I use a capacitor (as shown in the diag.) to 'hold' the power for a second or so. If so, how do I calculate the value? I looked at some equations related to capacitor energy etc, but its little bit over my head atm.