I'm trying to build an arduino based basic circuit that needs a battery backup. I have a 12V supply that is not reliable.

I have a boost buck converter with current limiting and voltage adjustment pots. Can I install it to output 3.6V at 1A max (battery specs for charging), have it directly connected to the battery and have arduino monitor the battery voltage continuously so I can cut off charging using a mosfet or relay at something like 3.4V to be on the safe side.

And then I am planning to add 2 schottky diodes at the output of battery and my 12V input, connect them together and add another regulator to 3.3V to drive arduino. I assume this will ensure that if the 12V supply is present, it will not discharge battery in any way but in case of a power outage, the battery diode will forward bias and supply the necessary current.

Basically something like this:

enter image description here

The regulator modules have their own Schottky diodes and filtering capacitors so I'm mostly concerned if this is an appropriate solution? I could not find a decent charger IC module for the battery here in my country so this is what I came up with.

I'd probably have a relay into the battery charger defaulting to off state and trigger charging if I sense the battery voltage is lower than a threshold. The battery has a BMS too so I guess it will protect from overcharge and discharge even if I do not do that.

  • \$\begingroup\$ Have you researched into what LiPo batteries need for a charging regime? Do you know how dangerous it might be not to follow that regime? \$\endgroup\$
    – Andy aka
    Apr 9, 2023 at 12:25
  • \$\begingroup\$ @Andyaka I did read a lot of documentation and the spec sheet of this battery but to be honest it looks like the thing is basically "Use CC at a rate conforming to the battery spec and then switch to CV at the end, supplying 3.60 in case of LiFePo4 single cell and then cut off charging if current draw is less than whatever spec says (300mA for my cell)." Now the regulator module I have handles CC and switching to CV. I can control cut off at the end using arduino. Anything else I might be missing? I can be out of my depth here so if my assumptions are wrong, I'd skip doing this entirely. \$\endgroup\$
    – Ekin Koc
    Apr 9, 2023 at 12:34
  • \$\begingroup\$ Have you checked if your 3.6V 1A regulator takes some current back from the battery/cell? \$\endgroup\$ Apr 17, 2023 at 20:59
  • \$\begingroup\$ Did you see my answer, and could it be the solution you need? \$\endgroup\$ Apr 18, 2023 at 15:27

2 Answers 2


From what I know, it would be safe to leave the charging circuit connected to the cell, just set it to 3.4V and there will be no need to turn it off.
You will likely have a problem with your charger letting current flow backwards from the cell to the 12V side if the 12V side drops below 3.4V and/or has a path to ground (through a resistor, for example).
The charger itself might have significant quiescent current which it would draw from the cell once the 12V input drops too low or is removed.
enter image description here

Now, here is a quick schematic I came up with for your specific requirements:


simulate this circuit – Schematic created using CircuitLab

- The MOSFETs M1 and M3 are turned on when the 12V side is higher than the 3.3-3.4V side by the gate threshold voltage, providing zero voltage drop from the 3.4V charger to the cell and from the 3.3V regulator to the MCU. - The MOSFET M2 is turned off by the Q1 transistor which is turned on when the 3.3V regulator voltage is above 3V. The LED should be a white LED which needs about 2.7-2.8V to turn on. You could also use 2 red LEDs or a green LED and a 1N4148 diode, test them to get your desired voltage value. Together with 0.5-0.6V for the transistor base-emitter junction, this gives above 3V for its turn-on. LED is better here than a zener because it has a much sharper turn-on curve - its turn on voltage is not as dependent on the current running through it. - When the 3.3V regulator output drops below around 3.1V, the Q1 turns off and M2 turns on, allowing practically zero voltage drop from the cell to the MCU. - The cell voltage does not need to be regulated as it is fairly stable and perfectly matches the MCU voltage range AND because any regulator would just add a voltage drop to an already low voltage. Since the cell has its protection circuitry (BMS), it would be protected from being discharged too far.

This circuitry works in real-time and requires no pins for monitoring or control from the MCU. If you still want to use the MCU for this, I could modify it, but I don't see much need for it.
Some components may need to be tweaked.


Probably not.

Firstly, it depends on how safe you want to be. From a strict, this is a consumer product that I'm getting CE marked (or the equivalent for your country) then absolutely not, you'd never do something like that.

For a "this is working just for me and I can accept some risks" then maybe. It still depends on the size of the battery, where it's going to be, how flammable are the surroundings, and how readily can it be yeeted out a window. Do you plan on leaving the device operating unattended would be a big consideration for me.

