Close

Raspberry Pi UPS with safe shutdown

A project log for Droidbot 07 - Wheeled-Quadruped

An ambitious mobile robot for testing my skills and learning new ones.

paul-crouchPaul Crouch 04/10/2019 at 23:400 Comments

It looks like I might finally have a functioning UPS. I say finally because it's taken way longer than planned due to both "technical difficulties" and resource availability. We're approaching exam season so my computer and bench are hijacked daily by the youngest of my offspring and I can't complain about that. This does, however, mean investigation of any technical difficulties spans weeks.

That's the excuses out of the way. Here's the short version of what happened:

"Wemo 18650 Battery Shield"
Twenty-third-time lucky?
UPS diagram (not showing GPIO potential divider!)

Still here? Here's some notes:

A "18650 Shield" is used to maintain power to the Raspberry Pi upon removal of the main power (e-stop) allowing safe shutdown after main power-off. It uses GPIOs to trigger the RPi to shutdown, waits for the RPi to signal it is (almost) complete before opening a relay to disconnect the UPS power and prevent deep discharge of the battery.

Arduino

3 - RPi_UP (DI), RPi GPIO output - high after boot, low just before complete shutdown.
2 - RPi_SD (DO), RPi GPIO input - active-high to trigger shutdown of RPi (through pot.div; 5V >> 3V3).
A0 - ADC to 18650 battery, 4V - disconnect load from battery when voltage drops.
4 - Main Power present/not present (DI).
5 - Keep alive/immediate select switch (DI)*
6 - Relay (DO) - active-high opto-isolated (N.O. contacts). Opens to disconnect battery.
7 - Amber UP LED
8 - Red SD LED
9 - Green MPP LED

*Mode selection input:
Keep alive = 0V   - waits until battery is low before shutting down and disconnecting.
Keep alive = N.C. - immediate safe shutdown and disconnect.

Raspberry Pi

RPi signals to UPS when it is up. UPS tells Pi to shutdown and waits for RPi_UP to go low before removing power.
RPi_UP=21       # GPIO output - high after boot, goes low a few seconds before complete shutdown.
RPi_SD=17       # GPIO input - active-high to trigger shutdown of RPi (through pot.div; 5V >> 3V3).

I might revisit this, to fix the low battery check, but for now...

Discussions