0

Sorry if this is a duplicate

So I am in the process of installing a Raspberry Pi into my car and have designed a simple circuit to delay power on and off to it to allow sudden turn-offs while starting the car (since my car will turn off accessory power temporarily when starting the car, a double power on if you will) and to allow enough time for a proper shutdown when the car turns off. The design takes the place of a navigation system that I took out in lieu of the RPi. The entire circuit is not very complicated and could probably be improved but works for the time being. It uses a 555 and capacitors to delay both on and off.

The delay-on is taken care of and works without issue. But I can’t come up with a simple solution to initiate power off when the car is turned off. I was looking into gpio-shutdown and using a transistor to short pins 5 and 6, but the transistors I have on hand don’t really work (not to mention the fickleness of whether or not the Pi wants to shut down when they’re shorted anyway).

To avoid damaging the Pi, my first thought was to separate the power circuit and Pi using a PNP driven by the 555 output which would theoretically short the two pins when the output goes low (pin 5 on E, pin 6 on C, 555 output on B). But the transistor I have on hand does not short them and an NPN for testing purposes also fails. I’m guessing the diode drop from the BJT is the culprit somehow. I would have tried a MOSFET if I had any, and since I am not totally familiar with GPIO, I wanted to avoid a straight 12 - 3.3v converter from ACC or the 555 output to provide a signal for shutdown (though I am not unwilling to try if my fears are unwarranted).

I would like the Pi to shutdown peacefully when the car is turned off but have been unable to come up with anything else. I am wondering if anyone has come up with a solution for something like this and would be kind enough to share. I have posted my design here.

Thanks in advance!

Schematic Details:

  • The system is 12v DC
  • VCC is always on
  • ACC is on when the key is in the 2 position and when the car is on
  • The CPC1718J is a solid state relay
  • The J2 at the end plugs into a separate 12v - 5v converter to power the Pi
  • In practice, the circuit turns on around 4 seconds after receiving ACC, and turns off about 40 seconds after ACC is cut

enter image description here

7
  • 1
    Does this answer your question? Car Powered Raspberry Pi: Safe Shutdown and Power On. Your problem seems to be with the self-made timer circuit, why don't you just buy a timed relay? Commented Apr 6, 2021 at 7:32
  • Can I send a 12v signal with a 1k resistor straight into a GPIO pin and avoid damage? I would need to make some code looking for a high signal going low correct? The circuit is my timed relay, since it will turn off power to the Pi after turning off the car, but I want to also software shutdown the Pi before power is cut, I am looking for how to send the "shutdown signal"
    – Kevin Lee
    Commented Apr 6, 2021 at 15:11
  • 12V is deadly for a GPIO pin, that's why you need a LED: it will drop the voltage to its bandgap level which is 1.9...3V depending on the color. Also, check the cigarette lighter: on my car, it stays powered for 2 minutes after you remove the key, so there's no need for a timed relay at all. Commented Apr 6, 2021 at 16:13
  • I will attempt this as soon as I get home
    – Kevin Lee
    Commented Apr 6, 2021 at 17:01
  • Unfortunately my car has no such timing delay. Am I able to use gpio-shutdown for this or do I need to use something else?
    – Kevin Lee
    Commented Apr 6, 2021 at 18:09

2 Answers 2

-1

You can try super capacitor and implement safe shutdown.

or try the ready-made hat available @ https://juice4halt.com

2
  • This seems more like a UPS rather than a turn-off signal. I am indeed trying to implement a safe shutdown but this seems to be more than I need at the moment (also kind of expensive, I have all my components already). Really I am looking for a way to send the shutdown signal safely and maybe what I need to code in for it to work
    – Kevin Lee
    Commented Apr 6, 2021 at 15:16
  • You can create a service with below python code and trigger GPIO on state with your circuit ``` import RPi.GPIO as GPIO import time import os GPIO.setmode(GPIO.BCM) GPIO.setup(buttonPinNo, GPIO.IN, pull_up_down=GPIO.PUD_UP) while True: if (not GPIO.input(buttonPinNo)): os.system('sudo shutdown -h now') ```
    – ismail
    Commented Apr 7, 2021 at 6:00
-1

You can create a service with below python code and trigger GPIO on state with your circuit

import RPi.GPIO as GPIO import time import os
GPIO.setmode(GPIO.BCM)
GPIO.setup(buttonPinNo, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
    if (not GPIO.input(buttonPinNo)):
        os.system('sudo shutdown -h now')

Source: https://www.instructables.com/Simple-Shutdown-Raspberry-Pi-Button-by-Using-GPIO/

1
  • I understand that the Pi can be shut down from a GPIO input. I am asking how to implement it via a signal with the design posted and what considerations I need i.e. current limits, voltage considerations, etc. because I don't want to have to push a button every time I turn off my car (as simple as it would be).
    – Kevin Lee
    Commented Apr 7, 2021 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.