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.

kaay
  • 251
  • 1
  • 2
  • 9
  • 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 03 '17 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 05 '17 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 http://www.mouser.com/ds/2/149/KA75390Z-189613.pdf. Would be interested to know what you find. – Brick Nov 05 '17 at 21:01
  • @Brick Thanks, I'll edit the question. I thought Pi needed 4.75V. Maybe a 4.7V Zener? Anyway. any success stories with KA75450 on rpi? Or between the caps and a boost converter? I'll see what can be measured, perhaps I can get hold of an oscilloscope. Meanwhile, let's not lose sight of other ideas :) – kaay Nov 06 '17 at 09:12
  • 2
    Andreas Spiess has a great video on doing exactly this: https://www.youtube.com/watch?v=m20o3P-S5s8&t=441s – bobstro Nov 07 '17 at 19:46
  • http://juice4halt.com/ A little googling goes a long way. :-) – Glenn Nov 07 '17 at 18:34
  • 1
    @Glenn Good, well-designed and efficient, but more expensive than the pi itself. Kind of overkill. – kaay Nov 08 '17 at 13:39
  • You can buy this Battery from Adafruit: https://www.adafruit.com/product/1317 And this voltage changer from 3.7 V to 5 V:https://www.adafruit.com/product/2465 Voltage changer module has charging micro-USB port and output USB port – rktech Nov 16 '17 at 19:11

1 Answers1

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.

kaay
  • 251
  • 1
  • 2
  • 9