Using car ignition to trigger OnOff Shim

Hi there. I would like to connect my pi to my car battery. I intend to use a 12v to 5v adapter to connect the pi to the battery (via the fuse box) with a constant current.

I am then thinking of using another circuit from the ignition to control the power up/power down sequence.

Is it possible to trigger OnOff Shim using a separate circuit such as the car’s ignition instead of a switch?

One option would be to wire a 12V relay to the switchable 12V source. Then use the Relays switch contacts to mimic a button press being sent to the on off shim. The common © and normally open (NO) contacts on the relay would be open when de energised, and closed when its powered up. Just find a 12V source that’s only on when the keys on.

There are some potential pitfalls… you should probably use the ACC wire from your ignition switch. The ALT wire usually goes low during starting and glowing (if you have a diesel), but is otherwise high when ACC is high. Also make sure that you wire the power from a different source if you want a clean shutdown.

Reading the OnOff shim description, it triggers on a low signal, so switching off ACC should do the trick. Not sure if it works the other way around, for switching it on with the ACC.

Thanks, I will try what you said using a relay. I guess my next question would be is it possible to configure the on off shim to check if the switch had been triggered ‘off’ during the boot sequence?

I have been experimenting with my OnOff shim today and noticed something which may hinder my plans.

The Shim supports an external momentary button which triggers the boot up by pressing the button for a second and then releasing. The releasing of the button is required for the process to work.

Momentary push buttons only stay shut for as long as you are pushing the button.
Maintained push buttons you push and they stay depressed until you push them again.
Referenced here

I realise now that I will need this to work using a maintained button because this is how the 12V relay would work if it is connected.

Is it possible for the Shim to work using a Maintained push button scenario?

Ah, OK, so it uses a pulse (momentary button press) for on and off. That makes things tricky. Just using a relay isn’t going to work. May have to use a 555 timer or something? Maybe two 555 timers, one for on one for off? I’ll have to give that some though? I don’t have an answer at the moment.

i would use an arduino type microcontroller as an inbetween. then you could also add a more complex shutdown easier. I would limit the amount of on/off in a brief time also.
pretty much program the arduino (micro is my preferred) to take car of tripping the soft shutdown and power on gpio button scripts. Difference is the arduino could handle all the timing issues with turning car on then off then on quick, delayed shutdown, peraps even a keep on after car off switch etc.
The arduino has vast libraries of code available so it programming the scripts in might be as easy as alot of cut and paste with minimal tweeks.
Also check out the esp32 and esp8266 with wifi & lo power bluetooth. You could make not only a remote start but alot more.
I would be interested in seeing finale build.

I have been able to achieve my desired functionality by changing slightly the ‘cleanshutd’.

Now, when the script is running with the daemon as usual, it is continuously polling the pin state (which is in a constant ‘low’ state at this point) until the button is switched to the off position. On that event the pin state changes from 1 to 0 and triggers the power down.
Once the device is fully off, it can be switched back on by clicking the switch again.

The only problem I have is that the power down sequence takes about 7 seconds until fully off. If I flick the switch back on during this time it will not be registered and then any subsequent switching on or off has no affect. The device remains off until I plug out and back in.