I have created a system using arduino where it controls 5 different electric lines. For example: Line 1, Line 2, Line 3, Line 4 and Line 5. What arduino does is, it turns on the Line 1 if it has power and if it doesn't have power it turns on the Line 2 and etc. Arduino turns on/off the 5V relay and it has at least 5 sec interval when switching from one line to another(in this case I have 5 x 5V relays). It is working perfect and I am very happy with the system, however I am concerned about relay fails to disconnect when commanded.

For example: If Line 2 was on and suddenly Line 1 also gets power and arduino will turn off Line 2 and after 5 secs it turns on Line 1. What if Line 2 relay didn't brake the curcuit? I think I will have a fire or something really bad.

My question is, can I some how make fuse so that never more than one lines will be connected?

See my schema: The reason I am doing this is, in our office we have 5 different lines of electric and I want to control it automatically. Also I would like to see which line has power and being able to control it from the computer.

enter image description here

  • 2
    \$\begingroup\$ (1) What supplies power to these different lines? (2) What is the load? (3) Why do you need to multiplex between the lines? What are you ultimately trying to accomplish? (4) A diagram wouldn't hurt. \$\endgroup\$ Feb 17, 2016 at 4:26
  • \$\begingroup\$ You really need a circuit diagram, please use the tool, they even have a switch symbol! When you say "turn's on line 1" do you mean bring it to 5V? Are these connected to the GPIO \$\endgroup\$
    – Voltage Spike
    Feb 17, 2016 at 4:30
  • \$\begingroup\$ Can you tell us anything about your load? What amperage load will this be driving; is it inductive/reactive/resistive; will there be a high 'inrush current,' etc.? \$\endgroup\$ Feb 17, 2016 at 5:44
  • \$\begingroup\$ @RobhercKV5ROB I know the relays that give power to the outlet can't hold 10A, but just to simplify I didn't draw another 5 relays. They will be triggered by 5V relays on the right side of the Arduino. My load is about 10-20A 220V. Also the relays I didn't include in this schema are 2 pin relays, so that I can put the phase and ground through the relay to separate each lines ground. \$\endgroup\$
    – Dilshod
    Feb 17, 2016 at 5:49

2 Answers 2



simulate this circuit – Schematic created using CircuitLab

Figure 1. Mains selector priority.

This circuit prevents cross-connection in the event of a relay contact welding or micro-controller going mad. You already have the components.

  • \$\begingroup\$ I like this idea. This prevents from something burning up, but I am not sure if I can control it from my computer incase if I wanted to change the order of it. Let me think little bit more see if I can make it work using the schema you drew. \$\endgroup\$
    – Dilshod
    Feb 17, 2016 at 10:13
  • 1
    \$\begingroup\$ Sure you can. It works as before but in the event that two relays are on (which, unless there is a stuck contact or logic error, should never happen) the lower number relay will supply the current. \$\endgroup\$
    – Transistor
    Feb 17, 2016 at 11:59
  1. You can get rid of the ac mains-powered relays for your 'sensing' side to tell the 'duino when each circuit has available power. A resistive voltage-divider with a diode & cap can do the same thing with lower power dissipation and should give you a much longer lifetime.

  2. You can use an N-MOSFET to drive output relays ok (but with limited lifetime due to physical switching stresses & possible contact welding), or you could have it drive an AC-switching MOSFET pair, as in the following (simplified) diagram:
    improved circuit


  • No overvoltage-clamping, or any other protective circuitry is shown in this diagram, but it should absolutely be used in your final project
  • The P-MOSFETS for the AC output stages must be specifically selected for this use. 'Normal' power MOSFETS will simply burn up their 'body diodes' in this configuration (without additional protection), rather than switching correctly.
  • \$\begingroup\$ Last bullet about power MOSFETs with body diodes. I've never come across a power MOSFET without a body diode. Theoretically a power MOSFET can be made without a body diode, but I doubt that such a thing exists in practice. If you are aware of one, could you post a datasheet link? \$\endgroup\$ Feb 17, 2016 at 6:32
  • \$\begingroup\$ @NickAlexeev Thank you; I mis-spoke there. While I can't locate the datasheet right this moment; I did come across a N-MOSFET datasheet for a transistor with 2 opposed body diodes, in what looked to be a TVS diode arrangement. It was clearly stated as intended for AC use in that datasheet. I'll try to keep digging for it. \$\endgroup\$ Feb 17, 2016 at 7:05
  • \$\begingroup\$ I don't like the look of this answer for several reasons: no electrical isolation; if the potential divider ground connection is lost the Arduino goes live; any failed MOSFETs may remain on or any Arduino code or hardware errors will cause connection of two supplies (until something burns out). \$\endgroup\$
    – Transistor
    Feb 17, 2016 at 10:05
  • \$\begingroup\$ @transistor I don't completely disagree. However, besides the 'no electrical isolation,' in what way is this not better/safer than the OP schematic using physical relays? Personally, with the # of times we've had to answer "why is my relay stuck 'on'?" questions, I believe that the possibility of a power MOSFET failing in a 'still conducting' way is a far lower total risk than the 1000x higher instance of a mechanical relay welding contacts. As far as elec. isolation goes; optoisolators could be added to each input/output easily enougjh. I think I'll 'tame your lead' & add those in. :) \$\endgroup\$ Feb 17, 2016 at 14:56

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.