I needed solution to keep Raspberry PI B+ running in case of power loss. So made following power backup circuit: RPI_UPS

It works, however, when it runs from battery, a bit too much voltage is dropped in the circuit. Exact components are D2 and R3 which drops 0.3V each, so 0.6V in total. I would like to eliminate or decrease this drop. So far I found that in some cases MOSFET can be used in place of diode. But would like to ask how/if it can be done on this particular circuit? It is D2 which needs to be replaced. Also, any other suggestions to decrease voltage drop while running from battery are welcome. UBEC GND is connected before R3, because I do not want charging circuit to count in RPI load. It is so because if battery will be discharged and mains power will get back charge circuit will limit currency by decreasing voltage and I believe that running RPi at that decreased voltage will not be a good thing. Probably it will try start up, but will go down again, because charge circuit will lower voltage right away. Please correct me if I am wrong here. Also, I know that using higher voltage battery would be workaround, but would like to see if it can be done with 6V battery.

Final schematic V4 after suggestions: enter image description here

I built and tested circuit as it is shown here in V4 schematic. Battery voltage got down to about 5.8V before RPi power indicator started to blink. It happens because UBEC output goes below 5V when battery is almost flat (before replacing diode with MOSFET, same behaviour was with nearly full battery). Switching between 12V and battery works fine, however if battery is not fully charged, power LED blinks on RPi during switching, so this is where it can be improved by adding capacitor. However, it does not cause RPi to reboot or so. Also, switching is not noticeable if battery is fully charged. Only thing which I will probably do is try different UBEC or add cut-off circuit, because I do not like keep RPi running at state where LED is blinking. Thank you for helping with this circuit!

  • \$\begingroup\$ You'll want to google MOSFET ORing. \$\endgroup\$ Commented Oct 12, 2015 at 19:50
  • \$\begingroup\$ Thank you for right keyword! Will update circuit in case of success. \$\endgroup\$
    – Nerijus
    Commented Oct 12, 2015 at 19:55
  • \$\begingroup\$ Don't get me wrong, your question is fine; I've upvoted it. I just don't have the time to answer it in detail. Perhaps someone else does. \$\endgroup\$ Commented Oct 12, 2015 at 19:57
  • \$\begingroup\$ It is all good. And your comment is very useful. Just now I have next question: results I found uses ICs to control gate. That is not a big problem, but maybe it is possible to omit it by connecting gate somewhere in current circuit. \$\endgroup\$
    – Nerijus
    Commented Oct 12, 2015 at 20:05

1 Answer 1


You don't need any switching. Since it is an SLA battery, just run your load from the battery all the time. Let the LM317 keep the battery topped off through D1, or buy a 6V trickle-charger. Adjust the LM317 output until the battery float voltage is at an appropriate level (maybe around 6.5V or 6.6V, but look it up).

  • \$\begingroup\$ @WarrenYoung, for NiCd batteries a current source is a good tricle charge method. But for SLA, voltage float is much better. An SLA floated at the right voltage, if it is not discharged often, might easily last for 10 years. And a float voltage will also recharge it faster than a trickle current. For NiMh, trickle current is not recommended, but it will work for a while. For Lithium chemistries, when they are full, all charging must be terminated for safety (no float, and to trickle charge). \$\endgroup\$
    – user57037
    Commented Oct 12, 2015 at 22:07
  • \$\begingroup\$ I know this method and all is fine until battery is not completely discharged. Discharged battery will draw lot of current, therefore current must be limited. Battery datasheet says charge at 1.35A max. So at the point where battery is discharged and mains power will back, I will have lowered voltage at battery and it might not be sufficient to run UBEC/RPI properly. Another thing which I do not like is double regulator. Because in your suggested way voltage is dropped twice: at charging circuit and at UBEC. In case of LM317 on charging circuit it would be constantly hot. \$\endgroup\$
    – Nerijus
    Commented Oct 13, 2015 at 6:41
  • \$\begingroup\$ I don't really follow your objections. If your UBEC is going to get hot with a 6V battery supply, it is going to get even hotter with a 12V supply when mains is on. Anyway, all you need to do to get FET switching is replace D2 with a PMOS. Use the 12V supply to hold the PMOS gate high. When 12V supply drops to GND, PMOS will turn on and supply UBEC with 6V from battery. Make sure you have enough capacitance to hold up Vin to UBEC during the transition. Keep D1 and D3 as-is. Note that you want to connect the PMOS drain to UBEC and source to battery (this is kind of backwards to usual). \$\endgroup\$
    – user57037
    Commented Oct 13, 2015 at 7:54
  • \$\begingroup\$ UBEC is not getting hot. It is very efficient. But LM317 does. And I do not want RPi current would go through LM317 all the time. Also, thanks for instructions regarding the PMOS. I have updated question description with your suggestions. Is that correct? \$\endgroup\$
    – Nerijus
    Commented Oct 13, 2015 at 8:52
  • \$\begingroup\$ I see. In the switching setup, LM317 is only passing current during recharge, not 100% of the time. I thought UBEC was a linear regulator because it just shows "in" and "out," no magnetics. For the PMOS, you need to swap drain and source. My comment above was in error. The drain should be connected to battery, and source to UBEC. I suggest to use a symbol which explicitly shows the intrinsic diode between drain and source. We need the intrinsic diode to be reverse biased when 12V is present (otherwise 12V current will flow into 6V battery without regulation, even when FET is off). \$\endgroup\$
    – user57037
    Commented Oct 13, 2015 at 16:11

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.