I'm attempting to design a circuit for some LED lighting that will be powered from a mains connected 24V DC transformer but if the power fails then the a battery should take over as the power source and automatically switch the LED lights on.

In the circuit below the idea is the LED light D1 is normally powered by V1. When V1 has power relay SW3 would switch from the position shown in the diagram and thus break the B1 circuit meaning D1 LED would be controlled by V1 and SW1. When V1 loses power SW3 would be in the position shown and the LED light would be powered by BAT1 and always on.

Is my analysis on the right track or is there a much simpler way to accomplish my goal? If I am on the right track what sort of relay should I be looking at for SW3?

enter image description here


Below is my revised attempt. The polarity on the SW1 terminals needs to be reversed. I don't think there's any need for a diode between the + terminals of BAT1 and V1 since they will only ever be connected if V1, the mains supply has failed in which case it will act as an open circuit. I think there is a problem with this new circuit in that the SW1 relay will always be off while SW2 is open and hence the LED will be lit by the battery. I need SW1 on even if SW2 is off.

enter image description here

  • \$\begingroup\$ What if you tell us the ultimate purpose of what you want to do? // V1 will NOT act as an open circuit when the mains fails. // You need much more than 100 ohm, with that LED, as we told you. \$\endgroup\$
    – Telaclavo
    May 23, 2012 at 13:46
  • \$\begingroup\$ Telaclavo said 1.1k\$\Omega\$, and I said 1k\$\Omega\$, and told you it's a 20mA LED. Why aren't you listening? Learn to read datasheets if you want to get your circuits working. \$\endgroup\$
    – stevenvh
    May 23, 2012 at 13:55
  • \$\begingroup\$ TBH I didn't even think about the resistor's value, 100 Ohms is the default value the circuit diagram tool put in. I'm focused on the general circuit design at this point rather than the component details. \$\endgroup\$
    – sipsorcery
    May 23, 2012 at 20:50

2 Answers 2


Your circuit is not quite correct. If V1 is present and you close the switch V1 and the battery will be shorted together, and you don't want that. Their voltages will never be exactly the same, and that will cause a large short-circuit current. More about this in a minute.
When V1 is present the LED will be on through the battery, regardless of the position of SW1.
If V1 is gone the relay will be off, and so will the LED.

How to solve these issues? Use a switch-over relay to switch between V1 and battery and place it at the node next to the LED's anode.

A minor thing, though it will not change the circuit's functionality: you're interrupting the ground with your relay. Don't. Swap the relay contacts and the LED, so that you interrupt the positive voltage instead. Just a good habit. Has been fixed anyway in the previous paragraph.

And don't forget to place a series resistor with the LED. For a 20mA indicator LED a 1k\$\Omega\$/1W will do.

And clean it up a bit. The ground line at the bottom, going to the contact of SW3 is superfluous, and draw a single ground line for both power sources, so that it's obvious that they're connected.

edit (re your revised circuit)
We're almost there. The switch is in series with the relay coil, so closing it will create a path from coil through R1 and LED to ground. The - of the coil should go directly to ground, and the switch should go between V1 and the unused relay contact.
But schematic-wise it looks already much better, don't you think? It may even pass the olin test ;-).

  • \$\begingroup\$ (24-0.4-2)^2/1e3 = 0.47 W. A 0.5 W resistor would be too tight. \$\endgroup\$
    – Telaclavo
    May 23, 2012 at 12:39
  • \$\begingroup\$ this resistor doesn't need derating below 70°C ambient. Besides, I use a 3V white LED :-), so that's 0.44W. \$\endgroup\$
    – stevenvh
    May 23, 2012 at 13:10

(In fact, I still don't get the ultimate purpose of what you want to do. Do you want to have light only when the mains fails? If so, what's SW1 for? The only purpose for SW1 would be "to force draining the battery while there is mains", which does not make much sense to me. Do you want to have light always? My answer below was for "always".)

Don't do that. You need relays, detect voltages, and you may end up connecting in parallel both voltage sources, which is not good.

Do this:


If the two sources give indeed the same voltage, use two schottky diodes in series with the battery, as shown. If you can slightly modify the output voltage of your 24 V dc power supply, make it slightly larger than the voltage of the battery, and use one schottky diode, instead of the two in series, shown. In any case, you must have a minimum of two schottky diodes, in total. Doing this, the battery will not be drained if the power supply is on.

R= 1.1 kohm, 1 W, for the LED you mention.

  • \$\begingroup\$ What happened to the switch? \$\endgroup\$
    – stevenvh
    May 23, 2012 at 12:36
  • \$\begingroup\$ @stevenvh It took some days off. It was starting to feel the stress of just going back and forth. \$\endgroup\$
    – Telaclavo
    May 23, 2012 at 13:17
  • \$\begingroup\$ It didn't suffer from burnout, did it? :-) \$\endgroup\$
    – stevenvh
    May 23, 2012 at 13:37
  • \$\begingroup\$ Why Schottkys? The priority detection will work better with the larger voltage drop of a 1N4001. There's no point in keeping the voltage drop low; it will be consumed by the resistor anyway. \$\endgroup\$
    – stevenvh
    May 23, 2012 at 14:42
  • \$\begingroup\$ @stevenvh The priority mechanism works equally well with 0.4 V and 0.7 V voltage drops. I bet there are more circuits in the world that use schottky diodes in that configuration, than circuits that use PN diodes (in that conf). // The low voltage drop is (of course) to waste less power, when he connects the main 24 V load (and when he tells us which one it is). I hope he doesn't want to build all that (and with 24 V) just to drive a 20 mA LED. I'm actually waiting for him to resolve this mystery. \$\endgroup\$
    – Telaclavo
    May 23, 2012 at 15:01

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.