X
Home & Office
Why you can trust ZDNET : ZDNET independently tests and researches products to bring you our best recommendations and advice. When you buy through our links, we may earn a commission. Our process

'ZDNET Recommends': What exactly does it mean?

ZDNET's recommendations are based on many hours of testing, research, and comparison shopping. We gather data from the best available sources, including vendor and retailer listings as well as other relevant and independent reviews sites. And we pore over customer reviews to find out what matters to real people who already own and use the products and services we’re assessing.

When you click through from our site to a retailer and buy a product or service, we may earn affiliate commissions. This helps support our work, but does not affect what we cover or how, and it does not affect the price you pay. Neither ZDNET nor the author are compensated for these independent reviews. Indeed, we follow strict guidelines that ensure our editorial content is never influenced by advertisers.

ZDNET's editorial team writes on behalf of you, our reader. Our goal is to deliver the most accurate information and the most knowledgeable advice possible in order to help you make smarter buying decisions on tech gear and a wide array of products and services. Our editors thoroughly review and fact-check every article to ensure that our content meets the highest standards. If we have made an error or published misleading information, we will correct or clarify the article. If you see inaccuracies in our content, please report the mistake via this form.

Close

How to add a UPS to your Raspberry Pi projects (and do it on the cheap)

Want your Raspberry Pi to carry on running when the power goes out? You need an uninterruptible power supply. Here's how to add one.
Written by Adrian Kingsley-Hughes, Senior Contributing Editor
Raspberry Pi fitted with a UPS

Raspberry Pi fitted with a UPS

Adrian Kingsley-Hughes/ZDNET

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?

Also: The best portable power stations you can buy

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)

View at Amazon

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) 

Also: Finding Raspberry Pi: Where to buy the latest model and its alternatives

Note: I've also used the GeeekPi UPS HAT, which offers similar functionality but uses micro USB, which charges at a slower rate than the Waveshare board at a similar price.

The Waveshare UPS HAT (B) fits onto the bottom of the Raspberry Pi. 

OK, got all the bits, so I'm ready to go.

All the bits I needed to fit a UPS

All the bits I needed to fit a UPS

Adrian Kingsley-Hughes/ZDNET

And I'm not going to be put off by the typo on the battery charger!

Typo on charger reads "Batter charger"

"Batter" charger

Adrian Kingsley-Hughes/ZDNET

The HAT connects to the Raspberry Pi using pogo pins that press onto the underside of the GPIO pins.

Pogo pins connect the HAT to the Raspberry Pi

Pogo pins connect the HAT to the Raspberry Pi

Adrian Kingsley-Hughes/ZDNET

OK, here are the assembly instructions.

1. Fit the spacers

Fitting the spacers
Adrian Kingsley-Hughes/ZDNET

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

Joining the HAT and Raspberry Pi
Adrian Kingsley-Hughes/ZDNET

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. 

Making my screwdriver bit magnetic makes fitting the screws a lot easier!

Making my screwdriver bit magnetic makes fitting the screws a lot easier!

Adrian Kingsley-Hughes/ZDNET

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.

Check the alignment of the pogo pins against the GPIO pins
Adrian Kingsley-Hughes/ZDNET

3. Fit the batteries

Make sure to get the polarity right!
Adrian Kingsley-Hughes/ZDNET

Make sure to get the polarity right.

4. Fit the battery cover

Attaching the battery cover
Adrian Kingsley-Hughes/ZDNET

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

The Raspberry Pi and UPS HAT work!
Adrian Kingsley-Hughes/ZDNET

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!)

Don't want to use HAT? Here's another way

OK, while a HAT is the most convenient and reliable way to set up a UPS for a Raspberry Pi, there is another option: use a power bank.

You can use the power bank to power the Raspberry Pi, and connect the power bank to a charger to keep it topped up.

Also: These are my 3 must-have Raspberry Pi accessories

Unfortunately, you can't use just any power bank. The power bank has to support a feature called pass-through charging. This is the feature that allows the power bank to be simultaneously charged while charging a device.

Not all power banks support this, but power banks from Zendure, Goal Zero, Omni, and Renology support this feature, and offer much greater backup capacity than two 18650 rechargeable batteries can provide.

Also: The 5 best portable power banks: Keep your devices juiced on the go

Another alternative is to use a power station, from makers such as Jackery or Bluetti. All power stations I've tested support pass-through charging.

Editorial standards