I am making a UPS for WiFi Router. My goal is to get 12V uninterrupted power at the DC jack J2. The buck converter XL4015 is used to charge the 18650 battery pack ( 2S or 3S ) and boost converter XL4019 is used to boost the battery pack voltage to 12V.

Condition-1: When the AC mains is available

  1. The power from the DC adapter ( J1 ) is fed directly to the output jack (J2) through a Schottky diode (D1).
  2. The battery pack is charged by XL4015 converter.

Condition-2:When the AC mains is not available

The battery pack should feed power to the boost converter through the p-MOSFET ( IRF4095 ). The boost converter boost the voltage to 12V and fed to output jack J2 through the Schottky diode (D2)

Please guide me, whether this circuit will work as per my objective? Any changes for improvement in the MOSFET switching circuit are highly appreciated.