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?
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.
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..
taterking:
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.)
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?
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.
taterking:
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..
taterking:
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:
MHotchin:
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.
taterking:
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.