Two channel relay trouble using Yun

So I am using an Yun in a project. I just added a SainSmart 2-Channel 5V Relay Module into the project. The trouble I am having is getting both coils to fire at the same time. Each relay is


wired to their own digital pin for control.

When I activate both coils only one contactor will activate but both LED's will light up as if they are both working. I can activate each coil separately no problem. When I try to activate both at the same time only one will activate. Reading the documentation of the Yun, I see that each digital I/O pin is rated to 40 mA. The relay module documentation says that each coil requires 15 - 20 mA of current. Am I reading this correctly? Any thoughts or do you see something that I need to change?

Thanks in advance...

How are you powering the relay board? The trigger input only needs 15-20 mA, but that's just to trigger the isolation circuit and LED. That isolation circuit then triggers the actual relay, which needs more current than that. It sounds like you are not providing enough power to the board.

The board should have an option for an independent power supply - you should use it and the relays itself, and whatever they are controlling, should be powere independently from the Yun.

They make several different versions of relay boards, just saying its two channels is not enough to positively identify your board. Knowing exactly which relay board you are using, and exactly how you have it wired up, will let us give you a better answer.

Can you post your code (between the code-tags)?
This is always helpful if your are asking for help since it helps use see what is going on...

Have you tried a different power supply?

A drawing of your circuit would also be helpful!

arjan_hes:
Can you post your code (between the code-tags)?
This is always helpful if your are asking for help since it helps use see what is going on...

I generally agree, and often ask to see code, but I specifically didn't ask for it this time. He says he can see both LEDs come on, but not both relays. It seems to me that software is not the issue this time, it seems pretty clear that this a power or wiring problem.

Thank you both for your reply!

I have confirmed that it's not a code issue. I would agree with ShapeShifter that it is a current issue. To me it's exhibiting a condition when there is not enough current to drive the coil.

I have the 5 volt power supply in a separate enclosure from the processor. In that same enclosure of the power supply I have the relays mounted. So the power supply is right next to the contactor. Currently I run the 5 volt power from the power supply up to the Yun. I then run power from the Yun back to the enclosure and connect power and the digital pin(s) to the contactor (relay module).

I would rather power the relay module direct from the power supply. I haven't read through the documentation of the relays on how to do this properly. Initially I tried to power the relays directly but it wasn't working for me so I wasn't doing it correctly. Initially I had run the 5 volt power supply directly to the VCC and the GND on the relay board and a wires from the digital pins on the Yun to the IN1 and IN2. Again this didn't work.

The following link to Amazon.com is the very relay module that I bought:
http://www.amazon.com/SainSmart-2-CH-2-Channel-Relay-Module/dp/B0057OC6D8?ie=UTF8&psc=1&redirect=true&ref_=oh_aui_detailpage_o05_s00

If you could enlighten me on the correct form of wiring directly from the power supply to the relay module I would greatly appreciate it! Save me some time reading through the documentation.

Hope this give you enough information of what I am experiencing. Thank you!

Looking at the manufacturer's page, that looks to be this module: http://www.sainsmart.com/arduino-pro-mini.html

From that same page, the schematic is:

Not shown in this diagram is the three pin header block which has these signals:

  • JD-VCC
  • VCC
  • GND

To isolate the Yun and the relays, you must:

  • Remove any jumper block that is on the three pin header block - very important!
  • Connect your relay power supply +5V to the JD-VCC pin of the three pin header block
  • Connect your relay power supply ground to the GND pin of the three pin header block
  • Connect the Yun's 5V header pin to the VCC pin of the 4 pin I/O connector
  • Connect the Yun's control pins to the IN1 and IN2 pins of the 4 pin I/O connector
  • The VCC pin of the three pin header, and the GND pin of the 4 pin header have no connections
    The Yun will, of course, need power as well (either through the USB connector, or VIN pin.)

With this scheme, the relays are powered directly by the JD-VCC source. The isolated inputs are controlled by the IN1 and IN2 inputs, but they are not referenced to ground - the Yun is not providing power into these pins to control the outputs. Instead, you must give the Yun's power to the VCC pin (it will only power the optoisolators, not the relays) and sink the current using the Yun's digital I/O pins. This means it will work the opposite of what you would expect: making the output HIGH turns the relay off, and making it LOW turns the relay on.

That is very generous of you! Thank you. It will be later in the week that I will be able to put my efforts to this change. I will update you once I have made these changes.

Thanks again!

My apologies to you ShapeShifter! I never followed up with you on this thread. What you provided to me worked perfectly! You saved me a lot of time and got me going really quick. Thanks again for your efforts in your response.

Thank you for the follow up! You're very welcome, I'm glad it worked out for you.

Hi Shapeshifter

Can I consider Relay board as a voltage-controlled switch that can pass high voltage and current?
What's the application of a power relay for IOT?

Can it be used to control home appliances or work like a fuse?

Yes, you can use relay as a voltage controlled AC switch.
Here’s an 8-relay shield I make, you shift data into a shift register and control AC relays.

This card is a shield that plugs on an Uno. I also make it as a standalone card. Here’s 3 of them daisychained

tim9510019:
Can I consider Relay board as a voltage-controlled switch that can pass high voltage and current?

Yes. As Crossroads points out, a relay is basically like a mechanical switch that can control high voltage and/or high current (within range of the relay's specifications.) But unlike a mechanical switch, it uses a low voltage/low current signal to trigger the switch rather than using a mechanical lever or button.

What's the application of a power relay for IOT?

The applications are virtually limitless. If you want to control something small like an LED, the processor can control that directly. But if you want your project to control something that takes more power or voltage than the processor can handle, then a relay is one of the many ways it can be done.

Can it be used to control home appliances or work like a fuse?

Yes, it can control a home appliance, as long as the relays' ratings (contact voltage and current limits) are sufficient. There are a wide range of relays ranging from small signal relays that can only handle low voltages and currents, to large power relays that can handle high voltages and currents.

I don't know what you mean by "work like a fuse." A fuse is a safety device that opens a circuit if there is too much current flowing. That is not normally what a relay does. Although one could make a circuit to detect the current, and activate the relay if it is out of bounds, I wouldn't normally recommend that for most situations: an actual fuse will be much cheaper and more reliable.