How to use an Arduino Relay Module

Поділитися
Вставка
  • Опубліковано 20 сер 2024
  • Arduino relay circuit and Arduino relay code:
    In this video we’ll learn how to use a SainSmart 4-Channel 5V relay module with an Arduino. We also discuss the SainSmart relay board’s capability, its use of optocouplers for optoisolation, and how to hook up the Arduino relay circuit. We use the Arduino to switch a light on and off, demonstrating the relay’s ability to control high voltage loads with an Arduino.
    Where you can buy the tools and materials:
    [✓] Arduino Uno amzn.to/2zqDqXE
    [✓] SainSmart 4-Channel Relay Module amzn.to/2xUvJN7
    [✓] YwRobot Breadboard Power Supply Module amzn.to/2yDuwsb
    [✓] 9V Power Adapter amzn.to/2yDSF1F
    [✓] Extension Cord amzn.to/2xVKxuC
    [✓] Breadboards amzn.to/2yDvapn
    [✓] Jumper wires amzn.to/2zpiT5E
    [✓] Light seen in the video amzn.to/2zrgTto
    Links:
    More on Optocouplers
    searchnetworkin...
    www.futureelect...
    More on Wiring Relays:
    www.how-to-wire...
    electronics.st...
    www.dummies.com...
    www.hunker.com...

КОМЕНТАРІ • 85

  • @mjneil
    @mjneil 4 роки тому +88

    As an electrician I suggest you consider using low voltage examples. The method you used to strip and terminate the cables is dangerous at best and potentially deadly for people less familiar with electricity. exposed wiring is an accident waiting to happen

  • @briantoste904
    @briantoste904 3 роки тому +4

    Super useful, could not for the life of me figure out why the relays were energised when the arduino outpu was set to low! Wish i had found this video before i spent the past few hours trying to figure out what i did wrong! Thanks!

  • @jimbrownza
    @jimbrownza 6 років тому +21

    It's recommended that just in front of the pinMode command, you make the pin high with a digitalWrite. That way, the pin will never be accidentally randomly low when it changes to output from the default of input: that could be catastrophic if it was say a motor or something that might activate accidentally in setup().

  • @Shibu11229
    @Shibu11229 Рік тому +1

    Thank you for posting this. I would love to see a follow up video with the Arduino controlling a relay based on input to the Arduino. In other words if I press one button the relay would be activated for one second. If I press a second button the relay would be activated for 10 seconds and if I press a third button the relay would stay activated unless a separate signal told Relay to shut off.
    I am trying to control an AC motor that will raise a platform to various heights.

  • @gordonbrown2204
    @gordonbrown2204 6 років тому +55

    Nice video... but dude, buy some wire strippers XD

    • @EvenTheDogAgrees
      @EvenTheDogAgrees 5 років тому +3

      And while you're at it, some ferrules and a crimper. Those individual strands are an accident waiting to happen.

    • @mlee6050
      @mlee6050 4 роки тому +4

      @Juan Rial at least this is safer than electroboom things

    • @android3447
      @android3447 4 роки тому +1

      😂but thanks for the video man💪

  • @azazer1700
    @azazer1700 4 роки тому +9

    even though i never used high voltage, i would not recomment leaving the wires exposed. just in case sombody tryied to do it,but greatvideo anyways! :)

  • @Fringedweller1000
    @Fringedweller1000 3 роки тому +4

    The idea and the code are great.... BUT SERIOUSLY
    If anyone follows your technique they are putting themselves at very high risk of:
    o Getting an ELECTRIC SHOCK from the AC supply
    o Slicing their fingers open with that knife
    Firstly - NEVER EVER allow that much copper to be exposed at the relay terminals. The chances are the wires will make contact causing a spark or even fire.
    Second - allowing that much exposed copper open someone up to inadvertently touch it.
    The wire should be stripped back with wire strippers (not a knife) and only a little copper showing on the TIP of each end of the cut wire. (Far better to use bootlace crimps to reduce risk) insert into relay output screw terminals with wire installation hard against outside of terminal block
    Third the knife… arrgh like others have stated get a set of wire strippers why run the risk

  • @jmscnny
    @jmscnny 4 роки тому +35

    I was going to comment about the AC wiring, but what's the point? He's probably already dead.

    • @eddie5556
      @eddie5556 4 роки тому +4

      I almost spit out my coffee...:>

    • @PeterSedesse
      @PeterSedesse 3 місяці тому

      This is like watching one of those wingsuit videos. You see the video, see the date it was published, then scroll down and all the comments are RIP..

  • @Mat-vb8er
    @Mat-vb8er 4 роки тому +3

    Why does the relay need 2 VCC's'? One VCC is coming from the BB PS and then you connected 5V from Uno? Why is that? Cheers

  • @cym.1867
    @cym.1867 2 роки тому +3

    As pointed out by many, the stripping of the Hot wire was done poorly and, the naked wires fairly dangerous although it's just the Hot wire and not very dangerous since not touching the ground or eart, but what if a student tries this standing barefooted on a damp concrete floor and the electricity was earthed ! Otherwise nice job explaining the function and usage of a Relay. Thanks.

  • @ericlessard5021
    @ericlessard5021 7 місяців тому +1

    Can someone help me? I need to control 4 relay with a 4 axys joystick. On position 1 of the joystick, 3 relay need to be on. On position 2, 2 relay need to be on. On position 3, 2 relay beed to be on. On position 4, one relay need to be on. Those relay will control some hydrolic valve...

  • @walterhynson2898
    @walterhynson2898 8 місяців тому

    yes you made a good video and the instructions are on point however please purchase a pair of wire strippers and learn to properly connect an AC circuit insure there are no exposed wires by using the proper size or guage of wire and when connecting a wire open (unscrew) the terminal far enough so the wire is inserted and there is no exposed copper hanging behind the terminal.

  • @rubenvaneupen7327
    @rubenvaneupen7327 Рік тому

    Can you explain how to connect the high voltage circuit? I want a 12V circuit: for the load, on the output side. + goes to NC, - goes to com, but where to wire up the input + and - wires from the 12V battery?

  • @conradstanley1027
    @conradstanley1027 3 роки тому

    Nice I can hardly wait!!

  • @zColdEli
    @zColdEli 4 роки тому +1

    Why do I need to provide 5V to the VCC port from the arduino if you are already providing it in the isolated channel?

    • @aakashsetty266
      @aakashsetty266 2 роки тому

      I also have this question. Any help is appreciated!

  • @raj_srikar
    @raj_srikar 4 роки тому

    Can I use two 3.7V lithium ion (18650) batteries to connect to the JDVCC pin to get opto isolated circuit?

  • @cafauer5195
    @cafauer5195 3 роки тому

    Heads up some of the affiliate links do not work in the description

  • @pound7108
    @pound7108 5 років тому

    I am facing problem doing wiring of "LED will relay module".
    If I attach both wire in
    1&2 it starts automatically/instantly
    In 1&3 or 2&3 nothing happens

  • @JanosTerroz
    @JanosTerroz 5 років тому

    Nice job sir.

  • @azimalif266
    @azimalif266 3 роки тому

    Can you convert these modules into a solid state relay by switching out the relay with with a mosfet?

  • @royramirez3343
    @royramirez3343 6 років тому

    Dude you are amazing!

  • @ekanshdeepgupta658
    @ekanshdeepgupta658 4 роки тому

    At 1:02 why do you remove the jumper? Can it be used without the jumper? Does removing the jumper pose any risks?

  • @dveram47
    @dveram47 4 роки тому +1

    What if I want to add a second light bulb to another relay from the same power source, how would I able to do this?

  • @nathanjohnson5955
    @nathanjohnson5955 2 роки тому

    Is the surge protector necessary for this setup to work?

  • @sharankumar8861
    @sharankumar8861 6 років тому +1

    Thank u for your... video which helps me a lot in my project...
    Can I know the reason why? you used YWROBOT as a isolated supply..instead of direct supply from arduino…?

    • @tinkerbuild6798
      @tinkerbuild6798  6 років тому +4

      It's for electrical isolation. If there's back emf in the relay or something goes wrong then the Arduino could get damaged without it. This blog post helped me understand it: howtomechatronics.com/tutorials/arduino/control-high-voltage-devices-arduino-relay-tutorial/

  • @diegoscala4505
    @diegoscala4505 6 років тому

    Good job man!!!

  • @AshiqurRahman
    @AshiqurRahman 3 роки тому

    Can I use this method to connect esp32 board? [Esp32 provides 3.3v ]

    • @AshiqurRahman
      @AshiqurRahman 3 роки тому +1

      Yes. I have tested it.

    • @novertrunnions2721
      @novertrunnions2721 3 роки тому

      @@AshiqurRahman Why did you respond with an answer to your own comment like you were on a different account? :D

    • @moeyali123
      @moeyali123 2 місяці тому

      @@novertrunnions2721 hahahahahaa

  • @omyfreakingawd789
    @omyfreakingawd789 4 роки тому +1

    Super clear - appreciate it.

  • @MrSpock-sm3dd
    @MrSpock-sm3dd 3 роки тому

    I don't get when you say "digital pin 3" in 1:55 but in your code 3:15 the digital pin is equal 2

  • @Nocturnes1984
    @Nocturnes1984 3 роки тому

    Wire strippers and please....some plugs for your cables... its a good video but i'm puking at the electrical wiring :)

  • @megankilinski4580
    @megankilinski4580 5 років тому +1

    I wish you had gone into more detail about how this set-up was wired, the power supply, each relay circuit, Arduino.

  • @theonewhowas7709
    @theonewhowas7709 2 роки тому

    THANK GOD, someone that speaks proper english finally explaining this correctly... thank you a ton!!!!..
    you definitly earned my sub and like!!!! but just wanna say that wiring job was horrid.. and why were you shaking so much.. dang

  • @maximilianklein7779
    @maximilianklein7779 4 роки тому

    Hey - I was wondering if you could elaborate which of the three pins on the relay you connected the GND/VCC and why there Is a third pin...

    • @xenith0351
      @xenith0351 4 роки тому

      The three pins are
      N/O normally/open
      COM common
      N/C normally/closed

  • @SultanAlawad
    @SultanAlawad 4 роки тому

    What if I want to use a battery?

  • @TheMscandy123
    @TheMscandy123 4 роки тому

    Can I use a 12v relay?

  • @youssefmosalam4638
    @youssefmosalam4638 5 років тому

    Hey sir
    Now i connect like this
    And the relay is active LOW
    But i set the code to switch on by High
    And switch off by set it Low
    Which is wrong (you said this)
    When i connect the relay to the lamp it works normally but after a while it lags and the lamp switch off but the relay green lamp blinks as it switch on and off but the lamp doesn’t work
    And this is problem
    I found also that when i connect the relay to the pin a voltage drop occurs and the volt become around 3.2 not 4.5 or more and the lag occurs (( I’m using atmega not the arduino and 9 v battery))
    Please help me

  • @shadowpaars
    @shadowpaars 6 місяців тому

    speaking of safety, if ur not an electrician pls don't do it with 230VAC

  • @Esteapen
    @Esteapen 5 років тому

    Hello guys, just wanna ask, I want to connect my arduino to a 12v battery (It's possible right?), if so, I want to control a light bulb with the same power source also 12v battery, do I still need a relay? If so what volt should I use?

    • @myrkazamora2140
      @myrkazamora2140 4 роки тому

      I'm trying to do the same thing did you ever figure it out?

    • @xenith0351
      @xenith0351 4 роки тому

      From what i understand u can get 12 v relays the adrino only runs on 5v (which u can get from a 12v phone charger) the arduino can only take very low current . So yes u need tge relays

  • @GTTalera
    @GTTalera 5 років тому

    Why had you collected all those drink cans?

  • @DannZylman
    @DannZylman 4 роки тому

    so the relays are 5 v right ?

  • @protonengineer2934
    @protonengineer2934 5 років тому

    How to program an aurdwino

    • @liberated_geek4428
      @liberated_geek4428 4 роки тому

      #define BLYNK_PRINT Serial
      #include
      #include
      char auth [ ] = "key";
      char ssid [ ] = "name";
      char pass [ ] = "pass";
      void setup ()
      {
      Serial.begin(9600);
      BLYNK.begin(auth, ssid, pass);
      }
      void loop ()
      {
      Blynk.run ();
      }

  • @leftitbe
    @leftitbe 4 роки тому

    ....next time the video looks more suitable (professional) when you put first the alu cans in the waste paper basket.

  • @wayneshephard
    @wayneshephard 4 місяці тому +1

    Wow, fancy UA-cam leaving a video up like this with such dangerous work, really disgraceful and dangerous workmanship, nobody should follow this video in regards to the AC terminations, clearly no clue or capability to deal with AC voltages.

  • @OGpimmelberger
    @OGpimmelberger 6 днів тому

    Standard Lamp😂

  • @bentimiday9123
    @bentimiday9123 2 роки тому +1

    Ummm dont fuck about with mains voltage? Ever?

  • @bartbonnyns
    @bartbonnyns 4 роки тому

    Hello @UCXRkG_PB-qAR67_LBMLONcA,
    Thnx a lot for your great UA-cam, It means a lot if you share what you’re good in, so we can learn from each other. I hope you have time for a small simple question. Is there power on your relay coil when the NO contact is closed (when you’re hooked up appliance is on) like a standard relay or does it gets a pulse each time you switch on and off you’re appliance?
    Greats
    Bart

  • @arifcaka3627
    @arifcaka3627 3 роки тому

    helal lan adamsın

  • @aniessaboulsoof
    @aniessaboulsoof 3 роки тому

    even if you are alone in your room and nobody touch your equipment and you are sure 100 percent from that, you should never connect the relay to the ac 220 volt this way,,, its dangerous man,,, safety first before anything ............

  • @garycahill6574
    @garycahill6574 5 років тому

    Great info but with high voltage wiring like that someones gunna die...

  • @burstfireno1617
    @burstfireno1617 3 місяці тому +1

    Ehh please dont cut and strip wires like this.. looks very unprofessinal. Where are your tool? 😅

  • @madbrit5053
    @madbrit5053 4 роки тому +1

    Thanks, but you need to slow down, and drink less red bull ITS BAD FOR YOU as we can here

  • @CHALLENGER3000
    @CHALLENGER3000 4 роки тому

    i think he took his redbull addiction little too far, judging by the shear amount of empty cans in the background and HIS SUPER SHAKY HANDS!!!

  • @zColdEli
    @zColdEli 4 роки тому

    This video is a fkin bible for someone trying to learn how to even start powering a high powered device.

  • @13anomalous16
    @13anomalous16 4 роки тому

    the relay is active LOW???? What in the fuck?

  • @antiquarian1773
    @antiquarian1773 2 роки тому

    thats a lot of redbull.

  • @karlhill6652
    @karlhill6652 3 роки тому +1

    Nice video but please re-do it!!!!.. or you will be sued by someone!
    Those over exposed wires to the mains is HORRIBLE! If someone tries out the way you handle live voltages they will DIE!!!
    I know, a suggestion after almost 3 years on the tube but rather later then never, this is DANGEROUS!!!

    • @FastGamingSeries
      @FastGamingSeries 3 роки тому

      Yes this isnt safe, but I do not think you know how electricity works.

  • @Legend813a
    @Legend813a 11 місяців тому

    The cringing begins at 2:34

  • @Metallicafan818
    @Metallicafan818 3 роки тому

    rip hope i dont die

  • @freelectron2029
    @freelectron2029 5 місяців тому +1

    bro.... you butchered those wires. do yourself a favour and buy some side cutters and strippers.

  • @diegoscala4505
    @diegoscala4505 6 років тому

    First!!! ;)

  • @bcddd214
    @bcddd214 3 роки тому +1

    Horrible job of showing how it's wired together.