Electronic – arduino – 5V Battery Backup Supply for GPS

arduinobackupbatteriesbattery-chargingraspberry pi

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 a LM7805 regulator to supply a constant 5v to a raspberry, however when I connect the output of the circuit to the raspberry and do the switching from main battery to backup battery the raspberry resets because it drops the voltage while switching the relay.

So my question is:

How I managed to do that switching without the raspberry rebooting?

I appreciate the help, I have been trying to solve this problem for two weeks now but I have not been able to yet.
Thank you very much.

enter image description here

Best Answer