Solenoid valves turning each other off


I’ve got a project attempting to control two solenoid valves with an arduino. Currently I can turn each valve on and off with the arduino, but when I try to open them both at the same time, they both turn off. The valves are 12vdc 4.5W, both connected to the same 12v power supply. The arduino is on USB power and the signal from the arduino is controlling the solenoids with TIP122 transistors. Circuit diagram attached (It’s stripboard which is what I’m used to drawing but the circuit is on a breadboard at the moment). The switches on the diagram basically tell the arduino whether to open or close the valves.

The power supply has enough juice to run both (2.5A). If I connect both valves up the the power without the transistors or arduino they both turn on fine.

I’ve just come across decoupling capacitors and I have no idea if I’ve done that right. The two caps on the diagram didn’t help any.

Any ideas?

The two caps on the diagram didn't help any.

Yes they did, just not enough to solve the problem.

Add an inductor in line with each solenoid's supply. The bigger value you can get the better. The inductors are shown by the green squares.

You also seem to have the Valve 2 - line to the wrong place, it is on the emitter and it should be on the collector like valve 1. The same goes for D2.

That stripboard layout is clearly wrong.

Valve1- is shown connected to pin 1 (base) of its transistor.
Valve2- is shown connected to pin 3 (emitter) of its transistor.

So you are being inconsistent, and both are wrong. The valves should be connected to the collecter (pin 2) of the transistor.

See the datasheet of the transistor for it's pinout.

You are also feeding your input signal to pin 2 (collecter), it should go to pin 1 (base).

You have placed the signal to the base on a parallel strip to 12V line,
maximizing the coupling from the relay load back into the logic signal. Keeping them
well apart will reduce interference.

Make sure the wiring from the board to each solenoid uses twisted pair or screened cable,
so its not spraying out lots of interference to nearby circuitry and wiring.

Wow… how did I draw that so wrong? My bad. I’ve fixed the diagram and added the inductors suggested (first attachment).

I wasn’t sure what size I needed so I tried 4.7uH and 470uH. I also tried some bigger caps but I’ve still got both valves turning off when trying to switch them both on together.

Another weird thing I’ve noticed: If I just try and run 1 valve (one side of the circuit), the valve won’t turn on unless I touch the back of the TIP122. However, if I connect the other side of the circuit, with D13 but without even connecting the second valve, it does work. So for some reason, it requires D13 (control for Valve 2) to be connected for the Valve 1, controlled by D12 to work. I’ve shown what I mean in the second attachment.

Do I need to isolate the two sides some how? And why doesn’t it work if I only try and run one side of the circuit?


That suggests to me that you have not got it wired up according to your layout diagram. Can you post a picture of the front and back of the board. Also with the software have you configured pins 12 & 13 to be outputs with a pin mode statement in the setup function?

Sure thing. There are a bunch of angles there. Let me know if they’re not clear enough. The diodes on the diagram aren’t on the board, they’re up in the solenoid wiring housing across the + and - pins of the solenoid. The cable to each solenoid is what you see with the yellow heat shrink around it. red is +, blue is -, white is the solenoid earth which isn’t connected to anything on the board as they’re DC solenoids (I think that’s correct?). The cable is shielded.

The Freetronics eleven board is 100% Uno compatible.

My sketch is below. It’s a bit long and is using classes and stuff for each switch but it’s what I’ll use for later, once this is working. The pinMode for the switches (2, 3) are set when each instance of the class is initialized. The pinMode for the valves is set in void setup().

I’ve unhooked the LCD in the photos for simplicity.

#include <LiquidCrystal.h>

//initialise pins

int winePin = 13;       // outlet valve control signal
int gasPin = 12;        // gas valve coltrol signal
int wineSwitchPin = 3;    // manual control of wine valve
int gasSwitchPin = 2;     // manual control of gas valve

LiquidCrystal lcd(4, 5, 6, 7, 8, 9);

class manualValve
  //Class for holding the valves open when the manual switch is used
  //The valves aren't allowed to be open too long to protect the solenoids from burnout
  int valvePin;           // pin for valve control
  int switchPin;          // pin for manual switch
  int valveState;         // current state of valve
  int switchState;        // current state of switch
  String label;           // valve name
  int row;                // lcd print row

  unsigned long switchMillis;  // store switch time
  long onInterval;        // max time switch is allowed to stay on

  manualValve(int vPin, int sPin, String lab, int pos)
     valvePin = vPin;
     switchPin = sPin;
     onInterval = 10000;
     label = lab;
     valveState = LOW;
     row = pos;
     pinMode(switchPin, INPUT_PULLUP);
     digitalWrite(valvePin,valveState);       //initialise valve to closed
     switchState = digitalRead(switchPin);        //get states on initialise
  void Update()
    unsigned long currentMillis = millis();   //get current time

    if (digitalRead(switchPin) == LOW) {
      valveState = LOW;                     //set valve state to closed
      switchState = LOW;
    else if (digitalRead(switchPin) > switchState) {   //test switch state compared to last time
      switchMillis = millis();              //get time of switch flip
      valveState = HIGH;                    //set valve state to open
      switchState = HIGH;                 
    if ((currentMillis > switchMillis + onInterval) && (valveState == HIGH)) {
      //valveState = LOW;                     //set valve state to closed
    digitalWrite(valvePin,valveState);    //apply valve state
    lcd.setCursor(0,row);                 //write valve state to lcd
    lcd.print(label);lcd.print(" valve: ");lcd.print(valveState);lcd.print(switchState);
    Serial.print(label);Serial.print(" valve: ");Serial.print(valveState);Serial.print(switchState);


manualValve gasSwitch(gasPin, gasSwitchPin, "Gas", 0);
manualValve wineSwitch(winePin, wineSwitchPin, "Wine", 1);

void setup() {

  // setup pin types
  pinMode(winePin, OUTPUT);
  pinMode(gasPin, OUTPUT);
  // setup LCD and Balance Serial
  lcd.begin(16, 2);
  lcd.print("hi pal");

  // setup Excel sheet for PLX-DAQ

void loop() {



Ok I was expecting that you had a layout like your diagram. Those photos show a circuit nothing like the layout you posted. I can't see any diodes and the connections are wrong. Rip it all up and start again, just one at a time. Make one solenoid driver and wire it up the the Arduino. Then make another and wire it to the same Pin and test it. Then join the two grounds of the circuit together and bring the other Ardunio output into play.

You are best starting from a schematic, I have never seen anyone before try to convert a layout diagram into a layout diagram.

Those inductors look like they can't handle the current, what is their rating?


Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Also have you got the gnd of the Arduino connected to gnd of the 12V supply.

Thanks… Tom… :slight_smile:

Also have you got the gnd of the Arduino connected to gnd of the 12V supply.

TomGeorge you're a genius! That's what I hadn't done. Wasn't sure if I needed to and was a bit worries about connecting the arduino pins to 12v things but that fixed it.

Thanks :slight_smile:

TomGeorge you're a genius!

Only in my own
Good to see you have it working...
Tom.... :slight_smile: