Simple Pi UPS with 2 batteries

14 posts
by paulv » Thu Aug 15, 2013 7:39 am
As a by-product of work around another project, a rather simple solution for an emergency power supply, or a simple UPS, emerged.
If you want to look at the development and the ups- and downs, go here: viewtopic.php?f=37&t=50470

Below is a sub-set of the project that allows a Pi to work for more than 4 hours (at 500mA) just of two Ni-MH 2700 mAh cells.
The 400-500mA is worse-case for a Pi model B with memory stick and WIFI adapter running a program 24/7.
Pi_UPS.png (36.37 KiB) Viewed 9745 times

If you want the details look at the other post, but in simple terms, this circuit automatically switches to battery back-up as soon as the main voltage drops off. If that returns, the circuit will switch back again. The LT-1302 converts the voltage of the cells (between 1.8 and 3V) to 5V. The Ni-MH cells are automatically maintained and re-charged with a small charge (C = 1/64). If you want to use normal Alkaline 1.5V AA or AAA batteries, don't install R3 and D3 or use a jumper, and you need to work out how long the charge will last.

If you connect a GPIO line as input to the junction of R10/R11, you can use this in your program to find out that the Pi is running off the UPS. Look at the other post for a program that does that, and more.

The switching between the two supplies is done with two Schottky diodes, and the higher value wins the battle. You need to make sure that the main supply is about 100mV or so higher, so the battery supply is simply in waiting for a lower value.
If you cannot change the main 5V supply voltage, attach the sense input from the LT-1302-5 to the anode of D1. This creates a lower voltage equal to the drop over the diode of 0.3V for the Pi. In that case, you may want to select a larger value for C2, to make sure the Pi does not get disturbed by the 0.3V voltage drop when the supplies switch.

You can also use the variable version of the LT-1302, in which case you can set the output voltage with a divider and a 10-turn pot. In that case, adjust the output of the LT to be 100mV lower than the 5V supply, and leave the sense line where it is in the diagram so it corrects for the voltage drop over D1.

The LT-1302 will not get warm at all at 500mA. Make sure you get a good coil L1 and a low ESR capacitor for C2. More information can be found in the spec sheet. One last word of caution, don't use a breadboard to play with this circuit, build it on a (universal or prototype) PCB and follow the layout recommendations in the specification. If you do that, the circuit is simple, works flawlessly and is easy to use.

Posts: 514
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands
by metaxas4 » Mon Sep 16, 2013 8:59 am
can I use this circuit with 4 batteries, 2-2 parallel for more hours?
Posts: 16
Joined: Mon Apr 01, 2013 9:57 am
by paulv » Mon Sep 16, 2013 10:05 am

If you charge the batteries in the circuit, all you need to do is to change the value of R3.

Depending on the capacity of your cells, you can easily calculate the value with the following formula.
Voltage V = VCC - V_Batt - V_Drop of D3 = 5.32 - (2 * 1.25) - 0.6 = 2.2 V
Charge Current I = Cell Capacity in mAH / Charge rate = 2700 / 75 = 36 mA
The charge rate (trickle charge or maintenance charge) is recommended to be between 64 and 100.
R3 = V / I = 2.2 / 36 * 1000 = 61 Ohm, I used 62 Ohm.

In your case, if you use the same 2700 mAh cells, but two sets in parallel, the Charge Current will become 2700 * 2 / 75 = 72 mA
And so R3 becomes 30 Ohm, and you can safely use 27 or 33 Ohm.

If you need to recharge the cells faster, change the charge rate.

Last edited by paulv on Tue Sep 17, 2013 10:20 am, edited 1 time in total.
Posts: 514
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands
by metaxas4 » Tue Sep 17, 2013 7:32 am
R3 i suppose you wanted to say! :)

Thanks, but I cannot find the IC you are using in my country.
Posts: 16
Joined: Mon Apr 01, 2013 9:57 am
by paulv » Tue Sep 17, 2013 10:28 am
Oops, I fixed it. Thank you.

You can order the LT1302 directly as a sample from the manufacturer, look on their website.
RS Electronics also have the part : ... ra=oss&r=t
Posts: 514
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands
by eried » Fri Oct 18, 2013 3:06 am
Awesome design!
My website:
User avatar
Posts: 82
Joined: Mon Apr 15, 2013 2:11 am
Location: Chile
by kehall » Mon Feb 03, 2014 7:39 pm
I have a problem with this not working as expected when under load...

I built this circuit and whilst the 5v from the AA batteries fundamentally works, I am having a problem where it's always drawing current from the batteries, even when +5v is present on the 'input'. (testing with a 450mA load) I can't see any error in the implementation of the circuit, but something is up somewhere!

Would appreciate any guidance...

