Page 1 of 1

Posted: Wed Dec 26, 2012 7:11 pm
This is the first time I created a circuit diagram, so bear with me

I want to use the Pi embedded with a large battery, but want to switch automatically between battery operation and mains operation with battery charging. The battery is one of those powerbanks for phones and tablets which has both a 5V input (micro USB) and output (USB A).

I came up with the following diagram:

(see post further down for reposted schematics)

What should happen is: The Pi is powered by the battery while the adapter is not plugged in and relay REL1 is in sleep(?) mode. Once the adapter is plugged in it starts to charge the battery and activates REL1 so the power to the Pi is switched from Battery to Adapter. To prevent the Pi lose power in the small time the relay travels between states I added capacitor C1 with an as yet unknown value.

The questions:
1 - Will this work, and if so
2 - What value should the capacitor have if the power consumption of the Pi plus peripherals will not exceed 1A?

### Re: Automatic Battery-Adapter switching circuit

Posted: Wed Dec 26, 2012 7:29 pm
It should work ...
Provided the battery has separate 5v In and 5v Out - and in fact that the battery has its own charging circuit built in, and a DC-DC converter to make sure the output is really 5v
Which may mean it already does what you want!

As for the capacitor ...
Assuming the relay could take 10ms to switch, and you want the cap to provide 1A during that time while keeping the voltage within 0.25v of the nominal 5v ...

C = It/v

1 * 0.01 / 0.25 = 0.04F or 40,000uF

### Re: Automatic Battery-Adapter switching circuit

Posted: Wed Dec 26, 2012 7:58 pm
Burngate wrote:It should work ...
Provided the battery has separate 5v In and 5v Out - and in fact that the battery has its own charging circuit built in, and a DC-DC converter to make sure the output is really 5v
Which may mean it already does what you want!
Yes, it has both of them. The output will automatically shut off after 15 seconds when charging begins. I've no idea though whether it's safe to connect the adapter to both the input and the output of the battery and the Pi all at the same time. If that's safe the relay and capacitor are not necessary.
Burngate wrote:As for the capacitor ...
Assuming the relay could take 10ms to switch, and you want the cap to provide 1A during that time while keeping the voltage within 0.25v of the nominal 5v ...

C = It/v

1 * 0.01 / 0.25 = 0.04F or 40,000uF
OK, thanks. Those buggers seem to have the same price as the Pi

### Re: Automatic Battery-Adapter switching circuit

Posted: Thu Dec 27, 2012 10:40 am
poing wrote:The output will automatically shut off after 15 seconds when charging begins.
That's rather clever - but a tad irritating!
poing wrote:I've no idea though whether it's safe to connect the adapter to both the input and the output of the battery and the Pi all at the same time
Probably not!
If it sees its own output on its input it may think it's being charged and shut off its output, which would stop it charging, so it would switch its output back on which ....

I'd go with the relay - unless you can come up with some way to use transistors for switching ...

### Re: Automatic Battery-Adapter switching circuit

Posted: Fri Dec 28, 2012 11:58 am
Well, the output is only switched on when you press a button so it will not charge itself longer than 15 seconds or so. And the output is max 3A while the input is max 1.5A. Still I'd be uncomfortable shorting a battery this way. The need to press the button to start using the output makes the setup semi-automatic of course, but I can live with pressing a button before pulling the adapter out of the wall socket.

Hmm, I've been thinking about transistors but can't come up with a circuit just yet although I've not given up

In the mean time I thought of diodes, like this:

That would be simpler than the relay circuit and without mechanical parts. I happen to have a strip of 50 diodes that have a max current of 200mA, so I think it would be possible to replace diodes D1 and D2 each by 5 parallel diodes of the kind I have lying around for a total max current of 1A. Correct? (not the most elegant solution but the cheapest option at this point).

### Re: Automatic Battery-Adapter switching circuit

Posted: Fri Dec 28, 2012 12:12 pm
That won't work either. With the battery and the power supply both at 5V, current will flow through both diodes. (Your battery will have to keep charging, which might reduce its life.)

Also the diodes drop around 0.6V (or less if you use schottky diodes) so you'd need a bit more than 5V.

One thing that might work is: have a DC-DC converter just before the raspi, producing 5V,

then feed this with two diodes as you've shown,

then make the battery 6-7V and the power supply 7-8V.