Consider also the possibility for toxic fumes to be released from the battery, as well as the fire hazard. Please ensure that you properly understand the risks associated with charging, and poorly managing these batteries.

Ok, in terms of would that system actually work, I think the answer is probably not. The basic principle is sensible enough, the use of diodes to quickly swap from one supply to other works well.
Ensure you have enough capacitance after the diodes to smooth out the switch, other wise you might get a brown out.

The regulator modules have their own Schottky diodes and filtering capacitors

This is true, but those diodes are probably for the regulator's switching function, and not for use in switching between different supplies. Add you own as needed. I would have big questions about what would happen to the output of the 3.3V regulator when its input drops from 12V to 4.2V as well.

You know about the need for CV and then CC charging as part of the battery's charging cycle. A regulator isn't going to do this very well at all. You'll need to find a regulator that voltage limits when it sees an over-current event. That is to say, it lower's its output voltage if the output would draw more than it's rated current. ManySome regulators would just cut their output, and hiccup until the overcurrent is removed. Or the current control might not be accurate enough, or have too much ripple, or else other issues

If you find a regulator that voltage limits, you will probably not get a good charge out of it. A battery charger is a current-driven device, that attempts to drive a current into the battery and controls the voltage accordingly, whereas a regulator simply increases the current until the set point is achieved. Once your battery has reached the CV voltage stage, a regulator might not actually drive any more current, as it'll see its output as having reached a suitable level.Unless the fine details between how a regulator handles its output, and the charging profile a given battery wants line up well, you might that you never actually fully charge the battery, only partially. It might work exactly how you want, but I'd be worried about it personally.

Personally, I would search again for a battery-charging IC. I would settle for a 500mA charge rate that I knew was going to safely and properly charge the battery, rather than using a regulator at 1A. You probably won't get a good charge like this, so you might as well have the IC for safety and reliability. Also, consider how often, and how long for, you expect the 12V rail to fail, and think about what that means for your circuit. Is it up 50% of the time or 5%? Does it fail once every now and again for a long time, or does it drop out often but only for a minute?

As a final note, consider replacing D1 with a solid-state relay, or a pair of MOSFETs (which is what they're made of). This could give you better on-state resistance, and less loss to the diode's forward voltage, but also gives you the switch you need. You should be able to make something latching so the Arduino can turn itself off if needed. Alternatively, you could do it all in hardware, and have some kind of monitoring system to turn it off for you.

  • \$\begingroup\$ "Many regulators" with hiccup mode limiting, seems like a bit of an overstatement to me; but they're certainly available in these ratings. More to the point, the current limiting is likely to be quite crude, whether among LDOs ("L"DOs being notorious for poor tolerance current limiting; HDOs would likely be fine here), or switchers (where not only may peak switch current be poorly controlled, but that's on top of ripple current). \$\endgroup\$ Apr 13, 2023 at 11:25
  • 1
    \$\begingroup\$ FYI, most secondary lithium chemistries only need a simple square load curve i.e. CC until CV. Once the battery reaches CV, current decays over time, naturally, through no action of the regulator (other than holding the voltage constant, as the name suggests). It reaches full charge when this current drops below the defined threshold. The 3rd-from-bottom paragraph seems erroneous, at least to my reading. \$\endgroup\$ Apr 13, 2023 at 11:27
  • \$\begingroup\$ @TimWilliams, these are good points and I've edited my answer. "many" is a bit unqualified, so "Some" seems like a better word. The 3rd paragraph was a bit too absolute, the point should be any disparity between charing profile and regulator output will lead to a poor charge. TY. \$\endgroup\$
    – LordTeddy
    Apr 13, 2023 at 14:41
  • \$\begingroup\$ Thanks a lot for the detailed answer. I ordered a powerbank module (IP2368) that can handle charging and discharging within lifepo4 parameters and since I will need to provide it a usb-c input, I will use a car socket charger with usb pd output as the first line regulator for my 12V input. I actually tested the current limiting regulator and it does decrease voltage to match the current limit. It is being sold as a battery charger but obviously does not have any smarts. Just doing cc/cv like a bench power supply. \$\endgroup\$
    – Ekin Koc
    Apr 13, 2023 at 15:20
  • \$\begingroup\$ I am also looking into having a supercapacitor array instead of batteries. My power outages are frequent but not long so it should be able to quickly absorb charge and provide backup power. Easier to work with and I assume safer but still need to do some reading into that. \$\endgroup\$
    – Ekin Koc
    Apr 13, 2023 at 15:23

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.