problem with optocoupler relay

I am previously using a transistor to switch a 12v relay from arduino but due to some interference, the circuit didn’t work properly. Now i am trying to use optocoupler (pc817) as a switch in place of transistor. I am dealing first time with optocouplers so kindly tell my mistakes. The problem is that when i am trying to switch a relay according to the attached circuit, relay doesn’t toggle. Although on measuring voltage with multimeter, it shows 12 v, but doesn’t toggle it. Is that optocoupler lowers the current?

You also want to show your original circuit and say what load the relay is switching.

From the diagram above, you do not have a flyback diode across the relay coil, its absence can cause interference and can the relays contacts when switching certain loads.

Also you have no resistor between the Arduinos pin and the optos led

See the diagram in entry #3 of this post http://forum.arduino.cc/index.php?topic=140116.0

OP’s pic for others:

ad30ade48f904a84a653fae22f7680eb56e7cfe6.jpg

You don’t show the arrow on the transistor, but the pc817 is an npn afaik. Assuming the 12V is to the collector, I think you would be better off with the relay on the other side of the transistor not on the emitter. (As shown in the post ricky101 mentioned, which in turn comes from the link in my post above that.)

You might even need to keep the transistor you already had, as shown here. (ie, use the optoto switch the original transistor.....)

Maybe there is insufficient current flowing through PC817. Is it a active low type ?

OFF TOPIC,sorry

Did you try this app on the windows store SerialScope ? You can turn your phone and a arduino into a tiny scope.

MalharD: Is it a active low type ?

Well it's open collector so I'm leaning towards my post #3, where it has a pullup on the collector and that output controls the transistor OP always had.

Hi,

Although on measuring voltage with multimeter, it shows 12 v, but doesn't toggle it. Is that optocoupler lowers the current?

Where were you measuring the 12V? Place your DMM on the relay coil terminals and read the voltage there when you try to turn it on. I would say the connections on the relay side to the opto are back to front. The input to the opto is okay, but the output is wrong way round.

Also place a current limit resistor in series with the arduino output, to limit current to the opto LED. Tom.... :)

JimboZA: Well it's open collector so I'm leaning towards my post #3, where it has a pullup on the collector and that output controls the transistor OP always had.

Sorry, I wasn't reading carefully.

Opto couplers generally cannot provide enough current for standard relays - you need to amplify the output unless you have an opto-darlington, which have that built-in. Opto couplers are signal devices, not power devices.

If you look at datasheets you'll see standard photo-transistor output optocouplers are typically 20mA in, 5 to 10mA out, whereas relays need more like 50 to 200mA.

This opto isolator (opto-darlington) should control your 12V relay OK ... providing the relay coil doesn't draw more than 150mA. What is the part# of your relay?

What is you location ? in India ?

[moderators,please don't ban me for asking location]

Thanks guys for reply. Sorry to attach that incomplete circuit, actually i have a resistor between arduino pin and optocoupler. Also the 12 V reading is between relay terminals (via multimeter) but not toggling it. I am satisfied with 'MarkT', i think the current it provide is not sufficient for relay. Do i need a transistor too for this? No way to switch relay just from pc817 ?

MalharD thanks for suggestion, app seems cool, I'll try that soon. I am from ncr region, ghaziabad.

http://forum.arduino.cc/index.php?topic=387205.0

Check this to review my problem and the full circuit.

Hi,

Place your DMM on the relay coil terminals and read the voltage there when you try to turn it on.

I would say the connections on the relay side to the opto are back to front. The input to the opto is okay, but the output is wrong way round.

Checking the [u]voltage on the relay coil[/u] will answer those questions, Tom... :)

I have a video on my YouTube channel (video #18) that deals with opto-coupled relay modules which may help you. A picture paints a thousand words, a video gives you a library (or something).

URL in the signature of this post.