Skip to content

Boot, reboot and shutdown the Pi with ignition key

Michael E. Palmer edited this page Aug 24, 2019 · 5 revisions

You can make a ON/OFF button for your Crankshaft head unit using GPIO3 and GPIO27 pins.

Note: You need a 5 pin relay and the shutdown/reboot script.

Instructions

Boot

GPIO3 wakes up the Pi from halt state by default (short pin 5 to ground)

Reboot/shutdown

This reboot/shutdown script could be helpful.

If you buy a simple 12 volt relay you can trigger boot / shutdown with your car's ignition.

Same like any car stereo works.

You need to connect the coil of the relay (pin86) to your switched power line (the line which is powered when ignition is on) and (pin85) to ground. The switch contact 87 of the relay (normally OPEN) you connect to pin 5 (GPIO3). The switch contact 87a of the relay (normally CLOSE) you connect to pin 13 (GPIO27). The common contact 30 of the relay you connect to pin 6 (GROUND)

Function

When you turn on the ignition the relay gets 12 volts and closes the relay Switch(87/30). This sets GPIO3 to LOW and your Pi will boot.

When you turn the ignition OFF the relay closes the Switch contacts(87a/30) and GPIO27 is set LOW. The Pi shuts down when ignition is off for at least 5 seconds (TIME is setable in the script)

Relay with wiring harness

https://www.amazon.com/gp/product/B01N66W2XF/

Above is a link to Amazon but any other 12 volt/5 pin relay will work!

Relay connectors

pin 86=   SWITCHED power(ignition)
pin 85=   Chassis Ground (Vehicle electrical system ground)
pin 30=   GPIO Physical Pin 6 or USB ground(Raspberry Pi/USB Ground)
pin 87a=  GPIO Physical Pin 13 (RPI GPIO 27)
pin 87=   GPIO Physical Pin 5 (RPI GPIO 3)

Raspberry Pi GPIO pins: https://www.raspberrypi.org/documentation/usage/gpio/images/gpio-pins-pi2.jpg

Raspberry Pi GPIO Pin Numbers: https://www.raspberrypi.org/documentation/usage/gpio/images/gpio-numbers-pi2.png

Relay Wiring Pinout: https://images-na.ssl-images-amazon.com/images/I/71vF%2BJbm5bL._SL1500_.jpg

NOTE:

You can edit the shutdown and reboot times in the script. Default time for reboot is 2 seconds and default time for shutdown is 5 seconds.

That means if you turn the car's ignition OFF the Pi will shutdown after 5 seconds. But if you turn the ignition OFF for just 2 seconds, then turn the ignition ON again, the Pi will reboot. I suggest setting the reboot time to 5 seconds and the shutdown time to 10 seconds to avoid unwanted reboots when starting your car's engine which causes the relay to lose power.

Have Fun :)

P.S. Note: Unfortunately GPIO3 is on the same pin as SCL. So if you keep this pin grounded with a relay when the car, and the pi, are on, you can't use I2C.

Also, note that the referenced shutdown_button script requires that you hold the "button" down 5 seconds, then release it. So you will have to modify it if you are just going to shut the ignition off and leave it off.

Clone this wiki locally