Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Since the advent of the many microcontroller development boards, like Arduino, there have been a number of relay modules sold to drive mains AC loads.

A lot of these seem to use an optocoupler, driver transistor and a relay to drive the load (example on Amazon)

Why are they implemented like this?

Some of my thoughts:

  • Relays provide as good or better isolation than most optocouplers
  • There is still a driver transistor present, so it is not component saving
  • There is still inductive kickback protection, so it is not component saving
  • Optocouplers are not as cheap as transistors, so additional cost compared to just a driver transistor
  • There is no need to meet any regulatory requirements as these are DIY products
  • I have never seen small mains relays driven by optocouplers in commercial equipment
  • A number of these boards don't seem to be designed brilliantly (no regard to clearance or creepage), so even if the optocoupler is simply to provide two layers of isolation, the board fails at this.
share|improve this question
Cargo-cult design? Maybe the designers are copying schematics from each other without thinking about it too much. As you said yourself, they don't seem to be designed well in general. – AndrejaKo Feb 27 '13 at 10:17
16A@250V is a lot of power and it does seem that the design is pretty naive on a lot of these. – Cybergibbons Feb 27 '13 at 14:31
Currently, a combination of Kaz and The Photon's answers seem most plausible. Industrial controls could be improved by use of optocouplers, and these hobbyist boards have likely cloned them. – Cybergibbons Feb 28 '13 at 0:38
up vote 10 down vote accepted

First, a possibly more permanent link to this product is here. And the schematic is here. (Edit 7/29/2015: Ironically my two links are now broken and OP's Amazon link is still useful)

Two reasons it makes sense to use optoisolators here:

  • The controlling device might be very far away so that it doesn't share a common ground reference with the relay board (except as connected through a long cable). Using the optoisolator means the control signal is used purely as a differential signal between Vcc and the control signal, both sourced from the controller circuit; ground potential differences won't affect the operation.

  • The relay coil voltage is not necessarily the same as the controller's Vcc. It could even be generated by an off-line (unisolated) supply. The optoisolator then provides isolation between the potentially unisolated JD-VCC supply and the controller circuits.

share|improve this answer
Slightly off topic These exactly same modules go for $2.25 (maybe even less) so the $7.99 link is a bad price. ledsee.com/index.php/arduino-modules2013-02-16-10-32-17/… – jippie Feb 27 '13 at 20:29
I think these are both very valid reasons when needed, and are why most industrial control system inputs will be optoisolated. But my gut feeling is that they sound like rare use cases, especially for hobbyist boards that are <$50. – Cybergibbons Feb 27 '13 at 20:34
@Cybergibbons, I admit the 2nd one is kind of a stretch. But I think the first would be pretty common...Also I imagine these boards weren't originally designed just to work with Arduinos --- that's just a market they found where they can sell a lot of them --- they could also be used in general industrial controls, etc. – The Photon Feb 27 '13 at 21:31
And in industrial controls you might a have a ground-loop or induced transient problem with a much shorter cable length due to big switching loads etc in the environment. – The Photon Feb 27 '13 at 21:33
I'd personally never dream of using something so low cost in an industrial situation - generally a single relay from a good manufacturer costs more. That's my reasoning as to why I'd not expect them to be considerations for hobby boards, when you could trim these components and the board would still work. Thoughts? – Cybergibbons Feb 28 '13 at 0:36

Probably a number or reasons, but the most important being that it will prevent transient voltage from damaging the driving transistor. And depending on the application, it will help prevent AC noise from interfering in the rest of the circuit.

You bring up some good points, however optocouplers are commonly used to isolate components from potentially dangerous outside sources. They are cheap and simple to implement. And they can potentially offer more protection than a diode. And of course, as you pointed out:

A number of these boards don't seem to be designed brilliantly (no regard to clearance or creepage), so even if the optocoupler is simply to provide two layers of isolation, the board fails at this.

share|improve this answer
Wouldn't a flyback diode be a cheaper way to prevent the transient back EMF damaging the transistor? – Rocketmagnet Feb 27 '13 at 14:18
I think Garrett means from the input side, which I hadn't considered. Most optocouplers can take a wide range of inputs. – Cybergibbons Feb 27 '13 at 14:30
@Rocketmagnet: The speed at which a relay can switch off will be a function of the amount of reverse voltage that is allowed to appear across it. Using a simple diode across a relay may be effective from a protection standpoint, but will cause the relay to behave "sluggishly". – supercat Feb 27 '13 at 16:07

I suspect a big part of the reason has to do with the idea that if there are two isolation barriers, there will continue to be an isolation barrier even if one is accidentally or intentionally bridged. When working with circuits, especially if one is a klutz, one may sometimes briefly short things which really shouldn't be shorted (e.g. because a scope ground clip decides to come undone and flail itself across the board). Adding an extra layer of isolation reduces the likelihood that such an accident will cause significant damage to anything. Most mass-produced products will never be on anyone's workbench, much less a workbench belonging to a klutz, but many home-brew products will spend a great deal of time on such workbenches. Further, home-brew boards are often made without solder mask, greatly increasing the likelihood that of stray ground clip or probe making an unwanted contact.

In addition to providing protection against accidental bridging, if there are two full isolation barriers it may be possible (if one is careful) to bridge one while doing diagnostics involving the other while maintaining an isolation barrier between the two main parts of the system. For example, if one wants to determine the amount of time that elapses between the processor setting an output and a solenoid receiving power, one could start by confirming the relay-coil ground and contact-side ground were isolated, bridging the relay ground and CPU ground, and measuring the time between the CPU output and the relay coil. One could then isolate the relay-coil ground and CPU ground and--after double-checking that they really were isolated, bridge the relay-coil ground and contact-side ground and measure timings between the coil and the things they control. Performing such measurements in a system with only single isolation would probably require having a scope with two probes that were isolated from each other. Such rigs exist, but they're generally expensive.

share|improve this answer

I suspect that this is just a case of hobbyists who are trying to start a circuit board selling business. They may be complicating their board simply to make it look more complicated, because complication justifies the existence of electronics and appears to add value.

I'm sure if you contact the vendor, they will have a convincing story that their circuit is how it has to be done, and they have it ready-made, the easiest thing is to just buy their board.

Everything you need to control an AC load with a small voltage and current can be found in a single component: a solid state relay like this one.

Any board that can drive 20 mA into an LED can use this, which means that you don't need a special board.

share|improve this answer
I like SSRs a lot. They do have downsides - failure mode is often on, and they have a not-insignificant on resistance. – Cybergibbons Feb 27 '13 at 20:35

A very good reason is to have separate power supplies for the logic and the power interface parts. Logic section is in normal design powered at 5V or 3.3V, and galvanically isolated from the power section, where the most common supply is 24V, so an optocoupler is necessary.

It is true that it can be avoided using a relay with coil rated for 5V, but many relays are not available with this coils, and it would be necessary to have a much higher power on the 5V side, with a bigger DC/DC converter.

It is more common to use the field unregulated supply, 12V or 24V, automotive or industrial (relays do not need a very precise voltage), and a small galvanically isolated DC/DC converter to derive the 5V / 3.3V for just the logic section, so the isolated couplers are necessary.

share|improve this answer
There are loads, upon loads of 5V relays to be had. Thousands at Mouser alone. Some of your other points are valid enough, but that paragraph is unnecessary hyperbole. – Asmyldof May 14 at 12:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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