10

Use case: On power loss, the pi is to gracefully close all I/O (already kept to a minimum) and shut down, to be manually rebooted later.

A supercapacitor works (I think; not sure of voltage near the end) but reboots the Pi (not sure why exactly).

A LiPo battery + charger + boost converter work fine, but are overkill. Too many components that could fail, and I need seconds, not hours of runtime.

[edit] The solution linked to by bobstro, and this one, allow the supplied voltage to drop to or below 4V. There are claims that even 3.3V can be OK (here, too), but the specs, I recall, state min. 4.75V. Is lower really safe for the storage? Could change a lot if it was.

8
  • Could you expand on this part: "A supercapacitor works (I think; not sure of voltage near the end) but reboots the Pi due to a voltage jump as it shuts down."
    – Brick
    Nov 3, 2017 at 19:19
  • @Brick Shutdown completes, and the device reboots. Not really sure yet what is happening there, I assume voltage jumps up as the pi stops drawing current. Or maybe it's just crazy stuff happening on insufficient voltage. Haven't examined it al that well, perhaps the cap is insufficient. Will put a voltmeter to it in 3 days or so; menwhile wanted to ask more knowledgeable users for something already known to work.
    – kaay
    Nov 5, 2017 at 20:52
  • 1
    Based on what you said, I'm guessing that it's not a power spike but rather a fluctuation right at the edge of where the Pi has enough power. Maybe putting a voltage detector in the circuit would help. Example part KA75450 mouser.com/ds/2/149/KA75390Z-189613.pdf. Would be interested to know what you find.
    – Brick
    Nov 5, 2017 at 21:01
  • 2
    Andreas Spiess has a great video on doing exactly this: youtube.com/watch?v=m20o3P-S5s8&t=441s
    – bobstro
    Nov 7, 2017 at 19:46
  • 1
    @Glenn Good, well-designed and efficient, but more expensive than the pi itself. Kind of overkill.
    – kaay
    Nov 8, 2017 at 13:39

1 Answer 1

5

The answer to the question is to build one of the 2 solutions:

  1. One based on a LiPo/Li-Ion battery - gives much more time than needed, but the parts (chargers, etc) are common and cheap, and can be replaced easily. I gather that a boost to 5V is purely optional and the Pi can work well at 3.3V.

  2. One based on supercaps. Good solutions are here (claims 111 seconds on a pair of 25F caps in series) and here. This one would be good too, if the voltage loss alarm were on the input rather than the battery. This option is much more expensive. Might be good to skip the boost converter altogether, efficient ones are expensive (can afford inefficiency with batteries).

To deal with the Pi turning on/off at low voltage, either use a voltage divider on the DC/DC converter's ENABLE pin (usually has hysteresis), or - even better - ignore it and protect the filesystem from consequences by making it read-only with a separate partition for data storage, mounted only when at the end of the system boot.

Also, though this lies beyond the question's parameters, but has turned out to be the best for me, SIGTERM, SIGKILL and unmount leave the Pi in a state where power loss is safe to the filesystem, with no need for a proper shutdown, cutting costs as we now need only a couple seconds rather than 15.

Your Answer

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

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