How to add a UPS to your Raspberry Pi projects
The Raspberry Pi needs little introduction. This single-board computer has become an essential tool for tinkerers, tech enthusiasts, and programmers.
But what happens when the power goes out?
I had a project where I needed a Raspberry Pi to run 24/7/365 with as high a level of uptime as possible. While power cuts are rare in my neck of the woods, they can happen. I needed to make my Pi resistant to such outages. I needed a UPS — short for uninterruptible power supply — a battery backup mechanism that kicks in when the power goes out.
Here’s the UPS I opted for: a Waveshare UPS HAT (B).
Waveshare UPS HAT (B) kit
The UPS HAT allows you to use two 18650 rechargeable batteries as a backup power supply for your Raspberry Pi. No soldering is required and you can still use the GPIO pins on the top of the Pi.
Waveshare UPS HAT (B) specs
- Compatible with Raspberry Pi 3, 3B+, and 4B
- Supports real-time monitoring of the battery voltage, current, power, and remaining capacity
- Multi-battery protection circuits offering overcharge/discharge protection, over current protection, short circuit protection, and reverse protection
- Onboard 5V regulator allowing for up to 5A continuous output
- 5V USB output
- Battery warning indicators
- Includes development resources and manual
- Requires 2x 18650 batteries (not included)
The Waveshare UPS HAT (B) fits onto the bottom of the Raspberry Pi.
OK, got all the bits, so I’m ready to go.
And I’m not going to be put off by the typo on the battery charger!
The HAT connects to the Raspberry Pi using pogo pins that press onto the underside of the GPIO pins.
OK, here are the assembly instructions.
1. Fit the spacers
Big spacers go on the battery side, shorter ones on the side that will face the Raspberry Pi.
2. Bring the Raspberry Pi and HAT together
Four flat-headed screws attach the Raspberry Pi to the HAT.
Notice how the pogo pins fit against the underside of the GPIO pins. The advantage? Not only is no soldering required, but you can still use the GPIO pins on the top of the Pi.
It’s a lot easier to tighten the screws if you have a magnetized screwdriver. I used a magnetizer/demagnetizer to make my screwdriver tip magnetic.
Tighten the screws holding the HAT down a little bit at a time, don’t just crank down on one screw then go to another because that will misalign the pogo pins.
When done, check the alignment of the pogo pins against the GPIO pins.
3. Fit the batteries
Make sure to get the polarity right.
4. Fit the battery cover
I used the domed screws to hold the cover in place. This prevents metal bits from falling into the battery compartment and possibly shorting things out.
5. Connect the power
All that’s left to do is connect the power to charge the batteries, and flip the power switch to turn on the Raspberry Pi. (Remember to fit a microSD card containing an operating system… I forgot!)
Read More: How to add a UPS to your Raspberry Pi projects