Electronic – RPI with power supply alternating between Li-ion battery pack and DC 5V

batteriesdc/dc converterraspberry pitransistors

I have a Raspberry Pi model B+ and I've been trying to design a solution so that I can switch power supply without having to shutdown.

The idea is this:
I have 2 li-ion 18650 batteries with protection board(DW01+) which disconnects the batteries when they reach a lower threshold of 2.4V and an upper threshold of 4.3V. I want to connect those in parallel to a step-up power converter (mt3608) which will give a steady output of 5V to power the Raspberry Pi.

I also have a charger circuit TP4056 which can supply up to a maximum of 1 Amp that I want to connect to the battery pack. The Pi requires around 0.56 A and 5V with a few peripherals connected but I want to supply extra power for whenever it might need it.

When I have access to an electric outlet I want the battery pack to be disconnected and the Pi powered with a 5V 2.1 Amp DC adapter. I want it to power the Pi and at the same time charge the battery pack and if I disconnect the DC adapter it should switch back to running of the battery pack again without the need to shutdown first. The reason for this is that I want to use the full capacity of the charging circuit to charge the batteries and because I haven't found a suitable charger that can supply a higher current than 1 Amp.

Is it possible to do this with mosfet transistors to switch on and off the inputs?
I thought of using a relay to switch between the power supplies but that's too slow and would require a big capacitor as I understand it. Every solution I can think of seems to require a diode but that would lower the voltage below the threshold for what the Raspberry Pi accepts. I should also add that my knowledge of electronics is a bit limited.

Edit:
This schematic is far from pretty but maybe it helps to show how I want to connect things. I put two transistors in the schematic but part of the problem is that I don't know where I should connect the gates.
enter image description here

Edit 2: Added clarification about the batteries, the power converter and about my goal.

Best Answer

It seems you are making this overly complicated. Have the battery power the Pi always. When you have wall power available, it powers the battery charger. During that time the battery is getting charged since presumably the charger produces more current than the Pi draws. If not, get a different charger.

Nothing needs to be specifically switched. Whether the battery is being charged or not, either way the battey voltage is used to run the Pi.