Help selecting optocoupler DC input to AC output

I want to use Arduino digitalwrite to turn on/off 24v ac circuit using an optocoupler. In this case I want to use Arduino's digital pins (DC) to switch a circuit on and off by way of anode cathode pins and on the collector emitter side, turning on/off, say a 24v AC circuit. Since on the AC side, current is actually flowing in both directions, you would want a triac-opto, (MO3021 for example) but it will stay on once activated (not a good switch)! With a transistor-opto (PC817C for example), the maximum Collector – Emitter voltage output is often 30V, which is fine, but the maximum Emitter to Collector voltage is always low, say 5-6V. Since AC is flowing in both direction, isn’t allowing 30V to flow from emitter to collector bad for the opto? What opto should one use in these hybrid cases? I want complete circuit isolation between the DC and AC sides, so please, no "Why not use a relay?" reply's.

Why are you so FUSSED UP about not using a solid state relay?


@Paul_KD7HB While some SSR's provide circuit isolation, none of them cost 25-45 CENTS each like most optocouplers.

Hi, Welcome to the forum.

What is the load you are switching?

Please read the first post in any forum entitled how to use this forum.,148850.0.html

Do you have any code written? Do you have a circuit made?

Thanks.. Tom... :)

Sorry, I thought I provided enough information for the question at hand in my first post. I have not written any code or have a circuit made yet because I don't know what optocoupler to use. I want to use an Arduino Uni R3 digital IO pin to turn on AND off the relay on a 24V AC irrigation valve that has it's own power supply. My intention is to allow or not allow that AC current to flow using an optocoupler. At first I thought I would use a PC817C but upon reading the datasheet the Vceo is okay at 30volts but the Veco is only 5-6volts. AC works both ways, so that is probably out. So then I looked at triac-opto's, but the ones I looked up all seemed to not shut off with DC voltage triggers. So I came to this forum looking for suggestions on an optocoupler to use for this. I wan to use optocouplers because they are inexpensive and I may want to control many more valves. If I have to use a $20 SSR for each valve, I might as well buy a commercial irrigation controller.

An irrigation valve is likely to use an Amp or more. We need a specification for the actual current it's going to use.

I don't know of any cheap optocouplers that can switch that kind of current. They're usually used to switch a relay or Triac which then switches the main current. A combined device is likely more expensive than discrete components.

4-pin or 6-pin DIP-style dual mosfet based SSRs are usually <120mA.

The 230volt SSRs you see on relay modules have a minimum voltage (~75volt).

Post a link to the valve.

Here is the tech datasheet for the 075-DV Rainbird irrigation valve.

It states on Page 1:

Electrical Specifications • 24 VAC 50/60 Hz (cycles/sec.) solenoid • Inrush current: 0.30 A (7.2 VA) at 60 Hz • Holding current: 0.19 A (4.6 VA) at 60 Hz • Coil resistance: 42-55 Ohms

On Page 4:

"The valve shall be actuated by a low power 0.30A (7.2 VA) in-rush current and 0.23 A (5.5VA) holding current."

Thanks for all the help. I really appreciate it!

The PC817C is a DC/DC only chip Do not apply AC you will kill the chip

You do not need to use an opto coupler in this application. If you think there may be a problem with Richard Head ( a typical user) connecting the wrong thing use a polyfuse

There are a number f cheap SSR's that will deal with the current you need look here



You can use an opto - isolated triac such as a MOC3021.

There is only a problem with the output not turning off if you have the output connected to a DC circuit.

Because you are using AC, then the output will turn off when the current falls below a certain threshold. This will occur 100 or 120 times a second depending on whether mains frequency is 50Hz or 60Hz in your territory.

@JohnLincoln, One of the optocouplers I was considering was the one you recommend trying, the MOC3021, but I discounted it because of the problem of it not shutting off I read on the interwebs. I did not realize those problems were for people trying to use it in a DC circuit! I will look into this further. I don't yet know what "non-zero crossing" means,

@holmes4, thank you for the link. 1454 choices! As soon as I selected the first filter at 500mA, I got 11 choices, all starting at over $27 US. Not cheap enough for me I'm afraid. The MOC3021 (if it works) is less than 4 bits.

The MOC3021 is totally unsuitable for driving anything other than a triac. Yeah, okay, you could probably misapply it and get a few milliamps out of it before it smokes the absolutely total package maximum power rating of 300 milliwatts, you're looking for closer to 10 watts.

Since cheap appears to be the operative word, here's a solution for $2.30 each, qty 1.

That's for a 1.2 amp device. I'd really like more headroom but you want cheap, you get what you get at that price point. About the only thing that will do the job cheaper is a mechanical relay driven by a transistor but you've never stated what the duty cycle is.

A mechanical relay would be fine if thing cycles maybe a few times an hour but anything faster than that really needs to be solid state because mechanical stuff self-destructs going clickety clack all day long.

@acr_fred. Thank you for the reply. Smart. It is so easy for a novice to read a datasheet and come to the wrong conclusion. The MOC3021 states the OUTPUT DRIVER can handle 400V and 1A, so a novice like myself would think it could handle 400VA and the irrigation valve is only asking for 7.2VA. Why would it have specs for 400volts and 1amp if it is going to smoke at 300mW?

