2

Apologies if this is a duplicate, but I can't seem to find a suitable solution.

I need to power a Raspberry Pi in a car, and for obvious reasons need to shutdown gracefully, however, I need it to automatically start backup when the car is started (and power reconnected).

The car has two power sources, mains (always) and accessory (only when the ignition is on.) Instead of using a battery which was original idea, is it possible to use two power sources, and when switched to mains, it will power off, but when accessory is switched back on, the Pi Powers up.

Alternatively, is it possible to do this off a battery powered by accessory, not sure how they would communicate though.

Kind Regards, Fox

Foxhound
  • 129
  • 1
  • 1
  • 3

2 Answers2

3

Feed both sources to a single voltage regulator through diodes. Additionally, provide a GPIO signal from accessory source which will tell the RPi whenever accessory power is present, so ther RPi can decide to shut down when it's not. Use a timed relay to cut off mains power after accessory power was missing for a minute or two.

schematic

simulate this circuit – Schematic created using CircuitLab

In many modern cars the cigarette lighter outlet already includes an equivalent of such a timed relay and diodes, so if you connect your RPi power supply to it, you will only need to provide a shutdown signal, i.e. R1/D3.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
1

Perhaps you already found it, but I recently came across this pi hat for interfacing with a car computer: http://www.carberry.it/

NOTE: I have not used it myself, so I have no clue about the quality.

According to the specs it is powered by the car battery even when the ignition is off (which I assume you mean with mains). They also claim it allows for a gracefull shutdown when the car is powered down, apparently by checking an IO pin or using a daemon they supply.

Cortado
  • 31
  • 6