I am re-posting the schematic with a couple of corrections.  "Always on" +12 from the car's battery needs to be connected to the source of the IRF9540.  A diode must be added to the input circuit so that the relay coil's resistance does not mess with the R-C decay time on the gate of the BS170. 
I finally get your concept of using one of the pi's i/o pins to signal shutdown, I think. Maybe it doesn't even require much in the way of code. Can you have a output pin held high, that reliably goes to a low state, or floats, when the pi shuts down? Can a cron job execute at power down to make an i/o pin low and be the very last task?
                       
                           
                       
                     I finally get your concept of using one of the pi's i/o pins to signal shutdown, I think. Maybe it doesn't even require much in the way of code. Can you have a output pin held high, that reliably goes to a low state, or floats, when the pi shuts down? Can a cron job execute at power down to make an i/o pin low and be the very last task?
Statistics: Posted by wstein25 — Tue Apr 30, 2024 2:12 am