Go Down

Topic: relay module (Read 286 times) previous topic - next topic

taterking

so i have purchased some relay modules to trigger AC on and off with my arduino. On the relay boards there are some blinky lights and some little black boxes (im not sure what they are) and maybe some resistors?

anyways, i would assume a relay should be a simple component. is there any reason i can just purchase the big blue box with the five pins and hook it up directly myself instead of using the module? besides the cute lights and connectors is the rest necessary?


raschemmel

Post a link to the relays you bought.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter


larryd

#3
Jul 22, 2019, 05:45 am Last Edit: Jul 22, 2019, 05:49 am by larryd
The cute lights tell you at a glance if the relay is picked or dropped.

The black box can be a transistor which the Arduino can can drive, the transistor then drives the relay.

There maybe an optocoupler to provide galvanic isolation between the Arduino and the relay.

The red cylinder stops relay switching noise.

The terminals are there to provide easy connections to the load.






No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

raschemmel

The little black 'boxes' are 4- pin opto isolators.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

sterretje

Yes, there are some good reasons not to hook up just the relay.
1)
Relays draw more power than an arduino pin can deliver. So you need a transistor/fet/optocoupler to amplify the signal.
2)
When a relay switches, high voltage spikes occur on the relay coil. You need a diode to suppress those.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Wawa

That's a proper relay module, with everything on it.
Optional opto isolation (the JD-VCC jumper), optos (the black cubes), and transistors (Q1, Q2 on the corners of the blue sugarcube relays).

Some Arduinos can power two relays, depending on how you power the Arduino. Others can not.
For opto isolation (safer when switching mains power) you must use a separate relay supply (JD-VCC/ground, with jumper removed) and you must NOT share relay ground with Arduino ground.

These relays require special setup code to prevent chatter on bootup, and inverted logic (LOW = on).
Post the details of your project if you want specific help.
Leo..

meltDown

#7
Jul 22, 2019, 07:21 am Last Edit: Jul 22, 2019, 07:26 am by meltDown
is there any reason i can [sic... can't ?] just purchase the big blue box with the five pins and hook it up directly myself instead of using the module?
And besides the good reasons already given, it's waaaaay easier to hook up the mains wires to the blue screw terminals, and the Arduino signals and relay coil power to the male pins, than to have to bugger around bodging connections to a loose blue cube. (edit... Which blue cube will then be hanging on those wires with no easy way to mount it securely in your project, compared to the mounting holes on the module.)






taterking

so what i am gathering the jumper "on" disables isolation between the input pins and vcc?

please comment if i am getting this correctly from your helpfull info you guys posted.

so arduino's 5 volt pin is not sufficient power for the relays vcc? so to use multiple relays, i would need to remove the jumper? and connect the vcc to a more sufficient 5 volt power supply. then trigger the inputs with a digital write? and my seperate 5 volts is safely seperated from my input pins?

MHotchin

The five volt supply *may* be enough.  The output pin used to trigger the relay definitely is NOT enough, so you need a transistor in there to actually drive the relay coil, and a flyback diode so you don't fry your output pin.

Wawa

#10
Jul 23, 2019, 06:01 am Last Edit: Jul 23, 2019, 06:01 am by Wawa
so what i am gathering the jumper "on" disables isolation between the input pins and vcc?
No, it disconnects/separates Arduino power from relay power.
With jumper on, the relay coils (~75mA each when active) are powered from the Arduino,
with jumper off, you must provide external relay power to the JD-VCC pin (and relay ground).

Not talking about control signal(s) here.
Control happens between relay vcc and relay inputs.
Relay ground is not involved in controlling the relay module.

As said, if you want opto isolation, then remove the jumper, use external relay power, and don't share grounds.
If you do a search on this site, then you find plenty of connection diagrams showing this.
Leo..



MHotchin

As said, if you want opto isolation, then remove the jumper, use external relay power, and don't share grounds.

I don't think separate grounds are possible with this module - they're tied together on the board.  I suppose cutting the trace is an option....

meltDown

#12
Jul 23, 2019, 06:31 am Last Edit: Jul 23, 2019, 06:38 am by meltDown
i would need to remove the jumper? and connect the vcc to a more sufficient 5 volt power supply.
No, with the jumper off, the JD-Vcc pin goes to that new supply. Vcc always goes to the Arduino 5V, to provide the power to the led inside the optocoupler on the relay module.

The connections to that style of relay board are shown below:



This youtube video explains those modules very well.


meltDown

#13
Jul 23, 2019, 06:37 am Last Edit: Jul 23, 2019, 06:45 am by meltDown
I don't think separate grounds are possible with this module - they're tied together on the board.  I suppose cutting the trace is an option....
See pic in previous post. The external supply ground goes to the module ground; do not connect the module ground to the Arduino ground, if the jumper's off.

The signal circuit is Arduino Vcc through the optocoupler's led, to INx to a low Arduino data pin.




Paul__B

so arduino's 5 volt pin is not sufficient power for the relays vcc? so to use multiple relays, i would need to remove the jumper? and connect the vcc to a more sufficient 5 volt power supply. then trigger the inputs with a digital write? and my separate 5 volts is safely separated from my input pins?
I spot a common matter of concern here.

The suggestion of "powering" something from the Arduino's "5V" pin indicates a fundamental misunderstanding.  The Arduino is not a "power supply".  This suggests that you are either attempting to supply 5 V power through the USB connector which is specifically limited to 500 mA in total (by the polyswitch on the UNO) or even worse, attempting to supply power through the on-board regulator.

The clear blunder is not comprehending what the "Vin" or "RAW" terminal is.  The regulator on the Arduino UNO/ Nano/ Pro Mini/ Mega2560/ Leonardo/ Pro Micro has very little heatsink, so will not pass very much current (depending on the input voltage and thus, how much voltage it has to drop) before it overheats and (hopefully reversibly) shuts down.  It is essentially a novelty provided in the very beginning of the Arduino project when "9V" power packs were common and this was a practical way to power a lone Arduino board for initial demonstration purposes.  And even then it was limited because an unloaded 9 V transformer-rectifier-capacitor supply would generally provide over 12 V which the regulator could barely handle.

Once you are actually using the Arduino for a serious project, you need to provide 5 V power for that project, generally with some sort of switchmode supply; a mains supply or a switchmode "buck" converter if powering from 12 V or an automotive application.  This power supply can then power the Arduino via the "5V" pin.

On these relay modules, you can provide isolation between the Arduino controlling the inputs to the opto-couplers and the relays themselves to avoid switching transients from the relays (or the circuits they are switching) interfering with the Arduino operation.  To do this, you must keep the wiring to each part separate and keep the wiring to each part together as a bundle, the control wires and the "5V" to "VCC" as one bundle from the Arduino and the "GND" and "JD-VCC" powering the relays themselves, as another bundle to the 5 V power supply.

If you follow that discipline, you can power the relays from the same 5 V supply as the Arduino given that the regulated 5 V supply is capable of providing sufficient current to all parts without losing regulation and that you run separate pairs of 5 V and ground wires (such as "figure 8" cable or ribbon)  from the output terminal of the 5 V supply itself to the Arduino and independently, to the relay module.

Go Up