I am having an issue with my power supply. For my project I must power the Arduino (Uno R3 in my case) using batteries. I have opted to use 2 power bank batteries. I would like to use one battery to power the Arduino while the other battery charges. The software and coding is good. My issue is in the switching of the power supply. When my relays switch the supply battery, there is a split second where there is no power to the Arduino and the microcontroller turns off, causing it to restart and use the now depleted battery. A very simple circuit design showing the basic connections of the relay is in the picture below:
NOTE: the relays are the generic 5VDC coil modules you can find on amazon.
The two relays operating in the Blue boxes turn ON together, and the two relays in the Black box turn OFF together. This disconnects one battery from supplying the Arduino and connects it to its charger to start charging. The opposite happens on the other pair.
Things I have tried so far to avoid the cut off in power during switching:
Program the relays such that both batteries are connected and supplying power to the Arduino at the same time. I keep them operating together for a brief amount of time (i tried up to 5 seconds). Then turn off one battery so the power is not supplied from the other battery (kind of like a bridge so power is continuously provided to the microcontroller). For example, microcontroller draws 100mA from one battery, during switchover both batteries are providing 50mA each, then final switchover second battery provides 100mA)
This did NOT work. I connected an Amp meter to the battery that will be supplying power AFTER switching. Unfortunately, even when both relays are ON (connected to batteries) the second battery does not provide any current! The power banks have all kinds of safety features i guess (which is great) that prevent it from supplying current when another source is supplying.
So, what can I do to fix this issue?
I have done some research and found some suggestions:
Use a MOSFET relay? Not sure how this will solve the issue since the second battery (with its built in safety features) will require a brief moment of time to register that it should start supplying power.
Use passthrough power banks. I did this, and found out that if the power bank is initially low on power it can charge the batter AND and supply power to the Arduino with no issues at all. However, once the battery is fully topped up (due to the safety features) it will keep disconnecting itself from the charging cable, and once that happens the Arduino resets again. As long as the battery is fully charged and connected to the wall socket it will run the Arduino for less than a minute before restarting again and again etc.
Lastly, I read about connecting a Capacitor as this may help bridge the power supply gap for a moment. I have never done this so I dont know where to connect this capacitor, and how large should its capacitance be?
If there is any other suggestion/solution for this please let me know
Connecting the outputs of two power banks together is not a good idea.
The problem is that the output of most power banks is turned off if there is no load connected and who knows how long it take to come back on. So what you need to do before you do the switch is to use another relay to connect a dummy load to the power bank in order to get it turned on, and then disconnect the dummy load after the switch is done.
You will also need a super capacitor on the output to keep the voltage from drooping.
@ttommttomm
The switching could be done with just 2 SPDT relays and 2 small MOSFETS for switching the dummy loads. You will still need a super capacitor
We used to use a series diode in the output from each battery; whichever battery had the higher charge was the one being drawn from. The idea is, you can plug in the fully charged battery, and it will 'take over' powering the circuit, and after a few seconds the nearly depleted battery can be removed. No idea if this will work for your application, as mine was an old lighting/radio system powered from 12V automotive batteries.
Of course, you'll suffer the loss of voltage attendant from using a diode this way, but it might be tolerable.
@jim-p might have a comment or two about whether this would work in your application, I offer it up for discussion.
edit - I think in your case you'd want to use a Schottky diode, due to the lower Vf.
You could always store which is the active battery in EEPROM, and if the Arduino does reset you can read the EEPROM at start-up, to ensure that the correct battery gets used.
Use a large capacitor to act as a short term power supply.
No matter what you do, there will be a drop or spike as the relays change over, which may disrupt the Arduino.
as jim-p says, only 2 relays required, but supply stability is key.
"The switching could be done with just 2 SPDT relays and 2 small MOSFETS for switching the dummy loads. You will still need a super capacitor"
I tried the dummy load idea. It seems to work every now and then. I know it sounds weird, and it is, but it does NOT work consistently. I can use a dummy load to activate the power bank (and it does activate because i see the lights turn on). Once that happens I turn on the relay that powers the Arduino as well. So, now the newly activated power bank is powering the dummy load and in theory also powering the Arduino. My understanding is that at this point since 2 power banks are powering the Arduino and they share the output current equally ( for example 50mA from power bank A and 50mA from power bank B). Then when I turn off power bank A to charge, power bank B now supplied all 100mA current to the Arduino. As i mentioned this works but very
inconsistently. It will work for 1 or 2 cycles then reset (due to lack of power supply), then after resetting itself it will not cycle again (same code nothing changed). When it is not cycling the Arduino turns off at the switching of power bank A to power bank B, which tells me that although the dummy load is ON the current to power the Arduino is not always shared between the power banks. So I suppose that's when the super capacitor comes into play.
How many Farads should this capacitor be? Also, please correct me if im wrong, but I should use two super capacitors each one connected from the battery relay switch to the Arduino input? Please see diagram below capacitors highlighted in yellow for reference:
@camsysca and @JohnLincoln thank you both for the great ideas. However, if I understood you correctly, both of your solutions would cause the Arduino to lose power and reset. I am trying to avoid having to cut off power to the Arduino and resetting as i am recording data. That interruption cause a problem when analyzing the data since i will have to consolidated multiple data files into one. If there is no other way then I will explore these options!
No, when you use diodes to power route, the device being powered doesn't see disruption. That's the whole purpose.
Here's a random image, from Stack Exchange, to illustrate what I'm referring to:
In this case, the 3.3V battery powers the circuit until it discharges below the 3V point, at which time the 3V battery begins to power the circuit.
As I said before never do that. Only ONE power bank should be connected to the Arduino at a time.
Here is the set-up with two relays. Instead of the MOSFETS you can use relays
I have a 1F super capacitor
Well I have to say that it would be fairly expensive but depending on the current requirement of your Arduino device, it could be much smaller and cheaper