This is a delayed shutdown solution for a Car head unit(Android Auto based on OpenAuto Pro running on a Raspberry Pi). Generally if we power up the RPI from the cigarette lighter plug, it will turn off abuptly as soon as the the ignition key is switched off. Repeating this over and over may damage the board or kill the SD card very soon! To avoid this and have a graceful soft shutdown of the RPI, I have built this module based on a timer relay(FRM01) inspired by this thread.
The timer provides power to the RPi when the IGN is on. When the IGN is switched off the timer continues to provide power to the RPi for a configurable amount of time before switching off (e.g. 10 seconds). In tandem with this the relay opens when the IGN is switched off and sets GPIO pin 17 low. A script on the RPi monitors the status of the GPIO pin and ensures that the RPi shuts down before the timer cuts power to the RPi, screen and peripherals (e.g. 15 secs). If the ignition os back on before the RPi shutsdown, it will reset the timerrelay.
- FRM01 ~ $6
- 12V Relay ~ $2.5
- DC-DC buck converter ~ $4
- IN5401 Diode ~ $2.5(20pcs)(we need 3 for this project)
- Some AWG22 Gauge wires
- Case for the Power supply(Amazon) ~ $8
- Download the power-monitor.py script to your home directory /home/pi
- Create directory /opt/power-monitor - >
sudo mkdir /opt/power-monitor
- Copy script to /opt/power-monitor/power-monitor.py >
sudo cp /home/pi/power-monitor.py /opt/power-monitor/
- Set owner - >
sudo chown root:root /opt/power-monitor/power-monitor.py
- Add execute attribute to script - >
sudo chmod +x /opt/power-monitor/power-monitor.py
- Download the power-monitor.service to your home directory /home/pi
- Copy service definition file to /etc/systemd/system/power-monitor.service
sudo cp /home/pi/power-monitor.service /etc/systemd/system/
- Set owner -
sudo chown root:root /etc/systemd/system/power-monitor.service
- Install service -
sudo systemctl enable power-monitor.service
- Start service -
sudo systemctl start power-monitor.service
- Check status of service -
sudo systemctl status power-monitor.service
- In the script set the DEBUG variable to 1 -
sudo nano /opt/power-monitor/power-monitor.py
- Restart the service -
sudo systemctl restart power-monitor.service
- Debug output is directed to /var/log/daemon - view with
tail -f /var/log/daemon.log
- When finished set the DEBUG variable in the script back to 0
sudo nano /opt/power-monitor/power-monitor.py
A SPST NC relay can be used instead of a SPST NO relay. To do so edit the power-monitor.py script and change all instances (3) of
if IGN_UP
to
if not IGN_UP
The OpenAuto Pro is the most advanced Raspberry Pi based, custom head-unit solution ready to retrofit your vehicle. The main functionality of the OpenAuto Pro software is to bring Users access to modern head-unit features like: Bluetooth Hands Free Profile, music streaming, integrated media player, navigation via Android Auto, screen mirroring, rear camera support, and much more interesting options and possibilities. You can get a version of OpenAuto Pro from here.
You can use this coupon to get 5% discount on your purchase
oap_2021_so