Switching two batteries with DPDT relay

Hey All,

I feel like a mooch to be asking, but can anyone vett my schematic and tell me if I’m about to fry anything?

It’s meant to switch two 12v batteries between getting trickle charged by a PMW solar charger and running a load (and powering the Arduino itself.) A 5v DPDT relay makes the switch, which is triggered by a digital out through a 2n3904 transistor.

Will I need a capacitor to keep the Arduino going during the switch? Should there be diodes for any kind of hiccup when that happens?

Thanks hugely.

Perhaps you could connect the batteries together so that they are feeding in parallel during the change-over. There used to be make-before-break switchgear for this purpose, but I guess simple relays are a better solution these days.

Thanks for the suggestion!

I’m having trouble working out how to wire the batteries in parallel so that they’re not always bypassing the relay or without resorting to a second switch (should note that I don’t know much of anything about circuits.)

I went the capacitor route, though I don’t know if it’s much of an improvement (ignore the farad value.)


Why do you need to swap them, can't you charge and use at the same time?


I dunno--can I?

I guess I figured that since the charger breaks 'charging' and 'load' into discrete modes, I would need to take off everything during charging.

Any chance you could mock up a very basic idea of how that works?

I don't know exactly about just trickle charging, but every solar power system I've encountered just charges and uses at the same time, it's the net current into the batteries that counts.

We live on solar, I have panels and a generator plus of course we are using power all the time. If the batteries are getting low and the sun is not out I turn the gennie on and pay no attention to where the current goes. Probably some goes to the load and some to the batteries.

charger breaks 'charging' and 'load' into discrete modes

Not sure what that means, you normally have bulk, absorb and float.


Will I need a capacitor to keep the Arduino going during the switch?

Yes. The value will depend on how fast the switchover is.

Should there be diodes for any kind of hiccup when that happens?

No, but you DO need a diode across your relay coil, to kill the back EMF when you disconnect it. Otherwise the back EMF could fry your Arduino.

Much obliged for the helpful advice, thanks.

Greynomad, looking into it, I think my needs for the system differ enough from yours to warrant the relay. The controller seems to have difficulty dropping out of absorb with much timeliness, and especially with an inductive load (I've got a bilge pump firing intermittently.)
I won't be able to make many tweaks once it's running, so I think the only safe bet for total automation is swapping two batteries.

Henry, I added the diode to the coil--if you have any suggestions on how to minimize losses, I'd appreciate them.

You have to add a diode (3A one) and a large enough capacitor (ie. 2200uF/25V or even bigger) in there (see below), otherwise you risk the arduino may crash during the switch-over of the batteries… :wink:
The adding only the capacitor may not help you much as the capacitor may discharge itself through the “load” fast. So the diode will isolate the capacitor from discharging into the “load” and the capacitor will power the arduino for a while, hopefully :slight_smile:

sch.bmp (42.6 KB)

You may consider to connect the 7805 reg to the batteries permanently via 2 diodes, so the switch-over of the batteries will not crash the arduino. I would add a simple filter into the arduino’s power rail as the switching between the batteries with different voltages may cause pulses.
The 7805 requires two 100nF decoupling capacitors connected as close as possible to its pins.

BTW the recommended input voltage for arduino (when powered from the external power source) is 7V. How do you plan to connect the arduino to the “7805” in your schematics above? Do you want to connect the 5V from the 7805 to internal 5V rail (not to recommend…)?

Or, safer imho, would be to use a 7808 and feed the power into the standard arduino external source input (the barrel jack).
Or to use other voltage regulator which gives you 7V external power for arduino (for example a low-dropout one based on how minimal voltage the batteries can provide worst case).

Or, another variant is to feed arduino directly from the filter, into its standard external power input. I would prefer a pre-regulation with a 7V output fed into arduino’s external power input (double stabilization), when you plan the system for the upcoming Mars expedition… :slight_smile:

No warranties of any kind :slight_smile:


Hey Pito, sorry to be late responding--your fault for giving so many great options!

I'm probably going to go with the simpler one-diode-blocking-the-load route (your first suggestion), and switch to a 5808 (I should have looked up the Ar's operating voltage before assuming 5v) and feed it into the barrel jack (already loped off an old adaptor.) Will I still need the decoupling capacitors this way?

Haven't made any plans for Mars, but this will be inside an aquaponics system floating on something equally inhospitable to life: chlorinated pool water. :slight_smile:

Will I still need the decoupling capacitors this way?

Yes, you always need decoupling capacitors with 7808 voltage regulator, placed as close as possible to its pins.