5

I have 13 sprinkler lines, and my old control box is failing, so I want to replace it with my Raspberry Pi B+. Here is a photo of the old wiring:

enter image description here

and a diagram:

enter image description here

I don't want to use relays, since for 13 lines that would get bulky and expensive. But I found the ULN2003A (pdf) that takes up to 7 3.3 VDC inputs and can activate corresponding VAC outputs. So my plan is to use two of those to control the sprinklers.

Since DC is easier and safer, I already made a DC version to light up a few LEDs, and it works:

enter image description here

enter image description here

But I'm not 100% positive how I should wire it up for AC. I think I want this:

enter image description here

enter image description here

I would take one of the yellow 24VAC wires and splice it to the 3 white C wires. Then I would take the other yellow 24VAC wire and put it in the left-side + power rail. I would take the 13 sprinkler wires and put them in the ULN2003A outputs.

So my questions:

  1. Does this look right?

  2. Is it correct that on the right-hand side I'm using the RPi GND pin for ground? Or should it be going to some other ground? In the DC version that ground was necessary to complete the circuit, but I think in the AC version there is a loop even without that, since one of the 24VAC wires would be spliced to the white C wires. So the ground would just be completing the circuit for the input wires?

  3. Any warnings or things I'm overlooking? I'm a total newbie to wiring things and I'm a little scared of AC power.

  4. Are the two yellow 24VAC wires "equivalent"? Does it matter which I put in each place?

By the way, I've already read this older question, and I don't consider mine a duplicate. As I said, I don't want to use relays. My question is about using an ULN2003A, which isn't mentioned there. Also my question gives a lot more context and specific details about what I've tried and what I'd like to know.

4
  • 1
    Are you sure ULN2003A is designed to output AC? I read most of the data sheet and didn't find that mentioned. I could easily be missing it, or course. Am I right to assume your sprinkler solenoids require 24V AC to actuate? My interpretation of teh datasheet is that it is designed to drive a high power relay, for instance, not provide actual AC to the sprinkler.
    – Dan
    Jun 27, 2016 at 18:12
  • 1
    Not sure! :-) I thought "inductive loads" was code for AC, but I guess that's not right. So that is why there are so many ULN2003 videos showing it driving relays! . . . I did find a 16-channel relay that is less expensive than I expected: amazon.com/SainSmart-101-70-103-16-Channel-Relay-Module/dp/… I guess I will add that to the mix, or even use it to replace the ULN2003As. Thanks! Jun 27, 2016 at 18:49
  • I found that curious as well, but I'm thinking that would apply to perhaps DC motors. Cool IC you found nonetheless, and that relay board looks like a winner! Thanks for discovering them for me!
    – Dan
    Jun 27, 2016 at 18:55
  • 1
    I'm with Dan but I am not an electrician. The fact that the ULN2003A uses flyback diodes internally says to me the output current is only supposed to flow in one direction; it cannot work alternating. You could confirm this on our larger sibling site, Electrical Engineering.
    – goldilocks
    Jun 27, 2016 at 20:14

2 Answers 2

2

No, you can't use ULN2003A to control 24VAC solenoids.

The chip contains NPN darlington transistors. This means that you can use each of these transistors to control a DC load by bringing its negative terminal to ground. You have two options:

  • Use a diode bridge to convert 24VAC to about 33VDC, and use that to drive the solenoids the same way you drove the leds. In this case, you have to take note of the current: The ULN2003A has a 500mA peak collector current, which means that if your solenoids consume more than 500mA at 33V, you will blow up your chip. To be safe, I wouldn't recommend going above 350mA. Since 33V / 350mA is about 100 ohms, you shouldn't put any solenoid that's below 100 ohms. You should also think about the combined current, and pick a diode bridge which can handle at least 13 * 500mA (or however many valves you would like to have activated simoultaneously). That's a very huge number, and I wouldn't recommend working with such high currents.

  • If your solenoids consume a higher current, or your setup doesn't allow using DC, the best solution in my opinion is to use the ULN2003 to drive relays the same way you drive the leds, and then pass the 24VAC through the relays.

  • Another way, which might (or not) turn out to be cheaper than using relays, is to use a triac for controlling each solenoid. The triacs are very good at handling AC, but it's a good idea to isolate the AC from the digital part of the circuit. This means that you would need a diac-based optoisolator for each of the triacs, like this (it would be the same for 24VAC and 240VAC): Optocoupled triac controller - source bristolwatch.com

2

I can confirm, you can't use ULN2003A for AC.

I'd just use 2 x 8-relay Arduino boards (they are commonly available on Ebay/Aliexpress etc.). They have opto-isolation and are easily drived by GPIO output from RPi, despite its 3.3V voltage.

enter image description here

It's simply plug-and-play. Connect board inputs with goldpin connectors (sorry, I don't know how they are correctly named, I'd be glad if someone could confirm the name). Relays already have terminal blocks, so setting this up is easy.

The only thing you can fix there is RC filter, parallel to each relay output, to extinguish electric arc that ignites when you disconnect relay and you don't hit zero crossing of AC.

They key is proper software, but I assume you have it already :)

4
  • 1
    I wound up using the 16-relay version. Although there are YouTube videos of people driving it directly from a Pi, my own Pi (a B+ model) didn't seem to work. All relays went on at once---I believe because the relay is "high voltage = off, low voltage = on", and the Pi's 3.3V was interpreted as low. Fortunately I had these nifty chips called ULN2003A that can step up a DC voltage. . . . :-) Aug 16, 2016 at 16:18
  • "All relays went on at once" - do you mean all of them switched when you toggled just one pin? BTW relay has no logic, really ;) if you manage to power the coil, it just switches. But in this module you can't directly power up the coil. You do this by powering on the optocoupler, and they work okay when powered directly from the GPIO output. Optocoupler turns on the transistor that delivers energy to the coil and switches the relay.
    – Mark
    Aug 17, 2016 at 6:18
  • All 13 relays closed and their red LEDs came on. The lights stayed on whether I said GPIO.output(pin, False) or GPIO.output(pin, True) (in Python). Same thing with the GPIO.HIGH and GPIO.LOW constants. I believe just GPIO.setup(pin, GPIO.OUT) was enough to turn them on. Aug 17, 2016 at 14:10
  • You can confirm that they actually react on low level by connecting directly "Ground" pin with input to the relay module. Relay should stay on. Next thing is to connect "5V" pin to another relay input. It should disconnect. If not, it might be your configuration or something.
    – Mark
    Aug 17, 2016 at 15:31

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.