Heck, the datasheet's own recommended uses is for a "Static ac Power Switch". What good is it for that if it smokes a 300mW?

I thank you for the link as well. The AQH3213 seems to support an output of 600V at 1.2A as you say, but I can't find it's power dissipation to compare to the MOC3021. I hope it is not a smoker too.

Really appreciate everyone's patience.

Well, it's a bit of red herring to say that the maximum power of the MOC3021 at 330mw has anything to do with the fact that you have a ~7 watt load.

You'd have to look at the sum of the power being dumped into the input LED and the power dissipated by the output triac. The input side is easy, Vfwd of the diode times the current.

The output side is the one that hoses the idea since the specs show that no matter how you look at the numbers, the output power can hit about 600mw. That is looking at both the inrush and the steady state over the temperature range. Just the best case of steady state at 25 deg C puts you at about 1.5 volts drop over the output device at 0.2 amps, that's 300mw, ignoring the input power which equals smoke released in short order.

You really should not dig too deep into datasheets before reading what the intended purpose of the device is. The point here is that the MOC3021 is intended for just what is says in the description (first page) of the datasheet:

The MOC301XM and MOC302XM series are optically isolated triac drivers... They are designed for interfacing between electronic controls and power triacs to control resistive and inductive loads for 115vac operations.

The AQH3213A datasheet leads with this:

Compact DIP type SSR Ideal for AC load control TYPICAL APPLICATIONS 1. Home appliances (air conditioner, microwave oven, washing machine, personal hygiene system, refrigerator, fan heater, inductive heating cooker, rice cooker and humidifier, etc.) 2. Industrial equipment

From that description alone, we know we have the correct type of part, all that needs to be established is that it meets our needs/specs.

BTW, I was going to add this to my first post, had access issues, I think it worth adding:

PS: I selected the "zero-crossing" model of SSR. This should limit the inrush when it turns on since what Z-C means is that the device only turns on at the zero voltage point of the AC waveform. That doesn't (and usually isn't) the best place to turn on with an inductive load (solenoid is inductive) since that doesn't mean it's the lowest current point to turn on. But, at least it is predictable, unlike the other choice , random turn-on.

PSS: You will generally not find a package dissipation number for a SSR, just maximum voltage, current and temperature. The max power is derived from those numbers and it's not going to smoke with a 200ma load, that's what it's designed to do, switch AC loads.

I'd like to add a caveat to anyone reading this thread.

If you're thinking of using the Panasonic part mentioned above at anything above the 24 VAC we've been discussing here, please reconsider unless you are aware of the dangers and are designing your own circuit board.

An 8 pin DIP package part, regardless of thru-hole or surface mounting configurations, will not be safe at mains voltages on a perf, strip or way worse, a breadboard. The spacing of the device pins is very tight and any home construction methods are not safe, it requires special considerations in PC board design to provide safe spacing between the pins to prevent flash over at the higher voltages.

Please DO NOT think you've just found a great $2 solution to a $5 problem.

@holmes4, thank you for the link. 1454 choices! As soon as I selected the first filter at 500mA, I got 11 choices, all starting at over $27 US. Not cheap enough for me I'm afraid. The MOC3021 (if it works) is less than 4 bits.

When selecting the load if you click a particular load to get just that. IF however you click the min/max (it's in blue) you get an extra popup menu. set 500mA as the min and order by price and you get a load of stuff starting at around 50c!


Thank you all for your replies! It has been quite a learning experience. Who knew it could be so complicated to safely create an open on an irrigation valve? Initially, I thought a optocoupler alone (like the MOC3021/MOC3041) would be a simple solution. I now have a greater understanding of why a Triac needs to be in the circuit to actually act as the switch because it can handle the slightly higher current the valve will pull.

Hey everyone. Just wanted to update you all. I finally got all the parts in from China. Man that boat is slow!

I ended up using an MOC3041 optocoupler AND a BT136-600D Triac as so many suggested. I did not realize there was such a difference between the DC-DC OC's like the PC817 and the DC-AC ones like the MOC3041. They behave very differently. When you put a current across the anode and cathode of a PC817, the other side closes by itself. The MOC3041 doesn't seem to do a thing without some current on both sides going through. I thought about using this circuit to short out my 24v AC garage door opener too, but there is always a little bit of current going from gate to T1, making it impossible for me to create a short circuit reliably. I guess a mechanical relay is the only way to go there?

Anyway, here is a shot of the project. I am using a 110V light bulb connected to a 24V AC transformer, which is why it is so dim. It is sitting in for my irrigation valve. The coin battery is sitting in for my GPIO pin. Seems to be working like a champ and no relay noise or moving parts to break down.

Here is a link to the the image on my Dropbox.

Image of Project

Thanks again for all your help!

"Short out" is usually a bad thing. Perhaps you meant "connect" or "join"?

What do you want to do with the garage door opener? Just press the open/close button? That's not likely to be 24V AC on the button. It may even be 5V or 3.3V which can be connected directly to the Arduino.

I'm still back at post #1. What was wrong with a transistor and decently designed relay PCB in a low duty cycle project like this? Isolation isn't an issue.

If the OP is going to run long leads in the open (garden), he's still going to need some transient protection on the AC wiring to protect the SSR against nearby lightning etc.