I know very little about Arduino and even less about programming one. Before I purchase a board, and learn how to program it, I was wondering if my idea is feasible.

I want to program the Arduino to sequentially open one after another irrigation valve. There would be approximately eight 24 volt solenoid valves. Each one would need to be open for approximately 15 minutes, then open the next valve in sequence and finally close the previous valve. Similar to a multi-zone irrigation controller.

I see that I may need to use a transistor in the power circuit of the solenoid. But it is not clear to me if the Arduino can control eight solenoids and if so, does each solenoid require its own transistor?

  • 1
    is this what you really want? it is different from irrigation. Each one would need to be open for approximately 15 minutes, then open the next valve in sequence and finally close the previous valve. .... the sequence has to be absolutely clear in your mind, otherwise it will prove difficult to write a program that does what you want it to do. – jsotola Mar 12 '18 at 18:28
  • Are these AC or DC solenoids? I see a lot of irrigation solenoids are AC. – Nick Gammon Mar 13 '18 at 1:03
  • 1
    If this is an educational endeavor: welcome. If this is something you need to get done in a reasonable amount of time, then I recommend using existing irrigation solutions. There is significant time and $ investment to not only program the device, but select switching mechanisms and ensuring they are hardened for the field – gatorback Mar 13 '18 at 2:34

An Arduino can control (at least) 8 devices. Instead of a transistor, it might be much easier to use an 8 way relay controller, something like this:

8 relay module

Just connect all 8 valves to the relays, you power the relay with a separate source for the valves, and connect the pins to the Arduino.

These ones have opto couplers, which give an extra security between the valves and the Arduino.

8 relay module with opto couplers (note I just put the first entry I found, you might find better/cheaper similar items, e.g. at AliExpress for $4).

As Andre said in a comment below, you can use an Arduino Mega if you need more outputs. Or if you want a challenge you can use use a multiplexer IC like 74HC595 (plenty of examples to be found with Arduino).

For controlling one relay with an Arduino enough examples can be found, for 8 it's similar (just use 8 GPIOs), or a multiplexer IC.

  • 1
    Ya, depending on the amount of current, it is better to have some pysical iscolation between your 24V/higher current side of the valves. and the 5v/low current side of the arduino. – Chad G Mar 12 '18 at 16:59
  • 1
    These relay module usualy have opto-coupler isolation, but indeed check. – Andre Courchesne Mar 12 '18 at 17:08
  • 2
    If you need more than i/o just use an Arduino mega. – Andre Courchesne Mar 12 '18 at 17:09
  • 1
    @AndreCourchesne Thanks for the comments, I have updated my answer accordingly. – Michel Keijzers Mar 12 '18 at 17:21
  • 1
    @MichelKeijzers I was agreeing with you in case that was not clear, I was saying have physical isolation (Relays) was better then driving it with a transistor. Having opto-couplers on the relays is nice, but probably overkill for those little relays. – Chad G Mar 12 '18 at 17:40

Yes, you will need something to drive 24 volt solenoids, because the Arduino cannot do it alone.

My preferred method would be to use a ULN2803 device, which will allow you to drive all those eight solenoids (assuming they take less than 500mA or current) and has inbuilt protection against the voltage spike when the solenoid switches off.


These devices are available on eBay.

The software will be quite simple for this application and should be well within the capabilities of anyone who reads an Arduino tutorial.


There are 2 wires to a solenoid, and 2 ways to operate them:

1- Closing a relay sends 24V out, with return wires going to 0 volts.

2- 24V Always goes out, and a relay can short the return wire to 0 volts.

Either way, test 2 by running the wires to a control board, and manually activating solenoids. When that works, add Arduino relay control as other suggest.

Keeping the switches will help, if you want to operate a solenoid manually OR you suspect you have a broken relay / solenoid.


Most irrigation valves are AC operated, typically using 24VAC at about 250mA (Double that to 500mA for the inrush current). The best way to drive these is via a triac. If you want isolation between your controller and the valve voltage an opto coupler with a triac output is the best way to go. A good choice given the typical irrigation valve is the Vishay VO3023: 5mA LED input current and 1A output current and only about $0.50 per unit. Triacs are pretty tough devices and have no moving parts like relays so they are quite reliable.


An Arduino board is merely a microcontroller with the stuff around it that is necessary to keep it running. By stufff, I mean thinks such as the voltage regulator that provides the power, the oscillator that provides the frequency for the controller, the GPIO pin connectors, and so on.

This is a very simple application and could easily be done by an Arduino. The programming doesn't have to run quickly. You are only doing one thing at a time.

I found an 8-channel relay module that should do what you need. You would need four of them, but they are only about $11 apiece. I have never used this device before, so I don't know how well it works, but the specifications seem right. They can be controlled by almost any computer with output pins that have 5 volts. So you'd need to use an Arduino with 5V output pins.

You will probably need more output pins than a standard Arduino, but that is easy enough to do with the Mega version.

  • 1
    it is not 24 valves. it is 8 24V valves :-) – Juraj Mar 13 '18 at 14:57
  • That makes it even easier. The module I linked can handle 30V DC at 10 amps. It can also handle AC up to 250V. And now only one is needed. – NomadMaker Mar 13 '18 at 16:58

Yes, Arduino can control eight transistors.

Each solenoid will need a transistor.

Ideal would be to use logic level N-channel MOSFETs that the Arduino 0/5V output can drive directly. IRFL540 is mentioned a lot, you can get them at digikey.com. Drive the gate thru a 150 ohm resistor, and have a 10K resistor from the gate to Gnd so the transistor is off while the Arduino is reset (and the IO pins all revert to Inputs).

Depending on the current draw, you may able to use a shift register with Open Drain outputs. TPIC6C595, 100mA. TPIC6B595, 150mA. TPIC6595, and TPIC6A595 are even higher current capable parts.

Add a diode with the same current rating across the solenoid coil, cathode to +24V, so the burst of current generated by the coil when the transistor closes has somewhere to dissipate. (current in a coil wants to keep flowing as the magnetic field in the coil collapses, it can't go thru the turned-off transistor, so it goes thru the coil and dissipates in the coil's wire-resistance).

  • 1
    this is not electronics.stackexchange – Juraj Mar 12 '18 at 17:25
  • 2
    Your comment does not make sense. Arduino controlling transistors is a primary function of what it can do. – CrossRoads Mar 12 '18 at 17:34
  • 1
    @Juraj knowing how to hook up the electronic portion of a system to an Arduino is an integral part of choosing/using Arduino devices. What made you think that it was perhaps off topic for this SE? – BunnyKnitter Mar 12 '18 at 18:12
  • 1
    why not use relay modules? or any other actuator or sensor you can by as module with supporting circuit soldered in factory with so small components? What can he make more specialized for the application, then the of the shelf relay board? the questions are not rhetorical. I really want to know what is the drawback. – Juraj Mar 12 '18 at 18:35
  • The solenoids I installed recently for my irrigation system were 24V AC-powered which would make a MOSFET or BJT transistor unsuitable. A Triac might be better in this case. – Nick Gammon Mar 13 '18 at 1:06

An alternative method is to use an I2c port expander such as a PCF8574. These are available as break out boards. By selecting a different I2C address on each break out board up to 64 relays can be controlled using opto isolated relay modules. Thus 64 0utputs or inputs with just two Arduino pins.

Not the answer you're looking for? Browse other questions tagged or ask your own question.