Close

Here we go again...

A project log for Cheap-O-NAS

A low-cost solid-state NAS with power-loss protection

robgRobG 11/03/2019 at 15:010 Comments

Aaarg. Must stop finding problems to solve...

The solution was looking promising: RPi4 running OpenMediaVault coupled to a pair of SSD's in a RAID 1 configuration, like this YouTube video or similar. All the benefit of Gb Ethernet, USB3.0, SSD speed, and mirroring for robustness. Sweet. Total bill so far about £130.

Then I realised about power loss corrupting the RPi image, and worse, the SSDs - especially cheap ones like I'd chosen. Balls.

So what I need now is a battery 'hold-over' supply. Not quite a UPS (I don't need it to run for hours and there's no need for a rechargeable battery and all that), but just for the 10 secs or so for the RPi to shut down cleanly. And a mechanism to tell it to shut down. And a way to cut the power once it has shutdown so the batteries aren't run flat. Oh, and it must also come up again cleanly once the main power is restored. Phew - anything else?!

This forum post indicates that the Pi's supply should ideally be between 4.7V and 5.25V, at up to 2.5A, though 4.0 to 5.5V might work. The PMIC's abs. max. is 6V. The official datasheet for the Pi just says 5V.

After some inspiration, and a lot of simulation in LTSpice, I've come up with this:

The idea is the battery is normally disconnected from the load until the main supply drops below about 4.8V. When this happens, the TL413a goes hi-Z making the nPGOOD line go high. This simultaneously switches the PMOS on, applying battery power, and also notifies the RPi (via a GPIO) that the power has been lost. It can then set about shutting down cleanly. The last thing it must do is change the GPIO pin from input to output, and drive it low. This cuts the battery power, turning the RPi off completely. Upon restoration of the main supply, the whole thing pops back into life, and the RPi boots as normal.

Hope it works!

Discussions