Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5067

Automation, sensing and robotics • Re: Detecting when 12V power is cut

$
0
0
I'm making a carputer and want to have my Pi do a graceful shutdown when the car turns off. I can have the Pi take power from the always-on 12V supply through the HiFiBerry Amp to get power, but how do I detect if the accessory power (also 12V) is ON/OFF to initiate a power up and power down? It'd also need to initiate startup automatically somehow when the accessory power becomes live.
There doesn't really seem to be a stand-out excellent solution to the problem of powering a Pi in a car, but there are several ideas floating around on this forum, and on the web.

To answer your specific question "how to detect if ACC is on or off?" I'd recommend an optoisolator connected to a GPIO.

Here's an example:
https://www.aliexpress.com/item/1005003242672161.html

You can get the 12V version, although the only difference is the value of R1.

Connect the input terminals to ACC and vehicle ground. Connect the output terminals as follows: OUT to the Pi GPIO you want to use, GND to Pi GND, and no connection to VCC.

Set up the Pi GPIO as an input with pull-up. Now, when ACC is on the optoisolator conducts, so GPIO is low. When ACC is off, the optoisolator is off, so GPIO is high. The rest is up to you.

Statistics: Posted by ame — Wed Sep 11, 2024 9:09 pm



Viewing all articles
Browse latest Browse all 5067

Trending Articles