[SOLVED] Raspberry Pi Safe Shutdown/UPS Boards

ethan206

Reputable
Jul 27, 2018
138
1
4,695
1
I was recently looking to add a UPS to my Raspberry Pi as I use it for a NAS and want to avoid any random shutdowns or power outages that could lead to data loss but realized that most of them don't really fit the case enclosure that I have right now. I stumbled upon the X735 (v2.5) Power Management Board/PWM board and I was wondering if I could use that instead. My understanding is that it's not a UPS as it doesn't include a power supply but it supports safe shutdown so, in a scenario that my Pi (with a hard drive attached) loses power, it'll perform a safe shutdown and not a "hard" shutdown and will prevent any kind of corruption and/or data loss?

https://www.amazon.com/gp/product/B07R45W1LN/ref=ox_sc_act_title_3?smid=A3OWUO30LQJ1NE&psc=1


I also found this case saying it supports safe shutdown, but it doesn't seem to include a PWM board? Would this work for my scenario?

https://www.amazon.com/Geekworm-NASPi-Shutdown-Function-Raspberry/dp/B095YCL7S8?ref_=ast_sto_dp
 
Last edited:

OldSurferDude

Commendable
May 18, 2019
89
13
1,565
18
A bit more reading yields the solution. On this page is the question:

11. Does this supply safe shutdown when power is cut? Or just safe shutdown when power is constant and a signal switch is cut

  • A: Sorry, no, the X735 does not support safe shutdown when power is cut. Please consider X728 if you need this function.
So you really want the X728 with AUTO ON enabled.

Done. If it will fit in your box.

Take-away. #1 Read as much of the documentation as you can find and it will probably help solve your problem.

Take-away #2. If you're going to get deeper into this stuff, you'll need to learn some basic electronics and soldering.

Thanks for introducing me to GeekWorm :)

PS be sure to get good 18650 batteries ( Newegg.com or fullbattery.com)
 

OldSurferDude

Commendable
May 18, 2019
89
13
1,565
18
Your RPi (with power management) will have to have enough powered provided to it to shut down, one of the purposes of a UPS.

I would propose that you use a USB power bank to run your RPi and the power bank always being charged from a power supply. Then put a sensor on the power supply to detect a power outage. The sensor would then trip your power management board into going into shutdown.

