Connecting a Relay Module to a Microcontroller
ฝัง
- เผยแพร่เมื่อ 4 พ.ค. 2024
- Today we are driving high current high voltage applications using only a microcontroller and relay. To accomplish this, we are going to take a closer look at a few different types of relay modules you might find across the Internet. We will first go over the components and connections available on each module, then we will go over the schematic to get a better understanding of how each module works, and finally we will demonstrate how to connect these modules into our circuits. Throughout this video I will touch on important considerations to mindful of to ensure you don’t damage your microcontroller or worse the item connected to the relay.
00:00 Intro
00:39 Hardware Overview
02:56 Relay One Schematic
06:22 Relay Two Schematic
07:53 Relay Three Schematic
08:20 Demo with External Power Supply
09:52 Demo without External Power Supply
11:19 Recap
Hardware:
SainSmart 2 Channel Relay: amzn.to/3l74TXi
HiLetgo 5V High/Low Relay: amzn.to/3crUelR
Tolako 5V 1 Channel Relay: amzn.to/3vlcWUU
Elegoo Uno Project Kit: amzn.to/3uq6YSd
Breadboard: amzn.to/2Npu9f5
Elegoo Uno R3 Board Only: amzn.to/3dCMpMA
Helpful Links:
www.arduino.cc
www.sparkfun.com
www.adafruit.com
www.mouser.com
www.digikey.com - วิทยาศาสตร์และเทคโนโลยี
Thank you for this video! Every other video I've found has only explained how to plug in a couple wires. You actually explained how things work and why they're set up in a certain way, which is exactly what I needed. Thank you!
This is the best explanation of relays that I have ever encountered for so long. Thank you so much sir for this.
Top quality. Clear and concise. Thanks for the video!
Brad, I really want to see more videos like this. If it is luck or what, I was trying to figure out a way to operate my relay with active high signal and I found this video right here. You have been a huge help. Subscribed.
you are my lifesaver for understanding relay module, I was about to make the diagram in everycircuit and when I try to run it, the page says I gotta pay, so I was lil bit frustated, then I finally watch this video, thanks sir
Refreshing to see a clear video on the subject. One thing to note and I wished more presenters did was talk to their audience like we are just home DIY's not knowing schematics and just visually seeing how to wire everything together. I've never used a breadboard so wouldn't even know where to plug something into it. We just want the pertinent info and move onto another subject.
I've been trying to find a good explanation of how to wire these relays, the 3 pins on the load side confused me, but you cleared it up really nicely. Thanks!
Very nice explanation. Thank you for sharing your knowledge !
This was a really clear video, well-explained. In particular, I was interested in understanding what JD-Vcc was doing and why the jumper is there/not there. Thank you.
I don’t care what your subject is all the best teachers have passion for their subject. We saw that in spades here along with very clear explanations.
Brad, Thanks. So helpful. You saved my board.
Thank you Brad, that was a very well explained demonstration
Excellent video. Rare to see an explanation of the circuit with cause and effect.
Finally, the mystery between the relay modules are resolved for me, Thanks!!!!
Awesome, thank you.
Great tutorial, thanks a bunch.
Great vid Thanks for sharing you said: I created all of the wiring schematics in the video using Adobe After Affects.
Great demonstration and so helpful thank the video.
Thank you for the video. You nailed all of it.
Adding this to my tool box!
thank you, great explanation of various module type and it circuit schematic
Thanks for the video, very informative. I would have liked to see the optocoupler based relay driver schematic with component names and values so that I could have tried making my own in a custom PCB.
Bundle oF Thank,s For your supper good Explane every point from A to z Thanks Alot.
Very explanatory. Many thanks.
Thanks for your video. Excellent explanation.
Super video. Great clarity
Great video, I definitely subscribed to watch more like this. It was a really good explanation.
Thanks for the sub!
Very well done.
It's very useful. Thank for your video
Excellent video, and you solved my issue at 5:45, thanks a lot.
Thank you for the video.
Awesome explanation 😍😍😍👌👍
this video is insane, thank you
Superb. Thank you!
really useful brad thanks for that. can you give us some tips how to find good quality relays? dealing with 230V I want to avoid bad quality components which may cause a fire in case they break.
Thanks for knowgable video sharing.
Excellent video. Thanks for sharing and do make more videos like this.
Thanks, will do!
very good video ! Thanks!!!
Thank you for your video. Its very informative and interesting.
Thank you.
@@hensonbl so if i am not using jumper to avoid any feedback> can i use same 12 v dc power supply source to give 12 v to jd vcc and same 12 v to vcc pin ...in DC plc output side ?
i tought theres nothing to learn about driving relays .. but i was wrong so much informational video!! thanks :)
Glad it helped!
Awesome!
thanks for the video, now i know what the JD-VCC is used for
i was going to use this relay for turning on a second PSU for computer as before i just use a relay and diode drive 12v dc from the main PSU and been working ok for years i just like to add a bit more protection
this this most beautiful video. thanks for your parents for making you
Will be good to have the calculation on the resistor, diode, transistor.
Nice video bro would you please explain us how the nrf433 hz relay module does work🙏
Hi Brad,
From what I understand, if I'm not using an external power source, it's not possible to reverse the pins in order to activate the relay when the pin is high or is it? I'm talking about what you discuss at 5:35 of the video.
Thank you for this really great video, I've understood a lot thanks to you!
Best video about relay so far, I wonder is it necessary to use opto-isolator when they share the same ground or even same source? Also it would be great if you also mention the resistor values.
You want him to list ALL of the resistor values for EVERY relay module out there?
@@AztecWarrior69 Yes, it’s necessary for a schematic. I can send you those values if you want.
quality tutorial, nice.
Thanks!
Nice video, thanks :)
Thanks, it helped me with solving the problem of the light being on when the relay lost power. I left one wire in the centre then moved the other to the opposite side, (which made no sense based on the Com, NO, NC schematic you showed). I then had to change my code to send LOW to actuate, and the HIGH to turn off. My wires are therefore now in I_ ( whereas before they were in ( _I where ( is the centre. Hmmm what I have done works for me but makes no sense to me.
Hi thanks a lot. Thanks to you the relay is working on and off according to the job, its all work fine, but when i turning on my plasma cutter, the relay only work about 10% of the project then my stepper motor suddenly stop moving and on the lightburn its show busy and pause, is it because the relay is 10 Amp maximum and the plasma cutter i use is 40 Amp? Is there any way make it work?
You give me a great vision thanks a lot
But do you have explanation for this?
When I turn on the Arduino board esp8266 and at same time connected to doubled relay WiFi can't connect
Only connect if I unplugged gnd and 3v pins
So each time I want to turn on board must unplugged gnd and 3v pins
educational video... thank you
Thanks for watching!
Thank you for the video Brad! I'm wondering if I can use a single power supply to power both the relay coils (JD-VCC jumper removed) but also the arduino. I guess technically the arduino wouldn't be completely isolated from the coils BUT at least the coils would be getting their power straight from the power supply instead of possibly overloading the VCC pin on the arduino right? I'd also like to know if I could possibly go a step further and use that same power supply to also provide the power on the relays themselves (only intending on turning on 5mm LED's) so basically I'm trying to use a single power supply to power the arduino, the relay coils, and the LED's connected to the relays. Starting to think maybe I could've just gone with a different module like something using mosfets? Still kind of a beginner so any suggestions are welcome! Thanks for your time!
could you tell me how to calculate the 2 resistors in the relay one circuit?
Thank you for the excellent and clear explanation. Regarding relay module two, would it be possible to isolate relay and signal power by discarding the jumper and applying DC+ to the DC+ terminal for the relay coil (or the LOW pin of the 3 pin jumper) and signal power to the middle pin of the three pin jumper (either DC- or DC+ depending on whether we want to trigger high or low).
Edit: I tried it and it works!
I have a car project going on where I think a 3 channel 12vdc relay module may work better than 3 cube relays. Can the relay module control side be wired up like pin 85/86 on a cube relay, just 2 wires, a power wire and a ground wire, to shift the relay module? I just can't seem to understand the Vcc/in1/grnd and using an Arduino board.
Awesome! Can the relay be the cause why my arduino keeps crashing? Im using it on my lamp and ac motor
hello teacher
What is the wire that goes into the roller?
Is it phase or negative?
or doesn't matter
Dude, I was totally confused about these relay modules. I wish I had seen this before I bought some. Anyway, thank you. [Click -> Subscribed 😀]
What is better for a 12v vehicle application say 3amp. A standard automotive spdt or a microcontroller. Been trying to find a comparison but I can’t. Just knowing that the automotive relay uses electromagnetic only. Thank you
Thank You
You're welcome
Awsome video. Can you do a tutorial on how to read schematic and electronic?
Thank you. I appreciate the recommendation.
Is JD-VCC is the (+) terminal for the collector of phototransitor, anode of the diode & P2 of relay?
Pls reply
Is it possible to use a relay module to programatically switch power source of arduino from a DC power supply to an external battery without loosing power on the microcontroller, thus making it uninterrupted? I hope you can help me.
l have quation ,you can put the GND of optocoplor with the GND of the transistor. thanks
Great video but I think theres a bug in the relay 2 schematic at 6:22 . The optocoupler transistor output cannot be connected to Vcc, otherwise it is shorting the Vcc to GND when the opto is active , isn't it ?
Nice catch. I'm guessing the board has a third resistor to limit the current through that path, but that it was inadvertently left out of the schematic.
I love that someone took the time to explain the differences between the relay modules designs. I know a few people who think they're all the same, so they just recommend people always buy the cheapest.
Best video I found to describe these boards. Are there any other benefits to using a separate power supply on the JD pins? I'm controlling five 24vac solenoids. Tripping them with a delay of 1 to 2 seconds between each solenoid. I'm having weird issues with the delays hanging (locked up) or acting like there is no delay where a few of the solenoids will trip like there is no delay. I'm thinking something is feeding back into my Arduino that is causing this problem and was wondering if I isolated the power that this might help.
Thank you. One of the first places I look when I start to see unexpected activity is "power". When your micro isn't getting enough power or you are trying to draw to much power from the board, it will start to act in unusual or unexpected ways. If you are not using a separate power source to supply your relays, how much total current are you trying to pull from the board? Do you have all of the relays in an active high or active low state?
Have you got a flyback diode or suppressor on the load side?
Can you explain how to connect the high voltage DC circuit? I want a 12V circuit: so - from the battery goes directly to the load -. And + from the battery goes first to com pad on the relay, then the the NC pad on the relay (if you want normally closed) connect to the + side on the load. Is that correct? My relay does not seem to have an external power supply input. Only 5V from the receiver servo wire.
Really u r great
I've got a small digital relay that I can't get to work on 5 volts. It takes a trigger larger than 5 volts to cause it to go high. I've currently got a 12 volt battey pack triggering it. So I've got the 12 volt battery pack acting as my mains current going to an LED. 5 volts coming into the relay side. And a line from a switch to the 12 volt on the trigger. When I hit the push button 12 volts goes to the trigger and triggers the relay allowing 12 volts to go to the LED. The relay is supposed to handle mains current but I doubt that I want to use mains current to trigger it.
What software did you use to create the animations.?
cant i connect an external power supply to the dc+ pin in relay module 2? or external power supply to dc- and dc+ for that matter?
At 7:29 it seems like the microcontroller is seperated from the relay? Can't you just have an external power supply going to the DC+ and DC- on high level trigger?
Is it possible to power the arduino from the relay?
Hi, please, can you get a 5VDC output? i want to use this as a safety relay so i want 5VDC in, 5VDC out
Can we use this relay on PLC logo?
nice
2:00 Can you really be sure those 3mm -wide traces can carry more current that the 1-1/2 mm wide ones? Can you know the thickness of the copper somehow? Excellent video, btw.
either NPN or PNP will work for me switching RF signal inputs and outputs
All my comments based on Relay Module One. Tks.
Can I add a relay to 50w ac fan?
at 4:22 , I don't understand why the protection diode have the small yellow animated dots going through it. Shouldn't the diode be reversed?
what if i have to use a 15-0-15 V at 300mA rating transformer connected to a IC L7805CV Voltage Regulator operating at 5V DC output?!
i did this but it resulted in a humming sound when the relay was turned ON, and heating of the IC circuit.
What are the chances of tarying a fire by connecting 110v to this full time using this as an interruptor for a power strip?
Hi Brad, what software suite did you use to create this video?
Adobe Premiere and After Effects
nice.. do you have circuit diagram of this?
good
This was a great tutorial. There is just one big problem with this safe option (8:20). You have THREE power sources hooked up!? I am trying to create a small project where I drive a traffic light from and arduino. I have a dual relay board. I really don't want to have 3 power cables running from the device. Ideally, I'd like to plug in my 240v mains and have it run the full system. Please could you create a demonstration to show how you would accomplish this in a safe manner (for me and the electronics).
Please bare in mind that I have no formal electrical training. I have bought a few ardiuno starter kits and have bought what I think the necessary components are to get this all to work.
Can I use a 5v 2A adapter as the external power supply for the 5v relay?
Yes, a 5v Relay, needs a 5v Source to turn it on. The Amp rating of the power supply just needs to be above the current draw of the relay (Typical ~70mA for a 5V) so 2A is plenty. You could use a smaller power supply ~200mA. But, I wouln't go lower than 150mA
@@mopoke6427 thank you 👍😀
@@mopoke6427Relay with octocoupler >>> so if i am not using jumper to avoid any feedback> can i use same 12 v dc power supply source to give 12 v to jd vcc and same 12 v to vcc pin ...in DC PLC output side ?
After I destroy 2 esp32 boards, luckily I found this to let me not third boards. It may draw to much current by coil to wreck them before I test any project.
What type of signal activates the relay? 1 vdc? A frequency? Or any detection on signal? Does anyone know off hand. I'm not driving mine with Arduino, I'm using BT
You would need a 24 volt signal to activate a 24 volt relay
How to implement this method in multiple relay?
You could drive multiple relays with an external power supply, and then turn them on and off with different GPIO on the micro. This would require utilizing the relay that enables you to separate VCC and JDVCC.
If I don't use an OptoCoupler in the circuit, would there be any problems? I simply want to use the relay as an active high device
It wouldn't be a problem. The version of the relay module that includes the optocoupler is good for protecting your control circuit (micro), but it isn't required.
@@hensonbl Thank you👍
How much voltage is required to power the first relay module when using an external power supply ?
You would use 5 volts at around 70 milliamps to power the relay from an external power supply.
What is max voltage of JDVcc on relay module one?
Relays typically will provide their coil voltage rating in the part number. In this case, it is rated for 5 volts. I'm not sure you would want to drive it any higher then what it is rated for.
👍 thx for your fast reply...actually I want to control a 12 volts device using arduino..greeting from indonesia..
In that case you will be okay to use this device. The control/coil voltage is rated for 5 volts, which aligns to use with a lot of Arduino devices. The voltage rating on the switch side is something like 30 volts DC up to 10 amps.@@Tatit_Widyartono
@@hensonbl thx mate..
good video,
Can you make a new video guide " Turn on contactor by module relay and arduino", i think it is a good video because i finding it :v
so incase i want to use 9v battery, i need to use the fist relay module
I have 8 channel relay board - the active low optocoupler! how to turn 8 channels into active high?
At time stamp 5:53, I show how you can connect a microcontroller's GPIO pin up to the VCC pin on the relay board and the Gnd of the microcontroller to the IN1 pin on the relay board. The key with using this configuration is not to use the JDVCC jumper. You don't want the GPIO to be the current source for the relays. This is why it is a good idea to use the external power supply as the power source for the JDVCC connection.
@@hensonbl It could be possible for 1 channel relay module, however, if we have 8 channel relay module and we have to turn on/off 8 IN pins of module. How it can be done?
@@imtiazdahar8451 different input signal from controller will drive their respective relays > when no jumper + external p supply to jd vcc is used >don't u agree ?
sir do you have diagram in this wirings?
I created all of the wiring schematics in the video using Adobe After Affects. So, I unfortunately don't have them as a separate file.
Is it possible to work relays for 24x7, 365 days continuously? Will it burn and get damaged?
I'm interested to know if you find anything out
Depending on how often they switch, read the data sheet every manufacturer states the lifetime
@@Hector0 not these guys. Cheap Chinese stuff. Just shows up in a box and the manufacturer says it will work forever and it's the highest quality 🤣🤣 the only way to know is to test