Using relay module with arduino

Hi all,

I want to use a relay module with arduino
I already have a 24VDC power supply to power the relay module and I can use something like this CAR DC TO USB to power the arduino
http://www.ebay.com/itm/like/172041617965?lpid=82&chn=ps&ul_noapp=true

I have 2 questions regarding that:

  1. On the relay module I have 1 pin for vcc 1 pin for gnd and other pins called In(1-4) for the 4 channels on that relay. If it says the the relay module is 24V, can I connect its vcc and gnd to the power supply and the In(1-4) channel pins connect to the arduino (5V) digital pins? Or does a 24V relay module means the In pins are also of 24V

  2. Even if the answer for the first question is "yes it would work" is it ok to connect this relay module directly to the arduino digital pins or should I use transistors that the power sides will be connected to the power supply and to the In pins and the arduino will only "switch on" the transistor?

Relay module link (24V 4-Channels):

Thanks in advanced!

Hello,

As far I undestood your problem, I got just one question before. Why didn't you choose the 5 V version to directly control it with the arduino ?

Gronjus:
Hello,

As far I undestood your problem, I got just one question before. Why didn't you choose the 5 V version to directly control it with the arduino ?

Thanks for you reply,

As far as I understood, the arduino itself cannot supply power to many relays, therefor, using an external power supply (of 24V which I have already got) is the most logic thing to do as I see it...

Well, I think you're mistaking a bit . Let's say that you got the 5 V version, you plug the 5 V from arduino into vcc , gnd to gnd and the the input pin to one of the entry on the board. Current needed to make the relay toogle is about 15 or 20 mA which can be given by the arduino. On the other side, you got your power supply of 24 v and the device you plugged in .

So to resume, you activate to high on entry from the arduino which activate the relay who can let the current flow through it.

Refer to this link, there's two pictures that explain surely better than me :slight_smile: : https://www.hobbyist.co.nz/?q=interfacing-relay-modules-to-arduino

However, this is for a 5 V version as I told you because this a lot easier than the 24 version. For the version, you will have to play with mosfet which is more work.

Since you already have the 24volt supply, and the 24volt relay module, connect both like this.

Remove the JD-VCC jumper (throw away).
Connect the 24volt supply(+) to the JD-VCC pin (not to the VCC pin!!!)
And supply(-) to relay module ground.

Connect VCC of the long strip to Arduino's 5volt pin, and the relay inputs to Arduino output pins.

DO_NOT_CONNECT_RELAY_GROUND_TO_ARDUINO_GROUND.

Power the Arduino with a separate 5volt supply (e.g. 5volt cellphone charger on the USB socket) if you want opto isolation (safer if you are switching mains powered devices).
Or use that buck converter you have if you don't care for opto isolation.

In setup(), write a HIGH to the relay pins BEFORE setting the pins to OUTPUT with pinMode.

digitalWrite(relay1Pin, HIGH);
pinMode(relay1Pin, OUTPUT);

That will stop relay chatter during bootup.

Gronjus:
Current needed to make the relay toogle is about 15 or 20 mA which can be given by the arduino.

Refer to this link, there's two pictures that explain surely better than me :slight_smile: : Step 2: Interfacing the relay modules to the Arduino | Hobbyist.co.nz

Make that 2mA pin sink current.

The link is for a different non-opto isolated relay board.

Leo..

