- Loss of main power should trigger the RPi to shutdown.
- Return of main power should boot the RPi.
- Power-up should wait until caps are sufficiently charged so RPi can boot cleanly.
- Wait for RPi to shut down before removing power (to enable reboot).
- Should cope with brief power drop-outs (maintain RPi operation).
- (Re)boot after shutdown completes if power returns whilst shutdown is in progress.
- Be as simple as possible and relatively low cost.
I'd had originally chosen to base the UPS around a "Raspberry Pi Wemos 18650 Battery Shield V3", essentially the guts of a small powerbank (as I already had some 18650 cells and I could easily access connections and package it in a way that suited me), but that had issues (see logs).
I also went through a couple of iterations of comparator and supercap circuits until I realised it is easier to get the correct behaviour from a µC than from a bunch of analogue components. Easier to tweak the behaviour too.
The latest design still uses hassle-free supercaps to provide the hold-up, coupled with a small Arduino to handle the delays and conditional switching (a Nano, Mini, Trinket or similar should do). The supercaps, as a bonus, support the peak power demands of the RPi, allowing me to get away with using a smaller power supply. In theory, anyway. I'm still testing the latest version...