1

It can be long discussion, because there is no single solution around this, so, to cut the story short, I will tell where I stuck on my way.

It is AndroidAuto (media centre in car on raspi) project I'm currently working on, and I'm stuck on effectively powering raspberry and safely shutting it down when ignition is on/off.

Initially, I went with mausberry solution circuit, that takes 12v const/ignition/ground from car battery on input, takes care of voltage conversion and triggers safe shutdown in the event of ignition goes off. But mausberry didn't supply the circuit, so when I fed up to wait I decided to go UPS route.

I use, one of them, Geekworm (geekworm.com) UPS HATs (+ separate unit for 12v-to-5v conversion) that goes over Raspberry GPIO, takes ignition as power source, charges its battery and in parallel powers Raspberry while ignition is on. When ignition goes off, Raspberry stays on and battery on UPS starts discharging.

At this point I need to trigger safe shutdown, so that no electronics draining my car battery.

Geekworm UPS HAT, also, have annoying switch that has to be pressed to give power to Raspberry, which I don't need as I want to start Raspberry when ignition turn on. This is possible to overcome by just using a micro usb splitter that will go into UPS and Raspberry from ignition power source. That is stupid solution to my view, so if anyone can help with more elegant solution, I'd appreciate.

EKreger
  • 11
  • 1
  • 2

2 Answers2

1

If you're feeling handy, I'm actually in the middle of building something that meets almost the same requirements. In my case, I have a Pi running RetroPie that is powered from the USB port of our television. I want to ensure that the Pi shuts down cleanly when the TV is turned off, and I would like it to boot up automatically when the TV is turned on.

I'm solving this by using an Adafruit PowerBoost 1000c, which is a "load-sharing battery charger" -- that is, it will both power your Pi and charge a battery at the same time, and if power is removed it will use the battery to power your Pi. That's handy, but by itself it doesn't implement the necessary logic to meet my needs so I've written some code that runs on an ATtiny85 to make up the difference.

You can find the code and a brief description of things at https://github.com/larsks/pipower. It's a breadboard and a bunch of wires on my desk right now, but it seems to be working so far. I just got things working earlier this evening, so the documentation leaves a lot to be desired.

larsks
  • 685
  • 1
  • 6
  • 19
1

I believe this is the same (Chinese) board: UPS HAT

Apparently there is no simple way to determine whether you are running on power (ie car battery) or the UPS battery.

FAQ
1.Is there a way to know if the battery is being charged or not?
Answer:
There is no direct way to know if the battery is being charged or not. BUT
you can get many time volatage in a short time, then judge the volage value.
For example: In 20 second, we get the 20 volatage value: 5.11v,
5.08V,
5.04V
5.01V
4.99v
... thus we can know the battery is charging. because the voltage value is raising

So you probably need to do something like this and then call the shutdown command.

If you follow this link, there seems to be some sw solution to the power-on problem, but I do not know anything more about that.

Tomas By
  • 218
  • 5
  • 13