Go Down

Topic: Wrobot / Emartee / Ywrobot relay board... (Read 19 times) previous topic - next topic


Hey Terry,
I'm so glad I found this thread. Your website was everything I was looking for. I'm somewhat new to Arduino and brand new to Arduino relay breakout boards. Since the documentation is scarce on the Relay Module from SainSmart, your tutorial was key in understanding how to move forward with this piece so thank you so much!

There's a Sparkfun tutorial http://www.sparkfun.com/tutorials/119 that picks up from where you left off as far as creating a safe connection to a wall outlet. I don't have all of the parts with me tonight but I now know what to get.

So thanks again and I'm going to be combing through your website for sure!



Hi Eric,

Thanks for that pointer; I've seen a couple of things like this but that is the best description I've seen: http://www.sparkfun.com/tutorials/119

Most outlets (AKA "Duplex Receptacles") can be separated into two circuits. Usually there is a small metal link that can be broken off.  Then a small 2-relay board like this could be used to control two separate things plugged into the two receptacles:  http://goo.gl/jJRYM

Another good possibility is to use a small optically-isolated "Solid State Relay" that can be easily driven by Arduino.  Example: http://goo.gl/jbNwl

I really prefer the optically-isolated relays: Your Arduino is doing nothing but turning on an LED inside the relay driver.

More relays here:  http://goo.gl/8ZEQ8

DISCLAIMER: Mentioned stuff from my own shop... which is what I know about!
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info


May 27, 2012, 03:48 am Last Edit: May 27, 2012, 05:56 am by Karoly Reason: 1
I have this Ywrobot Relay board. I've built a remotely controlled power outlet with it. It works perfectly well when nothing is plugged into the outlets. However, when I plug a lamp or anything into the outlet and switch the relay, Arduino frequently locks up.  I guess this board doesn't do a great job of de-coupling the power supply. Any idea how I could improve it? Adding a capacitor or an inductor to the board perhaps?

Here is the circuit of this relay board:

And here is a link with some additional pictures: http://www.ebay.com/itm/Two-2-Channel-5V-Relay-Module-Expansion-Board-For-Arduino-ARM-PIC-AVR-MCU-DSP-/221009967173?pt=LH_DefaultDomain_0&hash=item3375387845.


May 27, 2012, 11:56 am Last Edit: May 27, 2012, 12:06 pm by terryking228 Reason: 1
There are two things to consider here:

  • Isolation of Arduino from the relays themselves and their switching transistors and power supply

  • Isolation of your power wiring from arduino and it's wiring

Let's look at the choices of relay boards. There are two widely available types of relay boards, and lately they cost about the same.

  • Boards with a common Ground and +5V supply between the Arduino and the board.(The one you show above)

  • Boards with optical isolation that can be run with no direct electrical connection between Arduino and the relays and their power supply.(Which I will show below)

"Optically Isolated" means an "Opto-isolator" chip is used. See: http://en.wikipedia.org/wiki/Optoisolator So only a beam of Infrared light (The little blue arrows in the diagram below) connects the Arduino circuitry to the relay and switching parts. Here's what an opto-isolated board looks like, followed by it's circuit diagram, and a photo of the opto-isolator chip:

More details of this opto-isolator are here: http://arduino-info.wikispaces.com/Popular-ICs  (Scroll down).

Let's look at how to connect the relay board so it is really isolated. Notice that board has a jumper between "Vcc" and "JD-Vcc". Remove it.  For complete optical isolation, connect "Vcc" to Arduino +5 volts but do NOT connect Arduino Ground.  Connect your Arduino Digital Output pins to "IN0", "IN1" etc.  Connect a separate +5 supply to "JD-Vcc" and board Gnd. This will supply power to the transistor drivers and relay coils. Look at the diagram above. Only the part to the left of the small blue arrows is connected to Arduino.

Wiring and cabling issues:
You're not home free yet, because if you are switching large loads, especially inductive loads like motors, etc. you may still have "EMI" (ElectroMagnetic Interference) problems.http://en.wikipedia.org/wiki/Electromagnetic_interference

People who have designed computer-driven automated machinery know that they have to be careful about the physical routing, shielding, and isolation of low-level computer/Microcomputer electronics and high-power motors and loads.   Here are a few guidelines:

  • Physically separate the low-power Computer/Electronics part from the large power-handling part

  • Pay special attention to Grounding: Create a single common ground point in the power section. Connect the Computer/Electronics ground to it at only that one point.

  • If possible locate all the power switching devices/relay in the power section, as close to the load as reasonable

  • Run connections to the relays etc. from the Computer section to the Power section in shielded twisted pair (or at least twisted pair) wiring.

  • Minimize the Electromagnetic Interference put out by the loads by putting suppression devices like MOVs (Metal Oxide Varistors) across them.

  • Test the switching by attaching a simple light bulb load. When everything works, try the real heavy load. Then you will know if you have EMI problems.

OK, that's a big deal. What can we do that's simple and helps? I'd suggest this:

  • Locate the relay board close to the load, (like in the outlet example)

  • Locate a separate 5V supply near the relay boards, plugged into the Load power, not near the Arduino power supply or a computer supplying USB power to Arduino.
  • Run CAT5 cable back to Arduino, one pair for +5V and Arduino ground (NOT connected on the relay end if you have opto-isolated relays), One pair for each signal, with one wire connected to ground at Arduino, the far end unconnected

  • Run the Arduino from a separate 9V supply, not USB connected to a computer

Maybe we can start another thread just about relays and power switching in general. Opinions??

More about power/relays here: http://arduino-info.wikispaces.com/ArduinoPower   Lots of relays here: http://goo.gl/8ZEQ8

Lots of people are successfully controlling lighting, home devices, complex aquariums, Aquaponic Systems , etc etc. with relays like this.

DISCLAIMER: Mentioned stuff from my own shop...!

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info


Thank you for your detailed response. It looks like I will have to replace my relay board with one with optical isolation. I hoped I could avoid that because it is already built into a custom box. Ah, well...

Go Up