5V UPS for Raspberry Pi
- 1 Classic UPS
- 2 Powerbanks
- 3 USB current and USB cables
- 4 How much current do you need?
- 5 Possible solutions for UPS / Battery types
- 6 Raspberry Pi Battery Hats (updated: 2019/11/30)
- 7 All in one UPS device for 12V
- 8 DC-DC Converter from 12V to 5V USB
- 9 Everything connected together
- 10 Battery monitoring
- 11 Router 12V backup
Using classic widely available UPS from any computer shop for back-up power for your Raspberry Pi might seem as a pretty good idea. Until you find out problems assigned with these cheap off-line UPS. One of the main problem is that some models last 50 minutes maximum (no matter how much battery is charged, it will power off after certain time amount). Second problem comes with double voltage conversion. Normally UPS use built-in 12V battery which is converted to 230V AC voltage (if you have UPS under low load there will be pretty high lost) and then 230V AC is converted with your Raspberry Pi adapter to 5V DC. So there are two conversions, time limit and most importantly cheaper UPS do not allow you to measure battery voltage (you may buy more expansive one and connect it to your Raspberry Pi with USB UART convertor. Considering these facts I do not recommend classic computer UPS
Advantages of classic UPS
- extremely easy to buy
- easy to connect and get working
- communication with Raspberry Pi (added 27.7.2017)
Disadvantages of classic UPS
- usually time limit
- high power lost due to double conversion
- no battery measurement in basic models
After a long term usage of my solution I found out that there are a few reasons why usage of UPS is most effecient. One of the reasons is that for example with APC UPS you can use USB serial cable connected to Raspberry Pi and UPS and detect status of voltage, status of battery and status of UPS - This is a huge benefit. 50 minutes maximum of UPS is valid also only for cheaper models, for example this is not a case in Smart-UPS models which you can buy for few dollars used on second hand market with cheap replacement battery (but be advised that serial RS232 cables for APC ups are special and more expansive than regular ones). Also there is a main advantage of classic UPS and it is that classic UPS is fully working product which you do not need to make neither maintain. It can be a fun to make your own UPS on the first time but after a few years when you need to change something it can be challenging to maintain it long-term.
Update: 27.7.2017 - UPS with charging ports
There seems to be a new version of UPS in market with USB charging port from APC. You can get it here from Amazon - http://a.co/0edDqK3
Using USB power banks as a cheap UPS might seems as good idea because they are widely available and more expensive ones (around 20USD) provide enough power (up to 2A) not only for Raspberry Pi but also for tablets and other devices. Main issue with power banks (I tried Xiaomi MI 10,000 mAh) is that they contain just one DC-DC power converter so you can either charge them or discharge them. With my power bank when I disconnected power supply from power bank suddenly resetted and stopped providing power for nearly 5 seconds so my Raspberry Pi went down. Not only that. I was suspicious that when powering output power bank was not charging itself properly.
Also there is an issue with capacity. Capacity 10,000mAh means capacity of LiPol 3.7Volts battery inside power bank. After DC-DC converting you will get capacity around half - 5,000mAh for 5Volts output. If your RPi is just with all accessories is just taking out 500mA per hour this power bank will last for 10 hours maximum which is not in all scenarios (e.g. security, automation systems) enough. Futhermore you cannot monitor power bank recharge status.
Advantages of Li-On batteries
- widely available
- very easy to connect
- reasonable price
Disadvantages of Li-On batteries
- does not works correctly as UPS
- low capacity
- does not report status of battery to RPI
USB current and USB cables
Firstly you should be aware of this. By specification USB 2.0 is able to provide only 500mA current but some devices (including RaspberryPi) might need more. For example RaspberryPi model B+ needs 700mA for itself + connected devices, total up to 2,000mA. Some tablets needs 2A and new Apple iPad needs if my information is correct 3A.
Unfortunately not all power supplies and power banks are able to provide that much power. You can buy some cheap Li-On UPS for 500mA from Adafruit (e.g. PowerBoost 500 Charger - Rechargeable 5V Lipo USB Boost) but they won't be able to provide enough current for your RaspberryPi with all accesories which might use as much as 2A. Not only that - some cables has high impedance and are unable to transfer enough power for your device. For example devices with Belkin USB cable was charging only 400mA while with Samsung USB cable I was able to achieve charging speed up to 1,000mA with same charger.
How much current do you need?
It is sometimes difficult to determine how much current is your device using and how much current do you need. Of course you can use multimeter but in case you do not want to buy two USB connectors and connect multimeter between them for example using breadboard I would recommend you using ready to use solution called CHARGER Doctor. You can buy it from China on E-Bay for approximately 2 USD including WorldWide shipping from many suppliers.
Possible solutions for UPS / Battery types
Although it initially seems that using Li-On batteries would be a great idea it turned out as a terrible idea. Main problem with Li-On batteries are that you need high current UPS device which I was unable to find out on the market (all devices are able to provide 1A current at most). So you would need for Li-On batteries to make your UPS completely yourself from one AC-DC converter (you will probably not be able to find 3.7V converter on the market so you will need to use AC-DC converter and than DC-DC converter), you also need a charger and step-up DC-DC converter to 5V volts. Li-On batteries also has an issue with explosiveness -so if you connect anything wrongly not mentioning relatively high price of them.
Because Li-On batteries are expansive and quality charging accessories are not on the market (that means you would have to build them yourself) I recommend usage of cheap Lead-Acid batteries. It is not difficult to buy your Lead-Acid battery in any hobby market for fraction of the price of Li-On battery (e.g. I bought in local store 12Volts 7Ah Lead-Acid battery for 15 USD). If you compare capacity of Lead-Acid and Li-On batteries please bear in mind they have different voltage. So If you get Li-On battery with 10,000mAh on 3.7V in the end on 5V you will get approximately 5,000mAh. But if you get a Lead-Acid battery with 7,000mAh on 12V in the end on 5V you will get 14,000mAh. So triple capacity at one third price.
If you need some more info about Lead-Acid batteries please read Wikipedia article Lead–acid battery
Advantages of Lead-Acid batteries
- widely available
- easy to buy good charging accessories
- very good price
- nice capacity
Disadvantages of Lead-Acid batteries
- high weight
- lower lifetime
- larger size
Raspberry Pi Battery Hats (updated: 2019/11/30)
On the market become available many Raspberry Pi Hats like Pi Juice for around 50 USD. You can also obtain many hats from AliExpress. There have few advantages and disadvantages, lets look.
Also if you use Raspberry Pi Zero you can use UPS-Lite for Raspberry Pi Zero for around 20 USD from Tindie.
Advantages of Raspberry Pi battery hats
- Done for exactly that purpose
- Small size
- Overall not so high price
Disadvantages of Raspberry Pi battery hats
- Low battery capacity
- Price per capacity ratio is not very favorable
All in one UPS device for 12V
Fortunately there are UPS devices for alarm/camera systems which you can buy for few dollars from AliExpress, just search for ups 12v output (example - updated 2019/Oct/16: 60W 12V 5A universal AC UPS/Charge function monitor switching power supply 13.8v, battery charger 2 year warranty (SC-60-12) for 10 USD)and looks for example these rated at 35W (these are the smallest possible but still more than enough for any USB device). I was able to buy one of these in Prague in local store called T-Led around 20USD personally. But you can get them directly from China to anywhere in the world for around same price including shipping. The UPS power supply I bought has 110-230V AC input and two 12V outputs. One 12V output is for battery charging (0,5A) and second is for your DC-DC converter for USB (we will talk about this later). If you connect battery to UPS it would not automatically start but wait for power supply to be connected. Once power supply is connected it will start and if there is an outage it will automatically keep voltage without any downtime (tested, Raspberry Pi did not went down when I disconnected main power and it switched to battery supply). If you need a cold start (start from battery without any external power connected) there is a small button (unfortunately not external one) connected solely for this purpose.
From my measurements battery is usually disconnected when 11.5V in order to prevent damage and fully charged at 13.3V.
DC-DC Converter from 12V to 5V USB
At first it might seems as a good idea to use power stabilizer but problem with this solution is that all difference (12V-5V = 7V) would be converted implicitly to heat. So not only you would need to have some cooler but also a lot of power from battery would be lost without any usage. This is a reason why usage of DC-DC power converter is recommended. DC-DC converter has one large advantage specifically low power lose and high efficiency. If you put 12V at 2A to input you will likely get minimally 5V at 4A. One disadvantage of DC-DC converter is price which is slightly higher than using stabilizer but still pretty low if you buy it on Ebay.com. Just try to search for DC-DC step-down buck converter 5V USB 3A (or 2A of your choice) and you should get some for as low as 2-3 USD.
Advantages of DC/DC converter from 12V to 5V
- affordable price
- high efficiency
- available on international stores
- higher price than stabilizer
Everything connected together
You necessarily does not need to do any soldering or use any breadboard or circuit board. All components can be bought on E-Bay or Aliexpress together for price lower than 50 USD and everything you just need to do is connect all cables properly. For this reason there is a simple diagram how to connect it. Colors of wires are type used in EU - in your country it might be different. In any case you connect everything at your own risk and I am not responsible for any misuse or damage caused by my diagram.
If you need to monitor battery voltage and charging, please see my article about AD Converter PCF8591 for Raspberry Pi
Router 12V backup
One of my reader found this MiniUPS which can be found around 20 USD on AliExpress under name "12V2A 22.2W UPS Uninterrupted Power Supply Backup Power Mini Battery for Camera Router High Quality". Try it if you think it will works for you