# Implement 7 DPDT-switches with Arduino [closed]

OK, so my problem is the following: I have a commercial box with mechanical DPDT-switches for controlling valves by changing the polarity of 2 wires per valve. The box has 7 relevant switches, which I need to control further down the line with an Arduino. This Arduino gets signals from a separate computer over serial which switch should be in the on or off Position. When the Arduino is powered off the mechanical switches in the commercial box should function as without anything in between. Ideally the mechanical switches should overrule the Arduino in the off position. So the perfect states are as follows (-1 indicates no power):

I came up with the following schematic using SPDT-Relays, if you know of DPDT-Relays that work nicely with arduinos and I could order off amazon.de, that would make things a lot easier. Problem No. 1 with this approach is that the mechanical 0 signal does not overrule the arduino. I guess I would have to read the signal into the arduino and make an if case for switching the relay? Problem No. 2 is that I think the arduino can't handle the 14 Relays (I have only an 8-channel at the moment) Based on the specification I found in an amazon description it needs 20mA for every relay, with 14 coming to a total draw of 280mA which is above the 200mA rating for the output pins of an arduino I found online. I'm guessing a possible solution could be using transistors to switch the relays?

One other idea I had would be using NOT-Gates with NPN-Transistors, since the maximum power draw of the valves seems to be 500mA at 12V (fuse in the commercial box is 500mA, the real current is probably lower). This would require 14 NPN-transistors if I'm not mistaken, which I have already. There is also probably an easy way to use some logic gates to get the "overruling" of the mechanical switches.

As a quick background on why I want to do this: The equipment I want to control is an agricultural sprayer. Ours has 7 zones which can be turned on and off with mechanical switches. Earlier this year we built a diy-solution for autosteering the tractor (Cerea) and now want to control the sprayer at the same time. The arduino receives signals over the serial connection from the computer running the autosteering program. The signals determine which zones should be turned on, based on where the sprayer has already been. The manual override of individual zones is helpful at the sides of the field which the autosteering software doesn't know about.

If you have any ideas how to implement this let me know!

## closed as unclear what you're asking by Olin Lathrop, winny, Dmitry Grigoryev, Bimpelrekkie, Simon BAug 27 at 19:29

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• I'm not following what this "overrule" logic is supposed to be. If the micro (if arduino is really important, then the question doesn't belong here. If not, you can come here but need to use grown-up words) is getting its input over serial, then how is anything mechanical supposed to "override" the micro? How is this not just driving some SPDT relays from a micro? It's not clear what the problem is. – Olin Lathrop Aug 11 at 23:57
• why use an arduino? why not just use a 16-relay board that connects to a serial port? (I have not seen 14 relay boards, but 16 is common) – Jasen Aug 12 at 0:19
• Are the mechanical switches center-off? That is: spring-loaded away from the On or Off positions. Or does each valve always have power applied (either OFF or ON)? – Dwayne Reid Aug 12 at 0:26
• @TonyEErocketscientist The 0 in the logic table means voltage applied in different direction, so single SPST switch in series is not enough – Maple Aug 12 at 8:58
• It is still a logical AND as the output is the same for -1,1 input – Tony EE rocketscientist Aug 13 at 0:51

I believe this is the simplest solution. The relay is either ready-made module (e.g like this 5V or 12V version with 8 DPDT switches) or any relays of your choice with logic-level gate MOSFET switch.

simulate this circuit – Schematic created using CircuitLab

• I think your relay contacts NO/NC contacts need to be swapped. Output should follow the switches when Arduino is ON. (But that will fail the power-off requirement.) – Transistor Aug 12 at 10:03
• I don't think so. The Arduino connects output to "off" polarity directly or allows it to be connected to incoming switch polarity, which is also NC condition when Arduino is not powered. I might have got "off" lines swapped, but I think NO/NC are exactly as intended. – Maple Aug 12 at 10:11
• Yes, I think your solution is correct if you invert the logic of the Arduino. Energise the output to disable SW1 and reset the solenoid. See the tables at the end of my question. Your solution is the simplest. – Transistor Aug 12 at 19:56

simulate this circuit – Schematic created using CircuitLab

Figure 1. (a) What you've got. (b) Micro-control AND function but with no manual override. (c) Micro-control AND function with manual override.

How it (c) works:

• Solenoid polarity is controlled by RLY3, etc. This simplifies the rest of the circuit to controlling a single polarity +12 signal.
• In AUTO mode both the micro-controller controlled relay has to be on AND the solenoid switch has to be on to energise the solenoid relay.
• In MANUAL mode +12 V is fed to each of the manual switches via a diode. The diode prevents back-feeds from one channel to another.

Sw4 could be replaced by a relay fed from the micro-controller's 5 V supply or another GPIO pin permanently high. If the micro shuts down then the relay would drop out and enable manual control.

There are many relay modules available to be driven from the micro-controller. Most of these have transistor or opto-isolator inputs and will only draw about 10 mA from the micro-controller GPIO.

simulate this circuit

Figure 2. A further option.

This solution may result in less disturbance of the manual control box wiring.

Simple option:

Table 1. The OP's original table.

Mech    Micro              Output
----    ----------------   ------
0       0                  Off
1       0                  Off
0       1 or powered off   OFf
1       1 or powered off   On


Using Maple's design but inverting the logic signal for the micro-controlled relay makes the solution much simpler.

Table 2. The OP's original table modified with negative logic on the micro-controller.

Mech    Micro              Output
----    ----------------   ------
0       0                  Off
1       0                  On
0       1                  Off
1       1                  Off