Deploying an Internet-of-Things (IoT) project to production can involve various complex and unexpected problems, such as firmware updates, system reliability and many more. By using balenaCloud to deploy and manage your fleet, most of these headaches can be avoided. However, if your device loses power, there is very little we can do to ensure the device remains operating and online. With that in mind, I decided to investigate and test a few different methods you can use to help to protect your devices from low-quality power sources or even power outages.
An uninterruptible power supply (UPS) is a piece of equipment that provides power to your device, to ensure it continues to function during power instabilities and outages. In most applications, it is important that the device continues to operate at all times. Downtime can be expensive for businesses and improper system shutdowns can harm the hardware and corrupt SD cards.
The Most Feature Rich - and my personal favorite!
The PiJuice is a HAT for the balenaFin or Raspberry Pi developed by the guys at PiSuppy that was funded on Kickstarter back in 2015 and raised over 1200% of the target amount.
The HAT comes with a Motorola BP7X 1820mAh battery, which will keep your device running for a few hours depending on the project. If your system needs more juice, you can swap the battery to another one with higher capacity, PiSupply offer batteries with a capacity of up to 12Ah for power-hungry projects or long run-time requirements.
The board comes packed with many features, one of them being a real-time clock (RTC) chip that communicates with the Pi and ensures the device never loses track of time. Another useful feature is the presence of an STM32-F0 microcontroller that can communicate with the Raspberry Pi and offers smart power management, allowing you to trigger a soft-shutdown or even turn your device back ON when power is restored.
The PiJuice will use five GPIO pins from the device (Power and I2C) and will allow you to communicate with the battery management system via I2C, to make your project even more robust. If you would like to know more about the PiJuice, you can check the official documentation here, with hardware and software examples plus much more.
Sold! Where do I get one?
You can buy the PiJuice board from the PiSupply website at https://uk.pi-supply.com/products/pijuice-standard for £47.99, or around US$63.
18650 Battery Shield
The cheapest one of them all!
There are cases where the PiJuice is much more than you actually need and all you are looking for is a simple UPS system that can run the device during power oscillation or outages. With that in mind, we tested the 18650 Battery Shield from DIY MORE.
The system works just like a USB Battery Pack, with one micro USB port that you use to charge the battery and a USB Type A to charge your device.
Besides the USB ports, the device also has multiple 5V and 3V3 connections that you can solder to the board for extra power output.
Note that the amount of time the device can keep operating depends on the size of the battery and how much power the entire system requires. Pidramble made a power consumption benchmarks for different Pi devices. With the information from the benchmarks you can then decide which is the right battery size for your needs.
The board costs US$2.99 (less than a cup of coffee in most places) but you still need to buy an 18650 battery, which you can get for around US$5.
After some research, we found that there are other alternatives for uninterruptible power supply hardware that you can use with your device. Keep in mind that we haven't tested them ourselves, but would be interested to hear what you think of them in our forums
Apio Pi Saver
The Apio Pi Saver board uses a Maxwell Supercapacitor (50F 2V7) to save your device during power oscillations and has enough juice to keep your device running for almost a minute, which should be enough time to shut down the Raspberry Pi and maintain data integrity.
The advantage of using a supercapacitor in a UPS system is that the energy is stored electrostatically instead of electrochemically, which means that they don’t lose storage capacity over time. They usually take just a few seconds to charge
You can find more information at www.saveyourpi.com, and it can be yours for €64,90 or around US$73.
UPS PIco - Uninterruptible Power Supply (HV3.0B+)
The UPS PIco is another Raspberry Pi UPS HAT with similar functionality to the PiJuice. The HAT includes a microcontroller that can automatically shut-down your device during a power failure and can be set to automatically monitor and reboot it once the power has been restored.
You can buy it from modmypi.com for £31.99 or about US$42.
The Pi-Zero-UpTime was designed to use one 14500 Li-Ion battery and has the perfect form factor to be used with a Raspberry Pi Zero, but also work with all other Pi variants or even an Asus Tinker board.
The board is sold for US$29.95 from TINDIE.
The Pi-UpTime UPS was designed to use two 18650 batteries. The board works in conjunction with a Python script that can shut down the device once the battery levels are critically low. You can check more about this board on TINDIE, where you can also purchase it for US$49.99.
UGEEK UPS HAT
The UGEEK UPS HAT is a Raspberry Pi HAT that contains a 2500mAh 3.7v Lithium Battery. It can be powered from a 5V power supply and like most boards reviewed here, can be programmed to turn off the device at low power.
For more information check the aliexpress sellers page, where you can get the HAT for €20.80 or about US$24.
Using a UPS system to keep your device up and running is very important when powered from an unstable source or if your application can't tolerate disconnections. Besides keeping the system online, it can also prevent data-loss, storage corruption and enable a clean shutdown in the case of complete power failure.
In this post, we reviewed a few UPS hardware that you can use on your future projects. In the next post, we will do an in-depth review of the PiJuice. Stay tuned!
Thanks for reading! We hope this article was helpful and that your next application will be as stable against power outages as it can be. If this post has raised any questions or you'd like share your thoughts, please join us in our forums, on Twitter @balena_io, on Instagram @balena_io or on Facebook.
Until next time!