Relay Module wiring

Hi all

I'm a programmer of many years, but I am new to the electronics world. As a project I want to control some heating and pumps from an Arduino by reading DS18S20 thermometers. I've written a C# program to perform the main processing logic and pass requests to the Arduino to do the switching, which the interface works great so far.

I received a 8 Relay Module http://www.aliexpress.com/fm-store/312788/210933836-481242970/free-shipping-8-Channel-5V-Relay-Module-for-Arduino-PIC-ARM-AVR-DSP-wholesale-price.html (not purchased from here, but is has the main info on it) to allow me to switch the loads of the pumps and heating.

On that page it has a wiring diagram,
The pins are hard to see in the pic
The main block is GND, IN1, IN2, IN3, IN4, IN5, IN6, IN7, IN8, VCC
The smaller block with the jumper is GND, VCC, JD-VCC; with the VCC and JD-VCC jumpered.
Now I assume the jumpers allows the relay module to take power from the VCC of the main pin block.

To test wire it up I ran
ARDUINO +5v to VCC on the main block
ARDUINO Earth to GND on the outer smaller block
Digital PIN 9 to a IN1 (also tried other IN pins)

I set the ARDUINO to
pinMode(thisPin, OUTPUT);
digitalWrite(thisPin, HIGH);

Now when the digital out is HIGH, the relay is OFF
When it is LOW, the relay is ON

I though it would have been the opposite?

Also as a side question; when want to run it properly with more than one relay I'm going to feed power from an external +5v power supply. How should I wire it then?

Thanks in advance

Kev

edit: I should add when I jumper a LED across the pin and earth it behaves as expected.

When your output is high the IN terminal sits at VCC so U1 is turned off. This means the transistor is also turned off so there is no voltage across the relay - hence the relay is de-energised. If you want a reversal then invert the Arduino outputs.

To power from an external supply simply connect the board GND to the Arduino GND, connect VCC to the Arduino VCC and connect your external supply -ve to GND and +ve to JD-VCC. Remove the jumper, it is no longer required.

Thanks for the response. I understand what you have said, but from a non-electronics background it seems weird that it outputs when there is no feed from the ARDUINO to it; but if thats the way they have selected the transistors then thats how it is. Is there a way I could invert the transistor inputs so in the event of no power from the ARDUINO the relay would be off, hence in a power failure to the ARDUINO the relays are off and not causing possible issues with over heating on the output?

Thanks for the extra external wiring info for the external power pack, when I read it I thought how easy it sounds and can't believe I did not think of it up front.

Kev

Thanks for the response. I understand what you have said, but from a non-electronics background it seems weird that it outputs when there is no feed from the ARDUINO to it;

There is a good reason for this. Think about what happens at at startup/reset. All Arduino pins are inputs and could float HIGH. With a little pullup, like the circuit on those relays, they WILL be pulled high. So relays are OFF which is goodness at power-on.

See the schematic for these here:
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=156

However, you also need to make sure that when you DO set the Arduino pins as OUTPUT that the signal will be HIGH. See following for code example of how to do that: http://arduino-info.wikispaces.com/ArduinoPower (Scroll to "Complex Systems")

(excerpt)
IMPORTANT NOTE: There is a issue with start-up of Arduino programs that control these relays. These relays input controls are Active LOW, meaning that setting a pin LOW turns them ON. To assure that no relays activate at Reset or Power-On until you want them to, the initialization sequence in SETUP should be:
digitalWrite(Relay, HIGH);
pinMode(Relay, OUTPUT);
(end)

Excellent responses. Thanks for the links to that site it does clarify all I needed to know with great descriptions.

Can't wait to get this all up and running.

QldKev

I'm sorry for this revive but i really can't understand why i shoud connect the relay this way:

jackrae:
To power from an external supply simply connect the board GND to the Arduino GND, connect VCC to the Arduino VCC and connect your external supply -ve to GND and +ve to JD-VCC. Remove the jumper, it is no longer required.

If i connect the arduino VCC (in my case +12V) to relay's VCC i will have relays always on (with 12V or 7V on the circuit) since In1 can only grow to 5V... Isn't better to connect arduino's +5V to relay's VCC and +12V to JDVcc?

PS: I realized that my relays are 5V so i think i can't connect the power side to a 12V source :\

You have to use 5V external power supply to power the relay module. And it's true to connect 5V of the Arduino to VCC of relay module.

Hello, I need your help :slight_smile:
How to connect 2(two) 8-channel relay module in one Arduino Mega 2560 ?

Connect 8 IO signals, Gnd, and 5V to each. Connect separate relay coil power & Gnd to each.
Drive IO signals high or low as needed to turn on the coil & energize the relay.

For the two 8-relay modules, the power supply should be rated for at least 2A.
http://forum.arduino.cc/index.php?topic=374728.msg2585056#msg2585056