Unloaded, input voltage 5.18v, battery voltage 2.6v (connected, float charging), output 5.15v
Unloaded, input voltage 0v, battery voltage 2.54v, output 4.99v

So you'd think all seems well, except it doesn't play ball under load ~450mA

Loaded, output voltage is 4.71v, battery voltage 1.65v, drawing 0.5A from batteries, regardless of whether input voltage is applied :/ Input voltage drops to 5.13v when under load.

When this load is present, there's a voltage drop over D2 of around 0.4v ??

Probably need more info but do you have any ideas what's up?

Posts: 26
Joined: Thu Dec 05, 2013 9:52 pm
by paulv » Mon Feb 03, 2014 7:59 pm

A few questions.
Did you use a perf board or "proper" pcb, or do you use a prototyping board?
The connections to the LT matter a lot, and oscillation can happen at a very high frequency.
When I tried a protoboard, I could not get it to work properly, the chip was getting hot too.
As soon as I went to a perf board with very short connections (look at the datasheet), it worked perfectly, and the chip did not get hot anymore.
The cap at the output must be low ESR.
Did you use the recommended inductor?
Posts: 514
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands
by kehall » Mon Feb 03, 2014 9:48 pm
Thanks for the response...

Soldered to veroboard, everything as tight as possible (fit entire cct to 5 rows x 20), C2 cap 0.35ohm ESR Panasonic FC series (low ESR). Used this coil ( There is a fair ripple (230mV p-p). Chip not even warm.

Unless the ESR is still too high, I guess the other issue is really since my input isn't high enough due to drop on D2? So I've wired SENS to anode of D2 as suggested and this improves things somewhat, with the exception of no-load "runaway", output voltage increases to 22V without load when input voltage is absent due to lack of feedback... Interesting how it copes without feedback though when it does have a load!

I can try locating a lower ESR cap but without the feedback, any suggestions or pitfalls in using a zener or something to limit output (or get feedback from output again if switched to battery)? In theory it should always be connected to a load but I can imagine times when it could be disconnected/reconnected, not sure how happy Pi would be with a 22V spike!

Thanks again, Keith
Posts: 26
Joined: Thu Dec 05, 2013 9:52 pm
by paulv » Tue Feb 04, 2014 3:36 am
I agree, something seems not to be right.

My only advice at this moment is to look at the proposed circuit layout as per the datasheet.
When first I deviated (somewhat) from it, it would not work right either.
When I changed it again, while using veroboard, everything worked reliably and stable for more than 6 months 24X7 now.
Good luck!
Posts: 514
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands
by kehall » Tue Feb 04, 2014 4:57 pm
Thanks, will try to have a play around... After about 10 minutes on battery the chip temp rose to about 37deg C, but of course thats with feedback in an unsuitable position causing runaway, so I still need a method to use a standard 5v supply and not having it drawing from battery.

What make/model cap did you use for C2 and which 10uH coil, please?
Posts: 26
Joined: Thu Dec 05, 2013 9:52 pm
by paulv » Tue Feb 04, 2014 6:56 pm
I used Nichion low-ESR caps and Coilcraft DO3316-xxx coils as per datasheet.

Are you sure you are using the Lt1302-5 or do you have by any chance the variable output LT1302 ?
Just checking, since you have a run-away output...

As it so happens, I'm using the SO version in another circuit, and I'm having troubles to get the output regulated to where I want it. I'm using the published circuit from the datasheet but it gets stuck at 6-7V instead of the 10V I want. Sometimes it starts OK and goes to 10, most of the time, it doesn't. I'm using a potmeter to adjust the output, maybe that's not a great idea.

BTW, In the schematic that I published (which was part of a much bigger project) I used the LT1302-5 DIP version.
If you go to adafruit, they have a USB charger (the Mintyboost) that uses the same chip, that's how I found it.

See if that sheds some more light...sorry I can't help you much further. :oops:
Posts: 514
Joined: Tue Jan 15, 2013 12:10 pm
Location: Netherlands
by kehall » Tue Feb 04, 2014 9:31 pm
I'm using the 8pin DIP LT1302-5 full part number LT1302CN8-5#PBF
Struggling to locate non-SMD coilcraft DO3316 but will keep looking.

Looking at the mintyboost kit, the coil there is HUGE compared to the one I have which is about half the width and height of the IC!

I think I'm going to have to mess quite a bit, I'd love to be able to somehow check for low battery condition too (via another GPIO pin), so that it gives the option to delay shutdown of the Pi until absolutely necessary.

Many thanks again.
Posts: 26
Joined: Thu Dec 05, 2013 9:52 pm
by Cosa » Tue Apr 29, 2014 1:40 pm

would this be the way to go if i used the adjustable model of the LT1302?

circuit.png (13.62 KiB) Viewed 5040 times

Thanks in advance!
Posts: 1
Joined: Tue Apr 15, 2014 9:50 pm