Это видео недоступно.
Сожалеем об этом.

#18 Add a Relay Module to your Arduino project - Hints, Tips & Traps

Поделиться
HTML-код
  • Опубликовано: 15 авг 2024

Комментарии • 337

  • @bgable7707
    @bgable7707 Год назад +4

    I don't know how many times over the years I've watch this video to "remind" myself how the JD-VCC works, again thanks for the detailed explanation!!!

    • @RalphBacon
      @RalphBacon  Год назад

      Ha, ha! Yes, it can get confusing. I've just implemented a 4-channel relay for my pond controller. And yes, I used the JDD-VCC pin too!

  • @acadman4322
    @acadman4322 5 лет назад +27

    Ralph, you have pointed out some important nuances with this little relay board others have ignored. Thanks quite a bit for your kind video. Well done!

    • @RalphBacon
      @RalphBacon  5 лет назад +2

      Glad you liked the video ACADMan, thanks for posting.

  • @garycrockett4477
    @garycrockett4477 3 года назад +1

    Thanks for taking the time to describe what the JD-VCC/VCC pins are for, and how they work. I was having a hard time finding out, searching the Internet.

    • @RalphBacon
      @RalphBacon  3 года назад

      Glad it helped, Gary. Just don't short anything out using that dangerously placed jumper!

  • @iandawkins2182
    @iandawkins2182 5 лет назад +4

    Brilliant down to earth understandable for someone like me new to trying to control external devices with an Arduino. Thanks.

    • @RalphBacon
      @RalphBacon  5 лет назад +1

      I'm glad it helped, Ian, thanks for posting.

    • @iandawkins2182
      @iandawkins2182 5 лет назад +1

      Thank you so much, just subscribed as I think this is such a great learning channel as you have the ability to explain and inform. A rare skill please keep them coming and looking forward to what's to cum. Respect.

  • @andreatanzi3191
    @andreatanzi3191 3 года назад +5

    This the best explanation I found about the subject.
    Thank you very much, everything clear!

  • @user-qh2ed4xe5x
    @user-qh2ed4xe5x 10 месяцев назад

    this was so helpful ..was stuck on a project for days ..so enlightening ..may the Heavens richly bless you thank you

  • @mickcoomer9714
    @mickcoomer9714 4 года назад

    Finally a vid that explains why you are sinking the supplied voltage to the onto-coupling.
    Thank you.

    • @RalphBacon
      @RalphBacon  4 года назад +1

      No problemo, Mick, glad it cleared that up.

  • @jayobrine8475
    @jayobrine8475 3 года назад

    Thanks for describing what the JD-VCC/VCC pins are for, and how they work. Watched many other RUclips videos on the subject on relay modules and this was overlooked. Nice job.

  • @raygud5653
    @raygud5653 2 года назад +1

    This video may be 5 years old but still very educational and usefull, help me alot. Thanks!
    I had some issues running the code you used but i got it working with afew modifications 🙏🏻

    • @RalphBacon
      @RalphBacon  2 года назад +1

      Great to hear, Ray! It would be interesting to know what the changes were?

  • @allbeit582
    @allbeit582 5 лет назад

    I looked for quite a while to find info explaining the 3pins with jumper on this board, then I found your video .... Perfect, thank you.

    • @RalphBacon
      @RalphBacon  5 лет назад

      Glad it helped you, thanks for posting.

  • @jimbrownza
    @jimbrownza 5 лет назад +1

    That's a really good video; kudos for that. All I would add, when you're talking about why not to use it with the jumper attached (ie, powering the coils from the Arduino and compromising the opto protection) is the current aspect. Those Songles draw about 70mA each, so if you have an 8-relay version of the board and energise all of them at once you're up in the 1/2Amp realms and you don't want to subject the Arduino 5V pin to that.

    • @RalphBacon
      @RalphBacon  5 лет назад

      Excellent point you make there, Jim, I'll make a note for when I next mention relays.

  • @steveedwards90
    @steveedwards90 5 лет назад +1

    Thanks ralph your coding skills are far superior to my novice attempts but I cant find any one local to help so self taught .

    • @RalphBacon
      @RalphBacon  5 лет назад

      Self-taught is fine, Steve, but do try and follow Best Practice as you do so. Avoid monolithic programs (the first self-taught issue) and lay it out nicely. If it looks nicely written, logically, with comments, then it means the programmer has taken time with the code too. As a professional web coder for the best part of 3 decades, I can tell you I am STILL learning. But look at the demo sketch in my NEXT video (#133 about a workshop heater repair) to give you some ideas. Oops. Spoiler alert. Too late.

  • @oncledan282
    @oncledan282 4 года назад +3

    Hi, Ralph.
    I think you just pinned the « problem » I have with my Laser Fan Controller project I wrote a few months back. I hear relays clicking upon initialization. NOW, I know why. Hahaha! And it makes sense.
    Not that it is causing any problem, but I'll keep this trick in mind next time I pin un using relays in my projects.
    THANKS ! and take care !

    • @RalphBacon
      @RalphBacon  4 года назад +1

      All good news, Daniel. I know this is late but I have to put a comment here or it will appear forever in the unanswered list!!! You should see me, I have an eye patch on and I look like a pirate!!!

    • @oncledan8509
      @oncledan8509 4 года назад

      @@RalphBacon Aaarrr! Captain ! Hahaha! Shhhh !! Don't say that over the Net, for we just might taking you up for making your next video with this patch on ! Hahaha! Witch makes me think I must put my list to date. I made a list of all your video's titles a few months back (when we first met) and I didn't touch to since. I'm waaay back on that list, now. It's my Arduino/ESPxx's Bible and I often refer to it when I have time to play with these modules.
      Nowadays, I'm working that Laser like crazy .. for Xmas presents and all. Oh well ! Time will come back, I'm sure, when I'll have plenty of time to go back to the fascinating world of Arduino and ESPxx. Sooner than I expect, I guess! Hahaha!
      Have a nice day, my Friend .. and watch out for this eyepatch !! Take care !

  • @inspiredtiny
    @inspiredtiny 4 года назад

    I have just received my relay module which is exactly the same as modules shown in this video. Great thing I came across this video as I am just about to start my project.

    • @RalphBacon
      @RalphBacon  4 года назад

      I knew you had ordered one Robert (Benny is my spy) so it is not a coincidence that you have found this video! Have Fun but do NOT short out those header pins (JCC-VCC-GND) !!!

  • @markowens9950
    @markowens9950 5 лет назад +1

    Thanks for a great video. I was having trouble understanding my relays because because a single relay module I have actually turns on with the "HIGH" command but all the other relay modules turn off with this command. After watching your video I was able to understand how this one works.

    • @RalphBacon
      @RalphBacon  5 лет назад

      Glad it helped you, Mark, thanks for posting.

  • @MyBigThing2010
    @MyBigThing2010 5 лет назад

    Long time, no see...I hope you're well. I figured I'd drop by to vampire some more of your knowledge as I just acquired one of these funny little guys for a two channel 12V multi light vehicle project I've gotten myself into elbow deep at the moment. STILL the number ONE channel I go to to find help when I stray into dangerous...err...new waters, electrically speaking. Thanks again for sharing your knowledge and explanations that the rest of us apes can rightly understand and properly digest without falling asleep or frying our eyebrows. ;)
    Best wishes mate.

    • @RalphBacon
      @RalphBacon  5 лет назад +1

      Good to hear from you again, it's been a while. This device would work very well in a car (low voltage) and help protect your Arduino too. Thanks for your kind words about my channel, I'm glad you like the videos. Thanks for posting.

  • @nicholasbarber5905
    @nicholasbarber5905 Год назад

    Simple to follow. The circuite diagram really illustrates whats happening. Thanks.

  • @MikeHoover1
    @MikeHoover1 3 года назад

    Thanks for a great video! You are right about the jumper at around 15:30 and newbie assumptions. One might assume the jumper is to be in one of the two possible positions. I removed mine and turned it 90 degrees and placed it on the VCC pin as a reminder.

    • @RalphBacon
      @RalphBacon  3 года назад +1

      Yes, I do that with jumpers too! But they do have a habit of then jumping off, never to be seen again! That's why I bought a pack of 50 some time ago. Glad you found it useful, Mike, good to hear from you.

  • @Paulilmys
    @Paulilmys Год назад

    Best explanation yet! Thank you for the video.

  • @laidman2007
    @laidman2007 5 лет назад +2

    Thanks for this video on relays. It clarified a lot of things for me.

    • @RalphBacon
      @RalphBacon  5 лет назад

      You are most welcome Roberta Laidman, I'm glad you like the video. Nice to hear from you.

  • @syaduinotech3681
    @syaduinotech3681 2 года назад

    Thanks for your video sir. I have the problem with my relay, when start on, all the relay was not behave like i want. The reason, i already noted based on your explaination worth to try out. Tq sir

    • @RalphBacon
      @RalphBacon  2 года назад +1

      You're most welcome and good luck with your project.

  • @russellmccallum3606
    @russellmccallum3606 5 лет назад +1

    Wow I learned a lot about these relay modules with this video - Thank You so much-!!!

    • @RalphBacon
      @RalphBacon  5 лет назад

      Glad you liked it, Russel, thanks for posting.

  • @shaunr9950
    @shaunr9950 5 лет назад

    Great video - well explained. This has given me a much better understanding of this relay module and how to use it correctly with an Arduino board. Thank you.

    • @RalphBacon
      @RalphBacon  5 лет назад

      You are most welcome Shaun R, I'm glad you like the video. Nice to hear from you.

  • @webslinger2011
    @webslinger2011 6 лет назад +1

    Thanks for explaining that light flickering issue. Didn't know it was due to setting pins as an output.

    • @RalphBacon
      @RalphBacon  6 лет назад

      Thanks for that, webslinger2011, glad it was clear, nice to hear from you.

  • @hedbergmicke
    @hedbergmicke 5 лет назад

    Love your videos Ralph. Always that that bit of extra information that makes you go: "I've learned something new" :)

    • @RalphBacon
      @RalphBacon  5 лет назад

      Thanks for that, Michael Hedberg, glad you learning! Nice to hear from you.

  • @berliandro
    @berliandro Год назад

    I spent weeks and days trying to figure out why my servo spins when i turn the "isolated" relay on. And it takes 13 minutes to solve it with this video ❤❤

    • @RalphBacon
      @RalphBacon  Год назад

      I'm so glad it helped, Patrick!

  • @Risingnshouting
    @Risingnshouting 7 лет назад

    Thanks for the details. I am clearly not as skilled at reading circuit diagrams, and had no idea what was happening with my 16 channel relay. However, now I suspect I am inadvertently shorting out my GPIO IC with the connections from my Arduino to the GND, along with the 16 Pins.
    Again, your expertise is much appreciated!

    • @RalphBacon
      @RalphBacon  7 лет назад

      I read from your other post that things are now working. I'll comment on your other post...

  • @manuelacuna9958
    @manuelacuna9958 Год назад

    omg!, thank you so much! I had this issue with powering up an Arduino. The relay would activate within the first few microseconds, turning on the contactor of an AC motor,and of course, that shouldn't happen, It was driving me nuts

  • @ZunairParviez
    @ZunairParviez Год назад

    Thanks sir you explained very well. The same module you using is available in my country at the price of less then dollar 😀

    • @RalphBacon
      @RalphBacon  Год назад

      Glad it helped! I'm using the 4-relay module in my most recent project and that was pretty inexpensive too.

  • @yusufcali793
    @yusufcali793 6 лет назад

    Amazing video, very pedagogical, beginner friendly and focused on the point. Thank you for your time sir. Your friendly and humble cyber-student. :-) Much love from Sweden

    • @RalphBacon
      @RalphBacon  6 лет назад

      Nice to hear from you Josef, glad you're liking the videos!

  • @sadayghosh5894
    @sadayghosh5894 3 года назад

    Thanks, the video is very helpful. Everything's explained in detail.

  • @FOATE
    @FOATE 5 лет назад +1

    This is great info, just what I needed to know, thank you!

    • @RalphBacon
      @RalphBacon  5 лет назад

      You are most welcome dikke j, I'm glad you like the video. Nice to hear from you.

  • @glentyan2505
    @glentyan2505 Год назад

    I don't know if it's already been pointed out but the back emf diode and relay coil are short circuited. {Q1 collector to JD-VCC line.}

    • @RalphBacon
      @RalphBacon  Год назад

      Ha! I never noticed that before! Not my circuit diagram, but from the seller. The boards works at least, so we can safely assume that the replay coil is not shorted like that. Well spotted, Glen, you get the Eagle Eyed award for... well, for the last 6 years. 👁️😜

  • @CurmudgeonExtraordinaire
    @CurmudgeonExtraordinaire 6 лет назад

    Thanks for the hint about setting the relay HIGH before setting the mode to OUTPUT. I had been trying to figure out that no matter what I did, it insisted on activating the relay after being powered up or reset during a compile and load. I even tried it without sending a HIGH or a LOW and it still reset during the compile and load.

    • @RalphBacon
      @RalphBacon  6 лет назад

      Glad the tip worked, Grumpy Old Man. Funnily enough, I learned this from Arduino guru Nick Gammon. I queried why he did it and what it was doing behind the scenes, and he explained. And here we are, some years later, with the tip being passed on! Thanks for posting.

  • @mayurchauhan4219
    @mayurchauhan4219 3 года назад

    Thank you for this video it helped me alot while controling relay module through raspberry pi.

    • @RalphBacon
      @RalphBacon  3 года назад +1

      Glad it helped, Mayur!

  • @RD-ni7qe
    @RD-ni7qe 4 года назад

    Such a clear explanation, thanks!

  • @cyabd8515
    @cyabd8515 2 года назад

    Thanks Ralph for a very helpful video. It seems when using a 5v relay things are pretty straight forward and easy but, the problem starts going beyond 5v even 12v could still be all right since can use the VIN on Arduino but as far as I understand it and for the benefit of others you cannot use Arduino to trigger a 24v Relay. Although 12 is still ok feeding the Vin with an external 12v. Generally it seems triggers can only be done within 10% of the Relays Voltage rating as in min. 9v required for a 12v one and 21v to trigger a 24v relay!

    • @RalphBacon
      @RalphBacon  2 года назад

      Glad you found it helpful, Cy.
      You can always trigger a higher voltage relay if you supply the necessary voltage independently, usually controlled via a N-MOSFET. So the Gate of the MOSFET is switched on via the Arduino (via a 100Ω resistor), the Source of the MOSFET is connected to GND and the Drain of the MOSFET is connected to one side of the coil with the 12/24v connected to the other side. All Grounds are connected together (common ground). A simple TO-92 outline 2N7000 MOSFET works well, usually.

    • @cyabd8515
      @cyabd8515 2 года назад

      Also now-a-days Relays mostly come with the bi-directional Optos meaning no JD-Vcc! A bad Idea since JD-Vcc and the external power option not only creates total Isolation but also much less current draw on the Arduino since it only needs to light an Led and has nothing to do with the relay coil which gets powered by the external source.

    • @cyabd8515
      @cyabd8515 2 года назад

      @@RalphBacon Yes quite so, but then you'd be making a relay of your own to get the ready made one going. It's just best for everyone to know, if they want to get an MU like Arduino to trigger the relay, to NEVER buy a relay with more than 12v nominal rating. That is a 5v one can be run with no other changes necessary and the 12v one only with connecting a 12v supply to vin and then, only the MU/Arduino input signal line connected to Arduino and everything else on both sides input/output must be connected directly to the external supply which should not be leass than 9v also feeding the VIN. The relays with J-D VCC more versetile/safer draing much less current from thr Arduino Vs. the ones without it(my 2 cents after suffering 2 days of searching and trial error to get a 12v relay without JD-VCC going). I often wonder, why the Cinese don't invest a few bucks to write a proper tutorial on their product, I hope it is NOT intentional?

    • @RalphBacon
      @RalphBacon  2 года назад +1

      Perhaps in Chinese, the phrase "invest a few bucks" is often misunderstood as "keep the costs down"?

  • @berliandro
    @berliandro Год назад

    You saved my life

    • @RalphBacon
      @RalphBacon  Год назад

      Well, not literally, I hope but I get the gist!

  • @KAVIAN_HZ
    @KAVIAN_HZ 5 месяцев назад

    This was a awesome complete guide for relay module❤ I want to add a arduino to one of my home appliance so Im using a relay. the power outlet voltage is 220 volt and also the machin input power is 220 volt too and as you know arduino input is 5 volt so I was wondering is it possible to use a voltage decreaser module from 220 to 5 volt for my arduino instead of using adaptor for the my arduino and adaptor for the machine and just plug the both at the same time with same power cord directly to the power?

    • @RalphBacon
      @RalphBacon  5 месяцев назад

      If you have your mains voltage as part of the project anyway, I would use a mini PCB-mounted 5v PSU. I've used this many times and they are good if you use a good quality one. Hi-Link are OK.
      They might do a screw terminal version (so not designed for a PCB) if you look hard enough.
      Also check out "open frame 5v PSU" which I've also used with great success. These always have some sort of screw terminal but are larger than the mini PSUs I mentioned above.

  • @johnskii
    @johnskii 6 лет назад +1

    Great video - very informative, thanks!

    • @RalphBacon
      @RalphBacon  6 лет назад

      Thanks for your post, Broken Barrel Productions, good to hear from you.

  • @GaryMcKinnonUFO
    @GaryMcKinnonUFO 5 лет назад +1

    Thanks for the detail, good stuff!

    • @RalphBacon
      @RalphBacon  4 года назад +1

      Glad you liked it Gary, thanks for posting.

  • @JeremydePrisco
    @JeremydePrisco 6 лет назад

    Great job! I will be referring to your site again!

    • @RalphBacon
      @RalphBacon  6 лет назад

      Thanks for that, Jeremy dePrisco, nice to hear from you.

  • @steveedwards90
    @steveedwards90 5 лет назад +1

    Thank you this has been a problem for my self I want to switch 2 relays on when I push a button but they must not switch when powered up those code lines will save me a large headache lol regards

    • @RalphBacon
      @RalphBacon  5 лет назад +1

      You are most welcome Steve Edwards, I'm glad the video helped you. Nice to hear from you.

  • @eraslanaslan9059
    @eraslanaslan9059 Год назад

    This video is very helpfull thank you sir:)

  • @amoshuxley2924
    @amoshuxley2924 2 года назад

    Great video! Thanks 👍

  • @bloodswarms
    @bloodswarms 6 лет назад

    Subscribed because of this video. Side note: Ebay relays terrify me.

    • @RalphBacon
      @RalphBacon  6 лет назад

      Thank you indeed, Bloodswarms! If you liked this video you will like a future one too but no spoilers at this early stage. Let's just say we explore different approaches to relays. Side note: anything to do with mains electricity from the Far East gives me the willies (side note to my side note: I hope that translates well, it's a UK, family-friendly expression)

  • @ernestosaboia
    @ernestosaboia 5 лет назад

    Great information, and well done! Thanks mate

    • @RalphBacon
      @RalphBacon  5 лет назад

      Thanks for that, Ernesto Melo, nice to hear from you.

  • @stefaneberle8969
    @stefaneberle8969 3 года назад

    Hi.. I have a 12V power supply for the Arduino. The 5V from the Arduino I use for the output pins/ opto coupler diodes...for the Relais I use Vin from the Arduino Board... which is the 12V before the Arduino Voltage regulator.... This is not a full galvanic isolation but I think the Arduino is well protected this way...Do you think so too?

    • @RalphBacon
      @RalphBacon  3 года назад

      Yes, correct, Stefan. The Arduino is not totally protected but pretty good. Good enough, anyway!

  • @McBurneyAndrew
    @McBurneyAndrew 3 года назад

    Great work

    • @RalphBacon
      @RalphBacon  3 года назад +1

      Thank you so much 😀

  • @jakel1977
    @jakel1977 4 года назад

    Thank you. Very good explanation

  • @EnduroNerd
    @EnduroNerd Год назад

    So, what if you want to only use 1 power supply but still have the protection of isolated circuits? You can't really be creating devices with multiple power supplies. Can my external power supply be made to supply power to both the arduino and the relay module? Would I need to add in some sort of additional protection circuits to divide them?

    • @RalphBacon
      @RalphBacon  Год назад

      If you use the _same_ PSU for both parts of the project then they are not isolated. You _could_ use the same primary transformer with separate secondary outputs (eg 2 x 5v output) to provide better isolation but, frankly, dual PSUs are the only way to give total isolation.

  • @KaylebGarmon
    @KaylebGarmon 5 лет назад +1

    Can you just add a flyback diode at the JD part instead of removing the jumper? I don't have a separate 5v power supply.

    • @RalphBacon
      @RalphBacon  5 лет назад +2

      If you don't have (or don't want) a separate power supply for the JD-VCC part of the circuit, Kayleb, just keep the jumper connected on the board, JD->JD-VCC.
      Replacing the jumper with a rectifier diode (eg IN4004) might give a modicum of extra protection should things go awry in the "other side" of the board, but don't rely on it. That's assuming the voltage drop across the diode doesn't affect the operation of the relay (which I don't think it will).
      Adding a flyback diode _instead_ of removing the jumper doesn't come into it here, I'm not sure how you see that helping you. Let me know!

  • @prashantsakre6577
    @prashantsakre6577 4 года назад

    This is good exactly I needed...thanks

  • @vedaprakash2707
    @vedaprakash2707 2 года назад

    i am trying to switch between 2 batteries of 12V and 80A and 12V 20A, i am confused in choosing a relay. Would you recommed me which type of relay should i use?
    thanks

    • @RalphBacon
      @RalphBacon  2 года назад

      It depends on how much current you will draw _in your circuit_ . If the circuit only draws 2A then a relay rated for _at least twice_ that (so 4A+) will be fine.
      But if you intend using anything much higher (eg 16A) then be very careful that you find a relay that can handle that much continuous current. I always *double* the rating to be safe.

  • @djs134
    @djs134 7 месяцев назад

    Is there anyway u can tell me what’s needed to accomplish a simple task? So , I have 2 sets of 20 header pins, let’s call them source 1 and source 2. And I only have 20 pins as an output. I want to use a physical button to select between which source i want to use, either source 1 or 2 but never both at the same time. So in theory is basically a 20 pin ribbon cable switch so to speak with 2 separate sources and 1 20 pin ribbon cable out so to speak, with a switch to select which source I want. Thanks any help would be appreciated

    • @RalphBacon
      @RalphBacon  7 месяцев назад

      I'm guessing that a mechanical switch for 20 cables is out of the question (it would be for me).
      I would consider using a 20-way (or 2 x 10-way) digital switch IC. These are integrated circuits that switch signals (only signals, no high power stuff) from one source or the other.
      Purely as an example, here's a link to a 4-way, DIL switch so can see what I mean: bit.ly/digital-switch-IC
      You would have to design a custom PCB to make best use of these switches with a socket for the ribbon cable connector - very do-able but worth researching (and perhaps trying out a smaller switch like the one above first).
      Depending on your soldering / PCB design skills, there are ICs in DIP format ( through-hole like above) or SMD QFP (square) with much higher switch counts.

  • @oceanzrobotics
    @oceanzrobotics Год назад

    Thanks immensely!

  • @sushildamle3449
    @sushildamle3449 2 года назад

    This has given me a much better understanding of the relay module and how to use it. Good stuff. Great video detailing and well explained. Thanks for the details.
    Can you offer any advice for me please- I want to use two numbers of ON / OFF or push switch (one each for relay) two do jobs separately. Could you please give a sketch for the same and code.
    Thanks in advance.
    Sushil Damle

    • @RalphBacon
      @RalphBacon  2 года назад

      I'm happy this has given you a better understanding of relays in general, Sushii, but I'm not able to write bespoke sketches for you!
      That part of the job is down to you. Break the project down into manageable chunks and think about how they might interact. Only start coding when you have the design at least "working on paper".

    • @sushildamle3449
      @sushildamle3449 2 года назад

      @@RalphBacon Thanks for your guidance. I have tried doing the same, but I found that the turnout used to be energized where in I do not want the same as there is every possibility for the turnout getting burned out. Once I pressed the button track should change from Left to Right and when I either press the same button or have another button, when pressed track changes from Right to Left. The track should be energized only for the duration when button is pressed. Your advice please. Thanks once again.

    • @RalphBacon
      @RalphBacon  2 года назад

      When you press a button the pin will go HIGH or LOW (depending on how you have wired the button up). Whilst it is that state, the output (keep checking in the loop) keep the output HIGH. When the state changes then make the output LOW. Try this with a very small sketch and an LED to prove you can do this. Let me know how you get on.

  • @swedemake5571
    @swedemake5571 2 года назад

    Thanks for a great Video

  • @wouladjecabrelwen1006
    @wouladjecabrelwen1006 3 года назад

    Hi
    I think I have that problem with my ESP32 board, I have interface it with the relay after some times like 2 minutes of working nicely, it stops working at all until I have to disconnect to power supply (I supplied it from my computer) and I reuploaded the code. Tomorrow I will test your method and see.
    Thank you

    • @RalphBacon
      @RalphBacon  3 года назад

      Be careful with the ESP32 GPIO pins, they are 3v3 and might not be enough to trigger the relay.
      Also, you should be monitoring the serial output of the ESP32 (at 115200 bps) as it will tell you why it's crashed (eg Panic, or Brown Out Detected).

    • @wouladjecabrelwen1006
      @wouladjecabrelwen1006 3 года назад +1

      @@RalphBacon I succeeded to interface that, guess what I it works well. Thank you for the tutorial:) 😍😍😍

  • @mikesfarmmikesfarm3977
    @mikesfarmmikesfarm3977 8 месяцев назад

    are nano d4 and d5 not able to sink as much current as the other discrete outputs ?
    Those 2 outputs do not pull to 0volts, but rather 2.5vdc

    • @RalphBacon
      @RalphBacon  8 месяцев назад

      On an Arduino Uno and Arduino Nano D4 and D5 are just normal GPIO pins and should pull low in the usual manner. Here's an official schematic: bit.ly/47YFExC

  • @Risingnshouting
    @Risingnshouting 7 лет назад +1

    On my 16 channel relay, I removed the ground connection from the Arduino to the relay, so the ONLY connections between the Arduino and the relay board are the IO Pins. Everything works fine now, and no more shorting out :-). I obviously have a separate power supply to control the relays, and it has a ground connection. I wonder where the current flows from the IO pins, when they are set to HIGH? Does the current flow from one pin set to HIGH to another pin set to LOW? If that's the case, am I always required to have at least one pin set to LOW?

    • @RalphBacon
      @RalphBacon  7 лет назад +2

      OK, let's figure this out. The ONLY two connections you need to get this to work are the VCC (+5v) from the Arduino and a GPIO pin configured as OUTPUT. So the current flows from the (Arduino's) VCC through the opto-isolator LED pin (IN1) and back from GND to the Arduino's GPIO pin set to LOW (to let the current flow - set it to HIGH to stop it). But...
      But if you are also powering the relay from the Arduino's 5v supply, then you need that jumper in place (to join VCC to JD-VCC) and that GND (ground) connection (back to the Arduino) too. This is good for testing it all hangs together.
      If you are powering the relay side of things independently then you need to remove the jumper, and connect the independent power supply to JDC-VCC and ground. The ground does NOT need to go back to the Arduino. This is the best option as you're then totally isolated.
      Not sure if this clarifies things or not, Mr RisingNShouting? Let me know!

    • @Risingnshouting
      @Risingnshouting 7 лет назад +1

      Ralph S Bacon
      Yup, that helps a lot! Thanks Ralph, you're the best!

  • @josip1881
    @josip1881 4 года назад

    Well explained, thank you.

  • @woopywoopwoop
    @woopywoopwoop 6 лет назад

    Your video was very helpful.Thank you : )

    • @RalphBacon
      @RalphBacon  6 лет назад

      It makes me happy to hear that, woopscoop! That was video #18, there are now more than 100 videos on this channel so I guess you will enjoy many, many more of them as time goes by! Thanks for posting.

  • @patrickconrad396
    @patrickconrad396 Год назад

    I'm trying to make a water pump trigger. Would I put the relay before or after the step up? Anyone know? So if water hits a certain level start a 12v pump.

    • @RalphBacon
      @RalphBacon  Год назад

      I'm confused about the "step up" bit in your question! The Arduino GPIO will trigger the relay on and off, but the 12v for the pump is controlled by that relay (and never connects anywhere to the Arduino side of things).
      Can you clarify the "step up" part of your question?

  • @yurkshirelad
    @yurkshirelad 3 года назад

    If you wanted both relays to be off at bootup, would you set the pins to low before using pinMode?

    • @RalphBacon
      @RalphBacon  3 года назад +1

      Yes; Nick Gammon, Arduino guru, once told me to set the pins LOW before changing the pinMode to avoid the tiny pulse that will otherwise appear on the relay pin, which might cause the relay to chatter.

  • @ryanavery7980
    @ryanavery7980 4 года назад +1

    I think its an output pin because you are writing to it, not reading from it.
    edit: I'm talking about at 3:36

    • @RalphBacon
      @RalphBacon  4 года назад

      Can you just put this into context, please, Ryan? At which point in the video does this come up? From what you say if you are writing to a pin it will probably be an output pin - but if you write to an input pin it just turns on the pull-up resistor!

    • @ryanavery7980
      @ryanavery7980 4 года назад

      @@RalphBacon 3:36

    • @RalphBacon
      @RalphBacon  4 года назад

      Right, the point I was making at that point in the video was that although the current flow was coming IN to the Arduino (from VCC and the diode), the pinMode was still an OUTPUT - something that confuses beginners.

  • @Ahlg1990
    @Ahlg1990 3 года назад

    Thanks for the video,
    But I am a bit confused by the closing comments, you mention the protection diodes and that all you need to do is connect the Arduino to those inputs (easy),
    But a bulk of the video was discussing the issue of jumper pin and the two circuits not being isolated.
    So is it ok to use the Relay with jumper between VCC/JD-VCC and the Arduino powering the whole thing? Do the protection diodes protect the Arduino?

    • @RalphBacon
      @RalphBacon  3 года назад +1

      I'm sorry to have confused you; it was because I was trying to cover two points here.
      You can connect the jumper between VCC and JD-VCC to power everything, then connect up to the Arduino as described in the video. Because the relay module is isolated as far as the GPIO pin of the Arduino is concerned (that opto-isolator) there is no need for any further protection. Note that the relay energises when the GPIO pin goes LOW (not HIGH as you might expect) because the current flows from VCC into the LED then into the GPIO pin then to GND.
      If the Arduino were to ever power a bare relay (coil) it would need the protection of a diode connected across the coil contacts so that when the relay was de-energised, the back-EMF (potentially hundreds or thousands of volts) caused by the collapsing magnetic field of coil did not find its way back to the GPIO pin.
      Regarding that VCC/JD-VCC jumper, if you were to power the relay module with an independent power source (and removing the jumper) it would improve the isolation as all the Arduino environment now sees is the LED within the opto-coupler. But it's not necessary to do this.
      Have I confused you even more now, Andrew?

  • @mikhailkh8560
    @mikhailkh8560 Год назад

    But why HIGH - is turn it off, while it sent 5V in circuit, and LOW turn them on, while on circuit is just few mV?

    • @RalphBacon
      @RalphBacon  Год назад

      Because we are SINKING the current from VCC through the device and then through the Arduino to ground. So the output GPIO pin has to be LOW to allow the current to flow in that direction. Make sense?

  • @pjay3028
    @pjay3028 Год назад

    If the pin is set Low at the point of being set as Output, and you want to avoid this, shouldn't the pins be set High AFTER the Output command (lines 10&11) in the code, rather than before (lines 7&8)?

    • @RalphBacon
      @RalphBacon  Год назад

      It doesn't really matter whether you set the pin's state (LOW, HIGH) either before or after the "pinMode" command.
      But if you set it _after_ the pinMode you may get a tiny (1μS) pulse which you might not want. The guru Nick Gammon once told me that setting it _before_ was in fact a bit safer.

    • @pjay3028
      @pjay3028 Год назад

      @@RalphBacon excellent, thanks for your reply.

  • @PavolFilek
    @PavolFilek Год назад

    Hi Ralph., do U have a video, where U send signal to ESP32/8266 , to which is connected relay, and another ESP32 has a microphone, and listen to voice commands ? I need to program something like this, to get rid of DC cables from battery to switch.. Cables will be only from battery to LED.

    • @RalphBacon
      @RalphBacon  Год назад

      Voice commands requires a lot more processing than what the ESP32 can ever give you. You would need, I would think, at the very least, a link to a cloud service (such as Amazon's Alexa service, which is long winded by easy enough to do) for this all to work.

    • @PavolFilek
      @PavolFilek Год назад

      @@RalphBacon Thanks, bud I have to do it myself I do not want cloud, a lot of work ahead for me to do it.

  • @nexuzinnovation-com
    @nexuzinnovation-com 2 года назад

    hi Ralph,
    Recently I am working with relays.
    If the relay part number is "SRD-12VDC-SL-C", can it still be used for Arduino 5V and ESP32 3.3V as some said the "12VDC" means the relay is operating under 12V, does it means the JD-VCC have to supply 12V and VCC input is +5V DC ?
    Let's say, I am using ESP32 3.3V gpio pins, can the relay "SRD-12VDC-SL-C" works or I need to get "SRD-03VDC-SL-C" model of relay ?

    • @RalphBacon
      @RalphBacon  2 года назад +1

      I would be very careful about switching on a relay (coil) directly from _any_ GPIO pin, Ricky. They have very limited current available (40mA absolute max, but usually we limit to 20mA). I would use the ESP32's GPIO pin to switch on a MOSFET (or even a standard BJT) that then turns on the relay. You can use a simple 2N7000 MOSFET (I use this in my Workshop Heater Controller and it works well with the ESP32).
      This means a 5v relay will work because you have enough power from the +5v pin to run the relay. So what you really need is the relay model SRD-05VDC-SL-C, but if you limited the current through the transistor you could use a SRD-03VDC-SL-C running from the 5v supply line.
      Do not forget to put the protection diode across the coil otherwise your MOSFET (and even the ESP32 GPIO pin) will be damaged.
      If you need more information look at my Heater Controller schematic from video #225:
      ruclips.net/video/xJ8Q3ysC8Q8/видео.html
      The link goes to my GitHub here: github.com/RalphBacon/225-Project-Design-and-Implementation
      Look at the relay bit in the middle with the 2N7000 MOSFET.

    • @nexuzinnovation-com
      @nexuzinnovation-com 2 года назад

      @@RalphBacon , thanks for the feedback, I will take note on your suggestions.

  • @clems6989
    @clems6989 2 года назад

    So, why not drive the output HIGH to activate the optocoupler.. [Reverse the polarity's]

    • @RalphBacon
      @RalphBacon  2 года назад

      Because the datasheet suggests that the LED inside the optocoupler is connected to +5v and the current sunk (sinked?) via the μController.
      However, as the terminals are totally isolated I suppose you could drive the LED from the μController (instead of +5v) and connect the other end to GND, that should work too. But do check what the manufacturer of the board has done, they might have made assumptions on how you're supposed to connect it up.

  • @cedomirvalcic5080
    @cedomirvalcic5080 5 лет назад

    Great video!

    • @RalphBacon
      @RalphBacon  5 лет назад

      Thanks for your post, Cedomir Valcic, good to hear from you.

  • @drelectronics13
    @drelectronics13 3 года назад

    If i use same connection in esp 8266 with 8 channel relay board on which pin of esp 8266 i hv to i hv to connect vcc

    • @RalphBacon
      @RalphBacon  3 года назад +1

      You must be careful with the ESP8266 as it is a 3v3 device.
      The module you have will probably have a 5v pin which can be used for the JD-VCC relay supply (if you are not using a separate power for that side of things). For the opto-coupler LED you can use any pins (choose ones that aren't PWM-capable or that is used for I2C or SPI) connected to the IN1 - IN8 pin.
      If the current limiting resistor (R1 in my video) is not already on-board choose the wisely. If you are using a 5v supply as VCC then limit the current to 10mA so your resistor will be about 200 ohms (you have two LEDs in series on that board, one embedded in the optocoupler and the visible one). If you use 3v3 your resistor will be about 150 ohms but there is a possibility it won't work at all at 3v3 due to the LEDs voltage drops. Try it and see!
      Remember that the relay switches ON when the digital pin connected to the INx pins is LOW (your µC will SINK the current from VCC via the current limiting resistor).

  • @bigpickles
    @bigpickles 4 года назад

    Thanks very much, very helpful. One silly question I have though, is seeing as I'd like to keep my 12V source (deep cycle agm battery) fully charged, if I were to keep the trickle chargers (12V 1A from 240 mains adapter) cables attached to the battery, and activate a 12V 5A draw via the relay, will the charger/adapter pop, or will the battery deal with the draw? Please excuse my ignorance!

    • @RalphBacon
      @RalphBacon  4 года назад

      If you are _directly_ charging the battery from a charger the the current for any circuit will come from both battery and charger, depending on which has the higher voltage. If the charger can only supply 1A (at which point the voltage will drop) all the "missing" current will come from the battery. It would be better to use a dedicateds battery charger circuit (like the ones for LiPOs) that allow charging and powering a circuit without anything getting stressed. Check out solar panel charging modules.

    • @bigpickles
      @bigpickles 4 года назад

      @@RalphBacon ah like an MPPT controller? Thank you kindly for the reply too. Best wishes

  • @markwatson7636
    @markwatson7636 4 года назад

    Great demo. Can you help me? I have a MT3608 step up converter. I want to increase my output power from the arduino uno to ignite an electric match for my rocket parachute deployment. 9v battery is my power source . Can I power the MT directly from the battery and use arduino as a switch only? I used a blink program to send power to MT3608 thus increasing voltage, but not amps. ??? Any diagram help would be great.

    • @RalphBacon
      @RalphBacon  4 года назад

      If the 9v can ignite the match, Mark, then the Arduino can connect the 9v into a totally separate electrical circuit via the relay. Rough circuit here:
      www.dropbox.com/s/h1bvuntfivrmw5d/9v%20match%20circuit.png?dl=0
      Do watch the demo explanation in conjunction with that circuit.

  • @JohnBaxterWalker
    @JohnBaxterWalker 4 года назад

    Excellent video - thank you. I notice on some coding for relays there is a line in Setup - Serial.begin (115200); . Can anyone tell me if it's important when operating these relays please?

    • @RalphBacon
      @RalphBacon  4 года назад

      That line has no bearing on the relay part of the sketch, John. What it is telling Arduino is that the speed of data transmission from the Arduino back to the PC/Mac (in the Serial Monitor, aka debugging window) is at that speed. So you can then send information back like this:
      Serial.println("Relay ON");
      I tend to use 9600 which is a bit slow but very stable!

  • @frankalvarez7387
    @frankalvarez7387 6 лет назад +4

    Too late, RIP my ESP32 will be missed i ended up shorting VCC and GND :(

    • @RalphBacon
      @RalphBacon  6 лет назад +5

      Maybe not. Shorting out those two pins would overload the AMS1117 voltage regulator but your ESP32 should survive (the power doesn't flow through the ESP32). If you can find the AMS1117 (might be an NCP1117) you could replace it if your SMD soldering is any good, or just attach 3.3 volts to the VDD pin. If it springs back into life you must somehow replace the voltage regulator as that also receives 5v via the USB plug to generate the required 3.3v (or just keep the 3.3 v supply going). Worth playing about with.

  • @DougHanchard
    @DougHanchard 6 лет назад

    After watching this video, I'm more confused about relays than I was before. Muckery...

    • @RalphBacon
      @RalphBacon  6 лет назад

      Oh dear, Doug, that wasn't the intention at all. If you can specify the areas which confuse you I'll do my best to untangle confusion and provide a clear path forward...

  • @jcdock
    @jcdock 4 года назад

    Great info! Might save me killing on of my boards.

    • @RalphBacon
      @RalphBacon  4 года назад +1

      Oh no! Don't kill your board. I can't condone any cruelty to any board. Be kind. It will then work again because it loves you.

    • @jcdock
      @jcdock 4 года назад +1

      @@RalphBacon I won't! I'm always careful !

  • @jeffbluejets2626
    @jeffbluejets2626 5 лет назад

    Well done.

    • @RalphBacon
      @RalphBacon  5 лет назад

      Thanks for your post, Jeff Bluejets, good to hear from you.

  • @rob3125
    @rob3125 4 года назад

    Very useful thanks 👍

  • @saadet4
    @saadet4 4 года назад

    Can the alternate power source be something other than a breadboard power supply? Maybe something a little more friendly for a portable application?

    • @RalphBacon
      @RalphBacon  4 года назад

      The power for the relay (if you are using a dedicated, separate power source for the relay) can be anything you want - but it will need to supply power for as long as the relay remains energised.
      For portable, battery powered devices you really need a _latching_ relay that switches to the open (or closed) position and stays like that even if you remove the power. You can then switch it back again (via a different coil pin) the same way and remove the power. I hope this helps. Portable devices don't really need an isolated relay anyway, so you can power it from the same supply as the µController.

  • @JeanDAVID
    @JeanDAVID 5 лет назад

    Do we need separate ground too ? On a 4 relay modul there is no ground pin next to vcc ! Then we have external vcc on jd-vcc pin and ground on to the gnd pin on the input header.

    • @RalphBacon
      @RalphBacon  5 лет назад

      If the relay board is controlled by optocouplers, Jean, then you do *NOT* need to connect the grounds together. Why? Because the Arduino (or whatever) is effectively just lighting up an LED between a GPIO pin and it's own ground (via that optocoupler). End of. The relay board now does whatever it needs to, by using its own, entirely separate power supply. Fantastic isolation between the two parts. I hope this is clear, if not let me know. Thanks for asking a great question.

  • @marius86ar
    @marius86ar 6 лет назад

    And what do you do when you have only one 5v power supply? Then it means no isolation is possible, right? Maybe a DC to DC isolator will do the trick?
    What is happening if I take out the jumper and I split the power supply so that 5v -> jdvcc, gnd of the power supply -> relay module optocouplers gnd and on the other pins, VCC from 5v+ Arduino pin, inputs from Arduino outputs and gnd remains unconnected. Arduino also is powered by power supply

    • @RalphBacon
      @RalphBacon  6 лет назад

      Well, it's not so bad, Marius, if the relay board is powered by the same 5v as your Arduino, it's just that the level of isolation is reduced. At least this board gives you that choice. And, don't forget that the actual signal path is always isolated. Basically, it's risk vs convenience that we just all weigh up. Good point, thanks for posting.

  • @rabiulislam3406
    @rabiulislam3406 2 года назад

    my realy is good but when i connect the realy with aurdino it not working what should i do

    • @RalphBacon
      @RalphBacon  2 года назад

      Follow the example in my demo _exactly_ and it should work.

  • @MrIonutz2008
    @MrIonutz2008 4 года назад

    Hi, i would like to know if the 24v rated relay modules could be triggered by a 24v signal or the 5v signal is a must .
    Thank you.

    • @RalphBacon
      @RalphBacon  4 года назад

      There are *two voltage ratings* for a relay, Ionut. The first is the COIL voltage, and determines how much voltage you need to trigger (switch) the relay on and off. The second voltage/current is how much current the relay can carry. So a 5v relay with a rating of 24V/5A means that it requires 5V (no more) to trigger it, and can carry up to 24V at 5A maximum. Don't forget the protection diode across the coil, which will be present on a module board like I used, but you will have to add one if you use a bare relay. Is this clear?

    • @MrIonutz2008
      @MrIonutz2008 4 года назад

      @@RalphBacon Thank you for response although i'm not sure i did put the question the right way in order to get the right answer. For example the relay module is this www.ebay.co.uk/itm/1-channel-24v-relay-module-board-shield-for-arduino-with-optocoupler-ZT/362992628401?_trkparms=aid%3D1110001%26algo%3DSPLICE.SIM%26ao%3D1%26asc%3D20190920091355%26meid%3D0afe53015d8d4b729b7d7ba4cf4e6a36%26pid%3D100036%26rk%3D2%26rkt%3D7%26sd%3D402261796421%26itm%3D362992628401%26pmt%3D1%26noa%3D1%26pg%3D2047675&_trksid=p2047675.c100036.m2109 . Not talking about load rating. So, all i need to know is what voltage will require the input pin to trigger the relay on/off via optocoupler. Are the 24v coil modules built to be managed by 24v inpun signal, the 12v coil modules by 12v input signal, the 5v coil modules by 5v input signal or all the relay modules no matter the coil voltage is, are built to be triggered by an input signal in range within let's say 3.3v - 5v ? I'm talking strictly about the way they come from factory, about what range of signal voltage they can handle safely. I want to know if to this 24v coil relay module i can apply 24v as signal input without frying the input zone of module. I hope i made myself understood and i apologize for giving you such a headache. It's all because my bad english. Thank you again.

    • @RalphBacon
      @RalphBacon  4 года назад

      It's not your English that's a fault here, Ionut, just the rubbish documentation on these products! I can't even see the optical isolator, on the board you link to. I suspect the 24v refers to the JD-VCC that goes to the optoisolator (see my video at about 01:58). All the optoisolators require you to SINK the current from VCC (NOT JD-VCC) to ground. I would carefully wire this up to 5v first and test this out as per my demo. Then you can ramp up JD-VCC to your 24V and hope it works. this site has better pictures: www.ebay.co.uk/itm/5V-12V-or-24V-1-2-4-8-16-Channel-Relay-Module-Arduino-PI-ARM-AVR-DSP-PIC-PLC-UK/362951292175
      The 24v relay switching voltage and the VCC for the optoisolator are separate - you don't want 24v anywhere near your Arduino!

    • @MrIonutz2008
      @MrIonutz2008 4 года назад +1

      @@RalphBacon Thank you for response,. i'm sorry i sent you the wrong link, in fact the relay i bought is exactly from the link you sent to me ( the 24v - 2 channel relay module). My first thought was that if the JD-VCC and VCC are bridged by jumper and board being supplied by 24v, the input pins could accept 24v as signal. I don't use arduino, this relay will control the spindle of my cnc router which controller has the output pins providing 24v signal. In other scenario i could remove the jumper to feed separately the relay coil with 24v and for inputs zone i will provide the 5v TTL from breakout board . I guess and hope this way will work.
      Thank you.

  • @kennmossman8701
    @kennmossman8701 4 года назад

    a somewhat common mistake is using a mechanical relay when a solid state relay or device is a better choice;
    1) fast switching speeds (on/off/on)
    20 longevity
    3) fast turn-on
    4) High voltage or current loads
    5) need to have minimum current drain

    • @RalphBacon
      @RalphBacon  4 года назад

      But you did miss one thing, Kenn, that is not so good: HUGE size (compared to a mechanical relay) especially if we factor in the ridiculous heatsink for higher currents. I have...
      I have resisted doing a video on my SSR precisely for that reason. It certainly would not fit in the original consumer unit (fuse box) so it would have to be mounted externally, suitably insulated in a box which then requires drilling etc.
      Some relays are fakes, of course. Rated at 20A and can barely conduct 5A without melting (as other videos I've done have shown). But I've sourced (from a respected UK company) two very nice, high current mechanical relays, with all the correct CE certification that would do the job. But, I'm still thinking of that SSR... What do do!?!

    • @kennmossman8701
      @kennmossman8701 4 года назад

      @@RalphBacon :) to be sure relays have their advantages......including zero loss to the load, multiple poles, isolation .....

    • @kennmossman8701
      @kennmossman8701 4 года назад

      @@RalphBacon personally I'd go with the SRS!

  • @ryanjoshuaverano1382
    @ryanjoshuaverano1382 3 года назад

    Can someone help in my project?
    I used coin sensor and interrupt pin in arduino to catch the pulse that coin sensor sends. Everytime the relay clicks or goes from low to high, the arduino interprets it as the pulse of coin sensor. Any advice?

    • @RalphBacon
      @RalphBacon  3 года назад +1

      Has the relay got a reverse voltage (aka back EMF) protection diode across the coil? You might also need a snubber across the relay contacts to prevent a pulse being generated, more details in video #131 ruclips.net/video/OAmXypXwkeg/видео.html

    • @ryanjoshuaverano1382
      @ryanjoshuaverano1382 3 года назад

      @@RalphBacon im using the same relay module you used in the video

  • @jeremylambright1658
    @jeremylambright1658 3 года назад

    Awesome video! Does anyone know where i could get more info or paid online training on how to write code for arduinos and relays

    • @RalphBacon
      @RalphBacon  3 года назад

      There are doubtless many, many books on the subject, as well as videos, not least on this channel.
      However, the best way to learn is by doing, tweaking and understanding. You should at least be able to understand each and every line in your sketch - even if it's written by someone else.
      Start small, build on that. If you try and design the equivalent of NASA using an Arduino UNO you will become frustrated and eventually give up. My list of videos:
      bit.ly/RUclipsVideoList-RalphBacon

  • @steverose2405
    @steverose2405 5 лет назад

    I have a similar board, but is a bit different. It does not have the troublesome ground next to JD-Vcc and Vcc, just the latter two pins with a jumper, which I have removed. When connecting my independent 5 Vdc power supply, do I use JD-Vcc and the ground pin that is next to the relay inputs? Thanks

    • @RalphBacon
      @RalphBacon  5 лет назад +1

      That's right, Steve. The independent power supply (for the relay) goes to JD-VCC and the ground is common so must go to the GND pin on the board. If you have a multimeter you can prove that JD-VCC is not connected to the Arduino board at all.

    • @steverose2405
      @steverose2405 5 лет назад +1

      @@RalphBacon Good idea; thanks for your support!

  • @FOATE
    @FOATE 5 лет назад

    So this might be a stupid question but when using the external power input on the relay module, can you use the same power supply, like the breadboard power supply you're showing, to power the Arduino as well or does this defeat the purpose? It would be nice to have one psu powering both devices because it saves some space!

    • @RalphBacon
      @RalphBacon  5 лет назад +1

      Not a stupid question at all, dikke j. You can indeed use the same 5v source to power both Arduino and the bare relay (coil). Either drive the relay coil _directly_ via a transistor from a GPIO pin (using a protection diode across the coil), or use an opto-isolated relay as I showed here, which protects the Arduino (and you) better - and arguably is easier to use!

    • @FOATE
      @FOATE 5 лет назад +1

      @@RalphBacon Awesome, I thought it would be possible but I just wanted to make sure since this is all new to me. Thank you very much for being so helpful :)

  • @mhchew1
    @mhchew1 Год назад

    Can we link those relay to our car starter motor?

    • @RalphBacon
      @RalphBacon  Год назад

      Good grief, no! Your starter motor will take many, many amps to turn the engine, far more than this relay will handle. You need a proper automotive part to do that.

  • @ahk501
    @ahk501 2 года назад

    I can't find 30a relay modules with with seprate power pins
    Can anyone suggest one?

    • @RalphBacon
      @RalphBacon  2 года назад

      Depends where you are in the world, Alex. In the UK try RS or Farnell. In the US I'm sure Mouser or DigiKey must have something?

  • @khulileasherembizela3283
    @khulileasherembizela3283 3 года назад

    hey Mr Ralph can you please help me with my project here about 2 sensors , LCD, RELAY MODULE AND ARDUINO ITS my first time using them.

    • @RalphBacon
      @RalphBacon  3 года назад

      You need to start with some simple things first, Khulile. Try getting an LED to flash (and know why it's doing it that way). Then move onto the relay module and get that working. Then do the sensor... the only way to succeed in a project is to break it down into small, manageable chunks. That way you learn how to do each part and can build upon your knowledge. There are plenty of videos on this channel for beginners like you, but you must walk before you can run.

  • @m0gga
    @m0gga 7 лет назад

    Hi Ralph, thanks for sharing this informative video. I am currently working on a project for the control of various 240v devices used in my fish keeping hobby and have recently purchased a couple of similar relay modules with solid state relays, so as to eliminate the noise of the relay contacts. Do your recommendations in this video apply to solid state devices and are there any other pitfalls associated with using them, other than the obvious current limitations of the relays?
    Thanks.

    • @RalphBacon
      @RalphBacon  7 лет назад

      Hi Fred, and welcome to my channel!
      A solid state relay is, mainly, an opto-coupled triac so it behaves very similar to the opto-coupled part of the relay that I described (without the actual relay!). You still have to protect the circuit from spikes and back-EMF from any motors you might be driving (or anything else with a coil, such as a fan) but apart from that it should all work as you would expect.
      The Arduino will drive the 'input' (usually an IR LED) which is received by an photo-sensitive diode/triac connected to a mains voltage triac (a bi-direction thyristor) - usually with a zero-crossing component in the middle to ensure the off and on states only occur as the AC mains voltage crosses the zero voltage line - thus eliminating (or minimising) any RF interference generated.
      As you say, they are silent and work pretty much as you might expect. Just be aware that the IR LED driven from your Arduino must include a limiting resistor (usually) and the breakdown voltage of that diode is probably not much more than the 5v Arduino output level so don't connect it in reverse by mistake! Ideally you should reverse connect a standard diode in parallel with the input IR LED to protect it from just such a mishap.
      Additionally the forward voltage of that LED is pretty low, about 1.2 volts rather than the 2.0+ volts of standard LEDs. Refer to the maker's datasheet to find out the exact figures or you might overdrive the LED. From a 5v Arduino output the limiting resistor would be 5v - 1.2v = 3.8v drop at 20mA = 190R or the nearest (higher) preferred value.
      Finally, if I recall correctly, you should incorporate a snubber circuit in parallel with (and close to) the output pins that consists of a capacitor (suitably rated for mains use) and a resistor - a 0.022uF capacitor and a 47R resistor is a good starting point. This absorbs surges created by the load which may turn the relay back on again.You may not need this depending on what you are switching, but at least you know about it.
      I hope this helps and may your fish continue to thrive!

    • @m0gga
      @m0gga 7 лет назад

      Thanks for such an in-depth reply! Please take a look at this module which is the one I have
      www.ebay.co.uk/itm/132067724356? , is this not a plug-and-play solution not requiring any additional circuitry?
      Thanks.

    • @RalphBacon
      @RalphBacon  7 лет назад

      Squinting sideways at the photos on the eBay page it shows that the Omron relay model is a G3MP-202P, which if you look at the datasheet for that relay (www.mouser.com/ds/2/307/g3mb_0609-298620.pdf) it states on page 1 under Ordering Information that that model does contain both Built In snubber circuit AND input resistor.
      Woo Hoo! You have got the jackpot and therefore don't need to consider either (probably why the manufacturer of the board used them for Arduinos et al, as they save components). Phew! (More by luck than judgement, but hey, who cares how?!)
      Plug and play it is, indeed.
      Just watch the current on the (presumably) mains side of things, 2A max if you're using heaters for the water etc. 230V x 2A = 460W, sounds a bit high for a fish tank heater, you could boil a cup of water with that so I guess fish tank heaters are more in the 25W range? Your fish will love you.

    • @m0gga
      @m0gga 7 лет назад +1

      What a result! My fish and the relays will indeed be happy, especially since the highest rated heater I use is only 100W. Generally speaking most common fish tank heaters are between 25W-150W.
      Thanks for all your assistance.

  • @supremeleader5516
    @supremeleader5516 Год назад

    Thanks

  • @raillersinghirina8345
    @raillersinghirina8345 8 лет назад

    Thanks for all tuto!

    • @RalphBacon
      @RalphBacon  8 лет назад

      +raillersing Hirina You are most welcome! I hope it's helping you get your Arduino project(s) further forward. Remember to spread the word and, if you haven't already done so, please subscribe so you don't miss future videos.

    • @raillersinghirina8345
      @raillersinghirina8345 8 лет назад

      Hi!!Can you explain the variable type boolean...I dont understand it and I have not found tuto about it. I saw it in the book: Exploring Arduino. My problem is: I have never seen this in language C. I can give you the book if you give your email.

    • @RalphBacon
      @RalphBacon  8 лет назад

      Sure.
      A boolean variable (bool) can be either TRUE or FALSE. For more details see here: www.arduino.cc/en/Reference/BooleanVariables

    • @raillersinghirina8345
      @raillersinghirina8345 8 лет назад +1

      thanks

  • @chrism3790
    @chrism3790 3 года назад

    Why do you connect VCC and then set the pin to HIGH to keep it closed, instead of connecting the ground and setting the pin to HIGH only when you want it opened? I read some comments saying you can only switch on relay at a time like that, but I'm not sure I understand why... Is there something I'm missing? I have my relays coming in tomorrow and don't want to blow up my ESP8266 hahaha

    • @RalphBacon
      @RalphBacon  3 года назад

      I don't fully understand the question, or what you think I'm doing, but I can tell you the Esp8266 will SINK the current for the LED on the relay board's optoisolator when set LOW (HIGH is off). So the other side of the LED is connected to VCC. Take a close look at the circuit diagram in the video. Still confused? Let me know!

    • @chrism3790
      @chrism3790 3 года назад

      @@RalphBacon Thank you! My parts just arrived. I'll be trying to figure it out this weekend :) will definitely revisit your video then.

    • @chrism3790
      @chrism3790 3 года назад

      @@RalphBacon Ahhhhh now I understand!!! Took me a bit of tinkering, but your video makes total sense now! Thanks!

    • @RalphBacon
      @RalphBacon  3 года назад

      Great stuff! don't let the magic smoke escape!

  • @juliusferrer2071
    @juliusferrer2071 7 месяцев назад

    i tried to remove the ground pin among vcc and IN pins to one of my 4 relay module and now the led wont work...i think i broke it :< just like what you did on 8:07

    • @RalphBacon
      @RalphBacon  7 месяцев назад

      I don't think you can break a relay module just by removing the ground pin but you can check it's operation in two stages; the opto part first, followed by the actual relay power.
      If the LED lights up then it will all work. Remember you need to have the GND connected in all cases.

    • @juliusferrer2071
      @juliusferrer2071 7 месяцев назад

      ​@@RalphBaconIve absorb many infformations(including yours) in my head, still cant reach solve my main problem..