I designed a circuit to do the switching from a 12V car battery to a 8.4V Li-Po battery with a relay. Both batteries go through an LM7805 regulator to supply a constant 5V to a Raspberry Pi.

When I connect the output of the circuit to the Raspberry Pi and do the switching from main battery to backup battery the Raspberry Pi resets because it drops the voltage while switching the relay.

How I can I switch sources without the Raspberry Pi rebooting?

enter image description here

  • 1
    \$\begingroup\$ use only one regulator ... move D5 and D6 to the regulator input \$\endgroup\$
    – jsotola
    Commented Apr 30, 2021 at 2:39

1 Answer 1


As @jsotola says, you should do the diode ORing before the regulator, not after it. With the diodes in the position shown, you're giving up some of the design margin on the RPi's supply voltage. Also, a 7805 is marginal for driving an RPi in the first place.

So, get a beefier regulator (preferably low dropout), put the diodes on its input side, and also add a significant amount1 of capacitance at the input to the regulator (after the diodes) so that it can "ride through" the switching time of the relay.

1 For example, if your RPi is drawing 1 A, the relay takes 10 ms to switch, and you can tolerate 3 V of drop at the regulator input, you would need about

$$C = \frac{i t}{\Delta V} = \frac{1A\times 10ms}{3V} = 3300 \mu F$$

More would be better.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.