Now that I write that down, that sensor could be fed directly into the RPi and then the RPi could shut itself down, obviating the need for the Power Management board. (careful! the ground of the power supply would have to be the same as the ground of the RPi. If it is not, you'll have to use an opt-isolator.)
 

kanewolf

Titan
Moderator
Your RPi (with power management) will have to have enough powered provided to it to shut down, one of the purposes of a UPS.

I would propose that you use a USB power bank to run your RPi and the power bank always being charged from a power supply. Then put a sensor on the power supply to detect a power outage. The sensor would then trip your power management board into going into shutdown.

Now that I write that down, that sensor could be fed directly into the RPi and then the RPi could shut itself down, obviating the need for the Power Management board. (careful! the ground of the power supply would have to be the same as the ground of the RPi. If it is not, you'll have to use an opt-isolator.)
That is the hard way. Get a UPS that has a USB or ethernet port. Then run NUT on the PI to monitor the UPS. NUT can then shutdown the PI.
How To article -- https://www.howtoraspberry.com/2020/11/how-to-monitor-ups-with-raspberry-pi/
 

OldSurferDude

Commendable
May 18, 2019
89
13
1,565
18
That is the hard way. Get a UPS that has a USB or ethernet port. Then run NUT on the PI to monitor the UPS. NUT can then shutdown the PI.
How To article -- https://www.howtoraspberry.com/2020/11/how-to-monitor-ups-with-raspberry-pi/
For sure, @kanewolf , but ethan206 stated "... don't really fit ...", Thus my suggestion.

What I failed to mention is that finding a power bank that will provided the energy needs of the RPi/hard drive and will still provide power when the power supply is plugged into the power bank may be problematic.
 

kanewolf

Titan
Moderator
For sure, @kanewolf , but ethan206 stated "... don't really fit ...", Thus my suggestion.

What I failed to mention is that finding a power bank that will provided the energy needs of the RPi/hard drive and will still provide power when the power supply is plugged into the power bank may be problematic.
I guess I don't understand your statement above. A UPS that is providing power via AC to the PI and is monitored by the PI such that it does a graceful shutdown prior to the exhaustion of the battery is all that is required. As long as all the file systems are cleanly shutdown/unmounted there shouldn't be any issues with the power going away unexpectedly AFTER the graceful shutdown.
 

OldSurferDude

Commendable
May 18, 2019
89
13
1,565
18
I guess I don't understand your statement above. A UPS that is providing power via AC to the PI and is monitored by the PI such that it does a graceful shutdown prior to the exhaustion of the battery is all that is required. As long as all the file systems are cleanly shutdown/unmounted there shouldn't be any issues with the power going away unexpectedly AFTER the graceful shutdown.
While I like your solution, @kanewolf, ethan206 stated a size restriction: "...most of them don't really fit the case enclosure that I have right now."

If I understand your solution, the configuration would be:
  • power RPi with the usual power supply (AC to USB(5V)@2.5A)
  • plug the RPi power supply into the UPS
  • the UPS having a monitoring port (USB or ethernet), connect the appropriate RPi port to the UPS monitoring port.
  • run NUT on the RPI
My solution requires a power bank with pass-through charging, (PTPB) software and a sensor.
  • power the RPi with the PTPB
  • modify the cable to the PTPB from its power supply, connecting the input of an opto-isolator (with appropriate resistors) in parallel to the output of the power supply
  • connecting one of the RPi's inputs to the output of the opto-isolator.
  • write software to monitor this input pin that will shut down the RPi when the signal goes high.
As I write this up, though, I see that this probably won't work. Typical PTPB's are not designed to recharge its own batteries and pass through enough power to continuously power its client .

That is PTPB's have enough stored energy to charge the client's batteries and once the current to the client goes low enough, charge it's own batteries.

Hopefully, this will spark someone's imagination. eg. a TP4056 board that provides 5V@3A
 

ethan206

Reputable
Jul 27, 2018
138
1
4,695
1
Wait so what I'm gathering from all of this is that the X735 board I linked above along with the case I linked above would both provide a safe shutdown correct? Technically I don't really need a UPS for my Pi, but I just want to avoid any random shutdowns that could lead to data loss or OS corruption in which a UPS would be able to provide that but I really just need a little bit of power for my Pi to safely shut down in a scenario that the power goes out.

I do have a Portable charger that I could use as a power supply as you suggested, but I'm not sure if it supports power passthrough and I'm kind of looking for an all-in-one solution. Where everything is just inside the RPi case and I just need to connect a single USB-C cable to power it. Ideally, I would want to fit everything inside my current case hence why typical RPi UPSs with batteries don't really fit inside my case, but the X735 board does, and I know it's not a UPS, but if it supports safe shutdown (e.g. safely shutting down the Pi when my power randomly goes out), then that's all I need. I was also looking into the other case I linked above too and was considering that as well.
 

OldSurferDude

Commendable
May 18, 2019
89
13
1,565
18
... but I really just need a little bit of power for my Pi to safely shut down in a scenario that the power goes out.
Yup, that's right, and you need to trigger the X735 to start the shutdown sequence. Thus, the opto-isolator

I just thought of another gotcha and that problem needs to be solved even in the case of the UPS. You want the RPi to power back up when the power is restored.

On power down, you need, not only to shut down gracefully, but also remove power from the RPi. But you can't remove power until the shutdown has completed. Once the power returns, you need to reconnect the power to the RPi.

Think of it as a circuit that controls a relay with two inputs, one from the RPi and the other from the power supply of the PTPB. When the RPi Signal goes high for some number of seconds (it may glitch high on power up) the relay disconnects power from the RPi. When the input from the PTPB power supply goes high for some number of seconds (transients on the power line), it connects power to the RPi.

You could build such a circuit or you could program an Arduino Nano which draws power from the PTPB and could be powered down drawing much, much less than a milliamp) and still do the job.

There's almost a good solution here! Let's just use the RPi power supply and in parallel with a battery power supply. The power goes down and the RPi is running off the battery. Shutdown is triggered, then all power is removed from the RPi. When power returns, the RPi powers up from the RPi's power supply and the battery is put back into parallel.

Now the challenge is to design a circuit that allows the battery to actually be in parallel (a diode?) and also recharge the battery.

Of course, the battery has to supply 5V@3A, but only for a short period of time. (greater than 50mAh @ 5V) And there is just such a thing

more food for thought

OSD
 

ethan206

Reputable
Jul 27, 2018
138
1
4,695
1
Wait so, I would need an external UPS for this solution or is using the X735 board just fine? I've attached an image of what I'm planning to do below and if it accomplishes what I'm trying to describe which is to just get my Pi to safely shut down with a little bit of power when the power goes out.

View: https://imgur.com/a/LpsS6rZ


I'm planning to do Combination 1 above, so that wouldn't require any additional external UPS for a safe shutdown right? If the power goes out, there would be some limited "power" stored inside the X735 board that'll be able to send a shutdown signal to my Pi and shut down the system safely?

And also regarding this case (https://www.amazon.com/gp/product/B095YCL7S8/ref=ox_sc_act_title_10?smid=A3OWUO30LQJ1NE&psc=1), the X-C1 adapter board would not act the same as the X735 board right? It mentions that it supports safe shutdown but people are saying in the reviews/questions that for my specific use case, it wouldn't be able to do that.

And I'm not too experienced with building circuits and stuff, but you're saying I would need to remove power from the Pi? Would the X735 board take care of that? And I see where you're going at with the "switching" between the RPi Power supply and an external battery, but I'm heavily inexperienced with creating circuits and tinkering with electricity, so maybe I'll go to that as a last resort haha.
 

OldSurferDude

Commendable
May 18, 2019
89
13
1,565
18
A bit more reading yields the solution. On this page is the question:

11. Does this supply safe shutdown when power is cut? Or just safe shutdown when power is constant and a signal switch is cut

  • A: Sorry, no, the X735 does not support safe shutdown when power is cut. Please consider X728 if you need this function.
So you really want the X728 with AUTO ON enabled.

Done. If it will fit in your box.

Take-away. #1 Read as much of the documentation as you can find and it will probably help solve your problem.

Take-away #2. If you're going to get deeper into this stuff, you'll need to learn some basic electronics and soldering.

Thanks for introducing me to GeekWorm :)

PS be sure to get good 18650 batteries ( Newegg.com or fullbattery.com)
 

ASK THE COMMUNITY