At least I think. (I can't draw a circuit right now.) And of course that only works if you have a DC-DC converter, AND a 6-7V battery unit. But if building from scratch that's what I'd try.

Also I don't like the "parallel diodes on one line" idea - alright if they're all identical, but if not one might pass excess current. Probably OK for doing some short-term testing though.

### Re: Automatic Battery-Adapter switching circuit

Posted: Fri Dec 28, 2012 12:17 pm
poing wrote:
In the mean time I thought of diodes, like this:

That would be simpler than the relay circuit and without mechanical parts. I happen to have a strip of 50 diodes that have a max current of 200mA, so I think it would be possible to replace diodes D1 and D2 each by 5 parallel diodes of the kind I have lying around for a total max current of 1A. Correct? (not the most elegant solution but the cheapest option at this point).
Not going to work... 2 reasons:
1st there will be 0.7V drop across the diodes ->4V3 to the RPi
2nd (and this is the good one) should you be drawing a lot of current and one diode is taking more than its share of the load (very very likely to be the case), that diode blows, leaving the rest to take up the slack. Meaning that there is another diode right in the firing line. The word that best describes the result is Brrrap!

For diode mixing you would want a battery pack outputting 5V45 ~ 5V7 and a PSU that is 0V1 higher than that (limited to 5V95).

### Re: Automatic Battery-Adapter switching circuit

Posted: Fri Dec 28, 2012 12:27 pm
OK, good points , although:
Ravenous wrote:With the battery and the power supply both at 5V, current will flow through both diodes. (Your battery will have to keep charging, which might reduce its life.)
will not matter that much as the battery output switches off about 15 seconds after 5V is placed on the charging input. But the voltage drop is the real killer of course, as the voltage right out of the battery is just perfect for the Pi.
Ravenous wrote:That won't work either.
Why do you say that, do you think the circuit with the relay won't work?

### Re: Automatic Battery-Adapter switching circuit

Posted: Fri Dec 28, 2012 1:05 pm
poing wrote: Why do you say that, do you think the circuit with the relay won't work?
Ah no I didn't mean that. I meant the diode switching. But as you say, if the battery's controller is smart enough to stop charging itself, then the two diode arrangement probably will work.

EDIT: subject of course to the voltage drop across the diodes that is. There must be a circuit somewhere to do this cleanly without using relays and big capacitors and things... though I suspect more components, like DC-DC converters, will be involved again.

### Re: Automatic Battery-Adapter switching circuit

Posted: Sat Jan 05, 2013 11:26 am
poing wrote:
Happy to say the above method works; I received a bunch of 10,000uF capacitors yesterday thinking I'd add capacity until I reached the right value. The first try was immediately successful, meaning the Pi with only Ethernet and HDMI attached survived numerous changes between battery and adapter, even several times a second, using a single 10,000uF capacitor. Of course this was only using around 350 mA (while the design goal was 1A max) and I'll have to see if added peripherals make more 10,000uF capacitors necessary.

### Re: Automatic Battery-Adapter switching circuit

Posted: Fri Feb 08, 2013 6:04 pm
Hi Poing, do you have a photo of the finished product, I'd really like to try and replicate this and am not that good at circuit diagrams! Also would it be possible to detect the state of the pi using the gpio ports(on battery/on mains)?? This is for a project I'm working on to monitor one of the rings on my supply which trips randomly.

Thanks for sharing, Kerry

### Re: Automatic Battery-Adapter switching circuit

Posted: Sat Feb 09, 2013 11:21 am
No photo; I tried it on a breadboard and later I broke it down to set up something else. Besides a photo of a finished board wouldn't tell much I imagine. The thing to do is get a breadboard an just follow the diagram, it's not that hard.

It should be easily possible to detect which power source has actual 5V connected. I'd look at early issues of the MagPi to see how that is done.

Good luck

### Re: Automatic Battery-Adapter switching circuit

Posted: Sun Feb 10, 2013 9:52 am
I would think that you could use the setup with the two diodes. The 'pi runs fine off 4.3V. On the other hand, you can get diodes with a smaller voltage drop. For example: http://nl.farnell.com/1467550

And although the nominal voltage of the powersupply and the battery are both 5V, they might be anywhere between 4.5 and 5.5V. So if they are near the top end of the range, a 0.3V drop doesn't matter and leaves you with plenty of "5V".

### Re: Automatic Battery-Adapter switching circuit

Posted: Fri Apr 24, 2015 9:33 am
Hi. Is there a circuit schematic for this? The image in the first post is broken.

### Re: Automatic Battery-Adapter switching circuit

Posted: Fri Apr 24, 2015 9:40 am
wizard2072 wrote:Hi. Is there a circuit schematic for this? The image in the first post is broken.
The site it refers to no longer exists, you are reacting to a two year old post.
"poing" is still around, maybe you could PM him.

### Re: Automatic Battery-Adapter switching circuit

Posted: Sat May 16, 2015 12:33 pm
Just read the request for the circuit image:
BatteryAdapterSwitchCircuit.jpg (50.51 KiB) Viewed 8361 times