Leo thank you for your detailed answer but with many details come some confusion.

  1. What is the purpose of the JD-VCC jumper?
  2. How does the JD-VCC differ from VCC
  3. How do I know if a specific realy module (for example the one in the link) is an opto-isolated or not? (let's say nothing is written about it in the description)
  4. I am planning to connect my home 220V AC to the relay. How do I know if I should or shouldn't care for opto isolation?
  5. Why is this so important? "DO_NOT_CONNECT_RELAY_GROUND_TO_ARDUINO_GROUND"

Many thanks

Hi,
Here is a diagram of the way the opto-isolation works:

JD_VCC is the power to the RELAY coils. In your case that is 24V.

I think terryking228 answered most of it.

The optos are the small rectangular black blocks with four pins.
The board in the other link doesn't have them.

JD-VCC is the 24volt relay coil supply and VCC is the 5volt Arduino supply.
Could be unhealthy for the Arduino to mix them up.

Relay ground is connected to relay coil ground (see diagram).
If you share that with the Arduino, then you loose the opto isolation.
Ground is not needed to drive the opto LEDs, because they are powered/connected between VCC and relay inputs.

Opto isolation is wise if you use the relays for 240volt mains.
The boards are not specified for mains power use, and opto isolation gives a second layer of protection
Opto isolation means the 24volt supply has to be used exclusively for the relay board(s).
Leo..

relays have 3 possible power supply connections.

the Output is isolated from the coil and logic, and really the only possible connections are the leaks in the PCB. the relay PCB has a physical cut out of the PCB around the Common pin, in an effort to prevent these sort of leaks.

the second power supply, the coil voltage, is determined by the coil manufacturer and you must supply a voltage that will supply power to the coils.

Since this board has opto-isolators, you have the possibility for that 3rd power supply.

the jumper for VCC and JD-Vcc will connect your coil power supply to the opto's thereby tying the two power supplies together and removing one layer of isolation. but, then all you need to do is to bring that line to ground and then the coil operates.

as you can see in the manual for the board, or the post that Terry King posted, the opto can also be powered strictly and only with the Arduino on Vcc. if used that way, the opt-isolators appear to be simple LED's to the Arduino. a resistor is needed like any LED you might drive.

using the opto-isolators independently of the JD-Vcc gives you better isolation, and tying the grounds together defeats that.

dave-in-nj:
Since this board has opto-isolators, you have the possibility for that 3rd power supply.

Wrong link, I meant to a board which does not have opto-isolators.
Is there any way to connect such 24V non opto-isolated board to a 24V power supply and switch it using a 5V arduino?

Non-opto isolated relay boards with 24volt relays (if they exist) must have ground as common for all the inputs.
Not common VCC, as opto isolated boards.
Leo..

Wawa:
Non-opto isolated relay boards with 24volt relays (if they exist) must have ground as common for all the inputs.
Not common VCC, as opto isolated boards.
Leo..

Thank you Leo,
So just to sum it up, and in order to learn the working principles, let's say such module exists, for the discussion, and inputs have ground as common (which means arduino digital pins acts as ACTIVE HIGH):
There is no problem to have a common ground to the 24V power supply and to the arduino, correct?

And the 75mA or so, for driving the coil of the relay, will be drawn from the power supply and not from the arduino, is that correct as well?

Both correct.

Common 5volt sugarcube relays draw about 75-80mA.
From memory, the 12volt types are about 35mA.
There is a datasheet for those blue relays online.
Leo..

Wawa:
Both correct.

Common 5volt sugarcube relays draw about 75-80mA.
From memory, the 12volt types are about 35mA.
There is a datasheet for those blue relays online.
Leo..

You are awsome Leo. Thank you so much. So I will go with Opto board anyway as I will be powering AC main 220V and will isolate arduino from the relay board.

BTW, I have just thought of a case where someone will connect a power supply +v to JD-VCC and arduino 5V to VCC and BY MISTAKE, will also connect both JD-VCC and VCC pins (basically tying together arduino's 5V with a power supply's +V (it can be 5V or 12V or 24V). What happens in such case?

If I generalize the question: What happens in a case where you connect +5V or arduino to +V of a power supply? (let's assume grounds of both are tied together)

Hi,

Data sheets on those relays are linked on this page: ArduinoPower - ArduinoInfo

Scroll down to "Relay details and Data Sheets"

yanivps:
If I generalize the question: What happens in a case where you connect +5V or arduino to +V of a power supply? (let's assume grounds of both are tied together)

If you connect 12volt/ground to a relay board, and the same 12volt/ground to VCC/GND of the Arduino...

Well, I leave that for you to find out.
Stand back a bit though, and wear protective glasses.
Leo..

Wawa:
If you connect 12volt/ground to a relay board, and the same 12volt/ground to VCC/GND of the Arduino...

Well, I leave that for you to find out.
Stand back a bit though, and wear protective glasses.
Leo..

LoL you've made your point.
But, as people always state the current flow in a circuit. Why current from the power supply would bother going to the arduino VCC instead of flowing back to the negative terminal of the power supply?