Solution and sketch for detecting 12v dc presence to log usage in hrs and min

You may want to consider using a voltage divider or regulator and polling a connected GPIO pin.

I assume when it drops out - it’s gone (0V).

... or are you looking for the schematic and sketch?

Pat.