How to switch between two 5 V DC supplies?

Thread Starter

Marina Hanna

Joined Oct 30, 2015
For my project, I am using a solar panel to power a raspberry pi. The panel is connected to a charge regulator, which will connect to a battery. A DC-DC converter will convert the 12V from the battery to 5V (to power the raspberry pi). The charge regulator can also power the raspberry pi as it has a 5V usb outlet. From what I understand about the charge regulator is that it can still provide 5V even if the battery is fully charged, as long as the panels can provide sufficient power. Therefore, I want to implement a method to switch between the 5V from the charge regulator and the 5V from the DC-DC converter. I also want the 5V from the charge regulator to act as my main power supply such that when the voltage drops, the battery would power up the RPi, but when the voltage increases, the charge regulator would go back to supplying power.

I have been advised a multitude of things such as relays or transistors or diodes (although from my research it seems the voltage drop from a diode would not be ideal for my project). I have come up with a preliminary circuit design, but it does not work the way I want to, which is to say that when I lower the charge regulator voltage, I want the voltage to be 5V from the dc-dc converter. Instead, the voltage drops to 4.7V, which is too low for a Raspberry Pi.

Prelim Circuit.PNG

Am I perhaps using the wrong parts in this software or is my design completely wrong? If there's a better way of implementing this with relays, could someone help me with the design as I have never designed a circuit using relays before.


Joined Nov 4, 2015
not positive if this would work efficiently but, why don't you wire a program for your pi to calculate the voltage of your usb out put. If it drops below a certain voltage you could have it switch a SSR our regular relay to use your battery. Ir seems simpler to me. But what do I know :)

blocco a spirale

Joined Jun 18, 2008
At most, a pair of schottky diodes; one from the panel to the input of the DC-DC and one from the battery to the input of the DC-DC is all you need. Whichever has the highest voltage, panel or battery, will supply the load.

Since your DC-DC is dropping 7V the <0.45V forward voltage of the diode is not an issue.

But, I suspect that the 5V USB output from the charge regulator already does what you need, do you have the datasheet/ specification for it?
Last edited:


Joined Aug 1, 2013
A couple of problems. First, the LF411 is not a rail to rail opamp at either its inputs or output. With a total power supply of only 5 V the amp has only about 1 or 2 volts of input common mode range and output swing. This is not enough to turn your FETs either fully on or fully off.

Also, it is not clear what the FETs are trying to do, mainly because there is no overall circuit output marked on the schematic. Please show where the pi connects.


blocco a spirale

Joined Jun 18, 2008
The advantages stated in the application note are as follows:

"Power Switching Problems
Two problems are addressed. First, contact bounce effects can occur when the external source is connected and disconnected, resulting in power spikes, as shown in Figure 2. Second, the switching method can introduce a voltage drop, reducing efficiency and battery life."

Compared to a simple diode OR arrangement, how do these advantages apply to your particular application? Bearing in mind that diodes do not introduce switching noise and you have 7V of headroom to spare?

However, all this may be unnecessary; If you are using an off-the-shelf solar charge regulator, it will have a managed 12V output from which the USB 5V will also be derived.

If you then add another 5V DC-DC converter to the 12V output, you now have 2x 5V supplies that are essentially the same i.e. they are fed from the same source. So, there is no advantage in switching between them; just choose on or the other.
Last edited: