How to use relay with Arduino to control AC or DC load with bare relay

Поделиться
HTML-код
  • Опубликовано: 17 авг 2024
  • This video explains how to use or drive 5V relay with Arduino and shows you schematic .
    **** Free Arduino Course worth $200***
    Arduino Step by Step Course (over 100 lectures) Starts here robojax.com/L/?...
    I will reply to all Subscriber's 🔔 questions. So make sure to Subscribe.😊
    Please like 👍 the video and type simple word in the comment. It helps me a lot.
    Get the code and other resources for this video robojax.com/L/?...
    ** Purchase Bare Relay from **
    Amazon Canada: amzn.to/3B1iu9Z
    Amazon USA: amzn.to/3AXO6xc
    All other Amazon: amzn.to/3AWxeaj
    Banggood (1 pcs): www.banggood.c...
    Banggood (10pcs): www.banggood.c...
    AlExpress (10pcs): s.click.aliexp...
    ** Purchase Arduino Start Kit **
    Amazon USA: amzn.to/3z88F9G or just UNO board amzn.to/3aY7KOL
    Amazon Canada: amzn.to/31an88J or just UNO board amzn.to/3pYxSNN
    Amazon Europe (all Europe): amzn.to/3pMCHge or Just UNO board amzn.to/2PgGItD
    AliExpress: s.click.aliexp...
    Banggood: www.banggood.c... or UNO board www.banggood.c...
    eBay: ebay.us/B1JWLi
    ***** Purchase Authentic Arduino Uno from ***
    Amazon USA: amzn.to/2KApAwK
    Amazon Canada: amzn.to/37LZ8sW
    All Europe Amazon: amzn.to/36YDSzn
    00:00 Start
    00:40 Introduction
    01:13 Hardware explained
    05:00 Wiring explained
    06:17 Code explained
    10:43 Demonstration
    Watch my video on 5V relay module to control AC bulb: bit.ly/5v-relay
    Tutorial by Ahmad Shamshiri form Canada
    ****************************
    Arduino Step by Step Course (over 100 lectures) Starts here • Lesson 00 What is Ardu...
    ****************************
    If you found this tutorial helpful, please support me so I can continue creating contents like this. Here is PayPal link paypal.me/robo...
    Follow me on Facebook robojaxTV
    Follow me on Twitter: / robojaxtv
    Follow me on Instagram: / robojax
    Tutorial by Robojax.com
    Get other projects code and learn Arduino
    robojax.com/lea...
    *** AFFILIATE PROGRAM ***
    We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.
    #robojax #robojax_relay
  • НаукаНаука

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

  • @clarkso65
    @clarkso65 5 лет назад +5

    This is so far the best arduino basic tutorial! Good job

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

      Thank you for your kind comment.

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

    Finally somebody who explained it in a good way.

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

    The best " How To" videos. Thanks !

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

      you are welcome.

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

      I'm starting off from ground zero building an electronically controlled air / wood gas carburetor , using Arduino, an O2 sensor and servo motor to operate the carb's butterfly valve in order to compensate for rich/lean conditions. Your videos have proven to be a great help towards this goal. Much appreciated !

  • @m.fadhiilhaekal7693
    @m.fadhiilhaekal7693 3 года назад +1

    Best Tutorial Ever !!

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

      I am glad you liked it. You may watch my $200 udemy course for free ruclips.net/video/-6qSrDUA5a8/видео.html

  • @krah-basteln-hobby
    @krah-basteln-hobby 3 года назад +2

    Excellent! I think this video is good! Your video was great! I can do things myself with the Arduino! Thank you! 👍😉😎

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

      Glad it was helpful!

  • @user-kw3hb9kh6o
    @user-kw3hb9kh6o 9 месяцев назад

    well explained ... my quesstion is ,, is it possible to use IN5399 Diode?

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

    You are the best sir, thanks for sharing this video

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

      You are welcome. I am glad you found useful. Ahmad from Canada.

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

    Absolutely fantastic description. Keep up the good work. Brilliant!

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

    can i use it without the transisor, only with a HIGH pulse and ground connect to the coil ?

    • @robojax
      @robojax  4 года назад +2

      No you can't. why would I have bothered to waste time and efforts to make DRIVER? without driver your Arduino board will die. This relay needs 70mA while Arduino digital In/out pin can supply only 30mA see it here and click "TECH SPECS" store.arduino.cc/usa/arduino-uno-rev3

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

    This video was perfect for my application and I was able to complete my PCB. However, I just learned about optocouplers and this may be a far easier approach. Nonetheless, thank you for your time, schematics, and explanation!!

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

      Yes optocoupler can be used to protect or isolate stages of project, but it will as extra component to the circuit and cost. If isolation bid not critical, we should not use any extra components. Good luck and stay safe.

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

    I just connected 2 pin of 4 pin-relay (SRD-05VDC-SL-A) . One to pin 9 and one to ground of arduino pro mini - without any resistor. And one cable of 220 lightbulb to relay's NO pin, and it worked perfectly. Is that dangerous? Can I fry or destroy my arduino this way?

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

    what resistor(Diode) should be connected to 5 volt relay to avoid flickering?
    value of resistance please...

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

      Here is the video ruclips.net/video/x2YxfV1L02Y/видео.html you could just search for "resistor" on my channel.

  • @user-kw3hb9kh6o
    @user-kw3hb9kh6o 9 месяцев назад

    What is the power rating of the bulb you have used?

    • @robojax
      @robojax  9 месяцев назад

      it does not matter. the relay is a switch. Just read your relay. if it says 10A, then connect it to 10A or so.

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

    Great! Is it possible to put a potentiometer to speed on/off? ✌️

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

      Search my channel to find more or see this ruclips.net/video/6DGQhQgr7Ak/видео.html

  • @user-if8pi3mj8f
    @user-if8pi3mj8f 2 года назад

    great video

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

    Merci, clair et précis 👍👍👍👍👍

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

      Je vous en prie. Merci de ne pas sauter les publicités et de continuer à les regarder. Cela m'aidera beaucoup.

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

    Hello sir. May i know which pin the load connected? Is it the coil or the common and normally opened pin? Ive been trying to connect from the power supply to relay then the relay to the load thrn back to power supply. Can u tell me in more details because the figure u have shown is a bit confusing to me. Thanks

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

      Hello, I have fully explained it. You have to watch and do not skip the video. I am sure you will know it if you watch .

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

    can this relay be used as, basic gates for home brew 4 bit computer ALU ?

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

      relay is just a switch. it turns ON or OFF DC or AC load as long as the current of the load does not exceeds the relay rating.

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

    is this 5V relay is undervoltage or overvoltage...this ques asked in viva

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

      Hi, please watch this ruclips.net/video/58XWVDnB7Ss/видео.html

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

    Thank you for the tutorial! Question: If you use a 5V relay, can you just connect it directly to the Arduino without needing the transistor?

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

      you are welcome. from your question, I know you have not watched the video fully or skipped. The answer is in the video.

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

      @@robojax I watched the whole thing, but I guess I missed it. I’ll watch it again.

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

      @@robojax I watched the complete video 2 times now, and did not find any answers to my question.

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

      you made me watch the video. at about 00:40 I said "you need to be able higher current" may it was not clear to you. you can't connect higher current loads like bulb or fan directly to Arduino as Arduino supply very little current, so we use relay to handle higher current.

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

      @@robojax My question was about connecting the relay *coil terminals* to Arduino, not the common or outputs. We can activate the 5v coil terminals using the Arduino directly, so why do we need a transistor?

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

    if the relay load is connected between emitter and ground does the transistor going to face any kind of damage?

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

      if you connect it between E and GND, it may not work. The relay needs about 40-80mA and I've selected 2N3904 and I have provided the datasheet which show it can handle 200mA see it here media.digikey.com/pdf/Data%20Sheets/ST%20Microelectronics%20PDFS/2N3904.pdf

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

    Hi sir I would like to control the DC voltage power supply on off button using arduino. What kind of relay should I use.

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

      you can use this relay ruclips.net/video/58XWVDnB7Ss/видео.html or this ruclips.net/video/7tUGUXyloXQ/видео.html and here is how to control relay with push button ruclips.net/video/7CCSRs5bvH0/видео.html

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

    Thanks

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

      You are welcome.

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

    good day sir nice video, very informative. i wish to control a universal motor using an ir sensor, relay with arduino. your video has been helpful in the relay and transistor circuit part. now is it possible for me to connect an ir sensor to the arduino and the sensor will be the one that will tell the arduino to switch on the motor? please give me feedback Robojax

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

      Hello, you learn from this video ruclips.net/video/T3Li128GBlM/видео.html and combine it with relay . here video using relay module with Arduino ruclips.net/video/58XWVDnB7Ss/видео.html

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

    i have the NPN Transistor PN2222. Would that work?

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

      with your question, you make me watch the video and I realized that you have not watched the video. please watch again if you want to learn and use it. I saw the answer in the video.

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

    Nice sir

  • @Max-ge6jf
    @Max-ge6jf 4 года назад

    Why can't we use arduino as a switch? What if we send low and hight outputs to the relay directly through arduino? Why we use transistor? Please tell.
    Thanks!

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

      Hi, I made this video to answer all. That Please watch the video I can assure you, the answer is there.

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

      I was wondering this as well even after watching the video a couple of times. I did a search and I understand that the current supplied from the Arduino pins is limited and not reliable enough to consistently hold the relay open. There is an explanation here. arduino.stackexchange.com/questions/17022/reasons-why-it-is-not-ok-to-connect-a-relay-directly-from-an-arduino-digital-pin

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

    Does anyone here could explain to me, why do we need to use a diode to this project? Is there problem if we don't use it? Thank you!!

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

      Hello, I have mentioned what it does. Full details here resources.pcb.cadence.com/blog/2020-modeling-a-relay-with-diode-for-surge-protection

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

    Can use bd139 transistor ? Instead

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

      Yes you can . I checked the datasheet and it is NPN transistor www.st.com/resource/en/datasheet/cd00001225.pdf

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

      @@robojax ❤️

  • @itsjonny-rp5ve
    @itsjonny-rp5ve 3 года назад +1

    Thanksssssss

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

    Thank you for your video! Do you think that a 2N2222A transistor will work for this application?

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

      You are welcome. Yes it will work. The best "thank you" for me is to subscribe to my channel. thank you.

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

      @@robojax Doneee!

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

    Sir , jo relay pe LED & Resistor mount kiya hei uski value bataiye....pls

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

      sorry. English please.

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

    Is VCC must 5 v ??
    Can we use 12 v as VCC?

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

      Yes you can if you get the 12V relay. This relay is 5V

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

    How can I Drive a rele with humidity or water sensor, I mean the code
    Thanks

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

      Hi, Here are my videos on Temperature control so you can use them depending on the type of temperature sensor: ruclips.net/user/robojaxTVsearch?query=temperature

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

    what is the purpose of the transistor ?

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

      you have to watch the video. at 00:54 I have explained it. Later in wiring I have explained it. you can't turn ON directly using Arduino. Relay needs 70mA or higher. Arduino can provide only 30mA so you need to drive the relay using transistor as amplifier. Please watch the video and do not skip. I have not said anything excess.

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

      @@robojax thx for the explanation, i did not notice the part about relay needing 70mA

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

      you are welcome.

  • @AhmedMohamed-bk3go
    @AhmedMohamed-bk3go Год назад

    السلام عليكم ورحمة الله وبركاته رمضان كريم

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

      وعلیکم السلام و رحمة الله وبرکاته. رمضان کریم.

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

    Why do you use a diode?

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

      Watch the video without escaping, I have explained it.

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

    How to connect multiple relays to the arduino

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

      you could have just searched this without waiting but here is the link ruclips.net/video/Wbm3MCMgM_s/видео.html or see all relay related videos ruclips.net/user/robojaxTVsearch?query=relay

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

      @@robojax i dont have relay module i need to know how to connect 4 individual relays how do i do that

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

      what is this video for? just make 4 of this and you have 4 channel relay.

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

    Hello, I am working on theft detection meter. For this I have used two current sensors. I want to turn off the load when values of these two sensors are not equal and turn the load back when both values of sensors are equal. I have write a code and used while and if statement for this purpose. When sensor 1 is less then it turn off the load and displays phase line bypass . For this case the code is working perfectly and it turn off the load until the phase line back to normal condition but when I go to second case which is if sensor2 is less than sensor 1 by using the same code part then it didn't work. It keeps turning on and off the load .
    Here is the code. can you please help me in this and tell me where I am doing wrong? It would be helpful for me. Thanks
    // THEFT PART
    while (ecurrent1 < ecurrent2){
    CT1(); CT2(); // calls current measuring function of both sensor 1 and sensor 2
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print("Phase Line Bypass");
    digitalWrite(13, HIGH);
    if(ecurrent1 == ecurrent2)
    {digitalWrite(13, LOW);
    lcd.clear();
    lcd.print("Back To Normal");
    delay(200);}
    }
    while (ecurrent2 < ecurrent1){
    CT2(); CT1();
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print("N Line Bypass");
    digitalWrite(13, HIGH);}
    if(ecurrent2 == ecurrent1)
    {digitalWrite(13, LOW);}

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

      why you have the "if" inside "while" loop? this will never run because ecurrent1 == ecurrent2 will not be true as you have while (ecurrent1 < ecurrent2).
      if(ecurrent1 == ecurrent2)
      {digitalWrite(13, LOW);
      lcd.clear();
      lcd.print("Back To Normal");
      delay(200);}

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

      @@robojax Thanks for your reply. As I said earlier for "Phase Line Bypass" that part is working fine but when the same goes for "neutral Bypass then it didn't work. Can you please tell me how can I achieve my results?

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

      I did not understand "neutral by pass". My be draw diagram and post the image here snipboard.io/ and then share the link

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

      Please subscribe. I appreciate it.

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

    Poor video.. unable to see pin connection

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

      you skipped. watch without skipping. it take 5 seconds to write comment but you need to watch it for 12 minuets to learn. unfortunately you've skipped thinking you are "smart"

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

      @@robojax Dear Friend, consider my apologies if I heart you in any way, by the way I am one of your fan from Pakistan, please continue doing good thing and keep helping people like me. Regards

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

    Isn't someone better off using a realy module instead of using the relay and attaching all the resistors and diode?

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

      of course it is better. but you never learn how it works and what it does. This is in case you want to make your own relay driver. here is the module ruclips.net/video/58XWVDnB7Ss/видео.html

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

    4:57

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

      what about it? say something. this video already has chapter and you see them like this snipboard.io/6sIgKA.jpg

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

      Circuit diagram

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

      I have not only shown it but fully explained it as to how it works. please watch.

  • @0110ahsh
    @0110ahsh 2 года назад

    my relay burned

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

      It never burns unless if relay is 5v and you connect higher voltage. Only higher voltage will kill it . Overloading is also killing it

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

    Badly explained

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

      Thank you. Tell me please what did I leave out? I will fix it and re-post it.