Using Sensors with 5V Relays on the Arduino

Поділитися
Вставка
  • Опубліковано 20 сер 2024
  • Using Sensors with 5V Relays on the Arduino
    Learn how to use sensors with the Arduino to turn on and off of a 5V relay. This project will show you how to control high voltage devices with low power sensors and inputs. I use a light bulb to demonstrate but the 5V relay can switch on/off any 120-240V device.
    Get a 5V Relay here: www.amazon.com...
    Visit the blog post for this tutorial to get more information, diagrams, and the code: www.circuitbas...
    Check out the Circuit Basics blog for articles and tutorials on the Raspberry Pi, Arduino and other DIY electronic projects! www.circuitbas...
    Follow us on:
    Facebook: / circuitbasic
    Twitter: / circuitbasics
    Instagram: / circuitbasics

КОМЕНТАРІ • 89

  • @elecnut8211
    @elecnut8211 7 років тому +2

    This is the best relay/arduino video on youtube !!!! Clear and concise. Thank you.

  • @tonyb2955
    @tonyb2955 8 років тому +2

    Excellent video, just what I needed to start my 'journey' into controlling bigger stuff. I am looking to build a greenhouse vent system, and this is perfect. Many thanks for posting

  • @EnergeticWaves
    @EnergeticWaves 7 років тому +1

    this stuff is so easy it isn't even funny!!! I love arduino.

  • @tajnotpm6281
    @tajnotpm6281 7 місяців тому

    1:00 The position of NC and NO have interchanged from what was shown for the relay at 0:33. At 1:00 NO is against the GND pin.but actually it is NC according to 0:33

  • @ukmwg
    @ukmwg 7 років тому

    Excellent demo and description, all very easily understood.

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

    And also I will use 12V instead of AC to operate the electronic pump

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

    great video! i just accomplished my first project. its a little wonky but ill call it a win either way. does anybody have an idea as to why my serial port monitor is showing a cycle of 100 degrees fluctuating by 10 degrees every second or so? i will continue to diagnose this issue and then i will work on another circuit basics project since this was such an excellent demo!

  • @EllieMappin
    @EllieMappin 8 років тому +3

    Sick vid and channel you just earned 1 sub

  • @spike4850
    @spike4850 7 років тому +1

    This video is very clear and well explained - so many of these types of videos are unclear and confusing! Well done! I'm trying to set up this same relay module with the Arduino MKR 1000, but i have no success getting the arduino to change the state of the relay. I have noticed however that when I unplug the MKR1000 from the breadboard, the relay and lamp connected turn off, I just can't use the code to change it. Do you have any advice?

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

    Good video, but is wording that goes the graphics starting at 0:41 backwards? The arrows appear correct, but the first image seems it should say "Normally Closed" instead of Normally Open. Compare 0:41 to 4:26 to see what I'm talking about.

    • @tajnotpm6281
      @tajnotpm6281 7 місяців тому

      The whole concept changes when NO and NC are interchanged. It makes this video really confusing.

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

    Im using another version of the code to control a water pump, when the moisture is a higher than "500" the relay will activate the pump. Here's my problem:
    My arduino Nano is sending a "go"-signal at 2,4v to the relay and a 9v battery is connected between the relay and the water pump just as yours, but the water pump wont start on NO, but it does when I connect it to NC. Is the signal between the arduino and the relay too weak?

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

    So how about using a PIR sensor or an RCWL- 0516 sensor with a relay to work an LED and musical movement driven by a motor?
    Motion detector would set the musical movements and LED off. Sadly my 5v timer relay that I have has a constant 4.70v at its TRIG pin out. I was hoping to place my PIN OUT of 3.3v from my sensor onto the relay TRIG pin.
    My 5v timer relay has a small black button and when its pressed it will activate the LED and musical movement for 10 seconds. I can adjust the timer with it onboard POT.
    Basically I want the motion sensors to activate the relay NOT by me pressing a button.
    By the way I wasn't using an UNO or NANO.
    Any ideas?

  • @michaelboyda438
    @michaelboyda438 7 років тому +5

    Why are you connecting the neutral wire from the light to the relay? I would think that is dangerous? If the relay is off the light is still powered and if given a ground...? I think you should always switch hot wire?

    • @2012isRonPaul
      @2012isRonPaul 7 років тому +1

      0:56 says that the only place u could get a Fatal Death Shock is the C terminal of the relay

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

      Doesn't matter which direction you put, both hot and neutral wires are dangerous by themselves. (except nominally ground wire).

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

      2012isRonPaul check out what he said at 1:20 even though the plug can be inserted in either direction!

  • @adityanayak4237
    @adityanayak4237 7 років тому +1

    how about connection to a motor?
    will we need a motor driver too?
    please make a video on this!!plz

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

    Can you controll 2 ultrasonic sensor by just using 1 relay module? Thankyou

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

    Sir how can i use this relay and Arduino uno for star delta starter, if i use this type of relay for star delta starter when the input signal from Arduino is low the relay will activate and vice versa, bt this is not correct for star delta starter, how can i fix this issue, please help me sir....

  • @grim-upnorth
    @grim-upnorth 4 роки тому

    Hi, I want to do something very similar. But instead of activating the relay based on the thermistor, I want to use a voltage sensor.
    When the voltage sensor value = 15v I want the relay to open the circuit.
    it's a basic battery discharge protection circuit

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

    Hi...can i use a mosfet to controll a 24v dc load attached to it?the mosfet pcb i bought have 3 pins to interact with arduino and another 4 pins where 2 is for input power supply(in this case 24v)and other 2 is for output...

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

    What if I use Motion Sensor. Is it have the same connection as the thermal sensor?

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

    Could you add a time in this sketch? Let’s say turn relay off or on within the temperature limits already preset for 10 minutes? After that the loop stops.

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

    Say...If you add another sensor along with the temperature sensor and 5V output. Your analog read will mess up the Temperature Equation. How you go about solving it?

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

    MY 5v relay module activate when the signal is LOW/0/False, It's reversed. Any idea?

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

    I would like to use a proximity sensor to tuns an arduino mini pro on through a relay. After doing some work, the arduino mini pro gets turned off. How could I achieve this? Any ideas?

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

    Hi I have a problem and I would like your help. I did everything you said and the lamp is working correctly. But when I put a circulator to operate with, it doesn't work. But the lamp is still working! Could you help me please!

  • @EcBaPr
    @EcBaPr 7 років тому

    could you make a video which has an IR proximity sensor that turns an XLR microphone on and off depending on distance from the sensor ?

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

    Cool video, thanks

  • @Linrox
    @Linrox 8 років тому

    I am looking at doing something similar to this but with Three single phase 240VAC Motors.
    I am looking to switch between the motors so only one has power at a time, and only the active motor will show stats on a TFT LCD and be controllable with various options. Can you show me how to do this?

  • @AndrewPena76
    @AndrewPena76 8 років тому

    Very helpful....thank you!

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

    Is it possible to do the opposite? (Sending a signal when the bulb is on to the Arduino)

  • @thabisoedwintjatjie5339
    @thabisoedwintjatjie5339 8 років тому

    Sir I'm woking on a project that uses solar power to charge laptops for
    students so I've decided to get an Arduino micro-controller + coin
    acceptor + a board of 8 relays, so I want to make sure that when a
    student insert a coin to the coin acceptor, the coin acceptor will send a
    pulse to the Arduino and the Arduino will active the relay for a
    certain period in order to allow the student to charge his/her laptop
    for that period. So how can I link/connect the coin acceptor to the
    Arduino such that the relay activates when someone insert a coin to the
    coin acceptor? Please help me, if possible give me the codes for this
    operation

  • @jasoncollins4088
    @jasoncollins4088 7 років тому

    I need this to work to activate a 120v motor for X seconds, but only after the sensor value reaches a point or lower for 10 minutes.
    I am new to this. What would that code look like?

  • @MrRobot-vc2gk
    @MrRobot-vc2gk 3 роки тому

    How will I know what resistor I should use for my OWN relay actuator sensor setup ???? I know 1 led is ok with 250ohm (v=ir) but I mean should I check every amper volt for every element in the circuit and should I connect a resistor for every setup I make ???

    • @MrRobot-vc2gk
      @MrRobot-vc2gk 3 роки тому

      or is it okay not to use resistance? is it only ok when the voltages and ampere values are the same

  • @kevinbahe7745
    @kevinbahe7745 8 років тому

    I have a sainsmart 4 channel relay module that looks like i can do almost what your video shows. (same way to wire ect.) I want to add in the mix a potentiotmeter in. How can that be wired?

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

    can i use relay on digital pin 23 on arduino atmega bcz i dont have the space to connect it on pwm pins. i want to control a 12v dc pump..????????

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

    Instead of AC high voltage to power light bulb, is it possible to test this with 9v battery to small LED light?
    I know it says 30 VDC so will 9v battery damage the module or even worse arduino board?

  • @dionwilliams6841
    @dionwilliams6841 8 років тому +1

    can I use the digital outputs on the arduino to activate the relays? probably a dumb question but I just wanted confirmation. I'm using momentary switches to activate simple LEDs and I'd like them to activate 120 volt ac lights instead.

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

    Thanks for sharing. How about two ways control? I wish to control some heating system valve. We have a cylinder for the heating system and a hot water cylinder. I use ESBE ARA45 motors which have live, neutral and com wires. I need to control this valve in between the two cylinders. When the water temperature reached a certain level in the heating system cylinder, the motor should switch to the hot water cylinder to make hot water, So pretty much 2 sensors and dual motor control. If anybody can help me out on this would be brill. Thanks. I have two of this valve in my house a third which is the mixing valve.

  • @learnwithhalim
    @learnwithhalim 8 років тому

    Sir, you did a great job. i need your help. i have collect 5v & 12v both relay to control a Aquarium AC 220-240v Motor. i want to use it for my irrigation project. here i'm using a moisture sensor. my plan is when " moisture

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

    Forgive me if I am wrong but the data sheet for the Songle SRD-05VDC-SL-C appears to indicate that the current drawn by the 5V SRD relay is 71.4mA. (www.songlerelay.com/Public/Uploads/20161104/581c81ac16e36.pdf)
    According to the Arduino site the recommended DC Current per I/O Pin is only 20mA. (store.arduino.cc/usa/arduino-uno-rev3)
    Since you have to put the pin to the relay in a High state to activate the relay (one way or another) you are providing a constant 5V @ 71.4mA from the Arduino plus whatever the Thermistor and resistor are drawing. Could this potentially damage the Arduino by using a relay that draws more current than recommended?

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

    Could you please upload arduino to send notification when we forgot to close the gate. Thanks

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

    hi sir,
    its very nice.
    can i control multiple sensors at the same time.
    delay() command will interrupt the other sensor activation please give me some ideas about multiple sensors

  • @blueckaym
    @blueckaym 7 років тому

    Nice video!
    Can you point me to a slightly higher Voltage Relay? I mean to control flow between main-power and battery (with 2 similar relays). I'll have about 20~25V on the main-power (already converted to DC by a power supply), and I want to use the main-power in the Norm.Open position AND the signal simultaneously, so that while I have main power to connect the Norm.Open and disconnect the battery.
    Also do you know what's the switching time of these relay? And can they be used in a Uninterruptible Power Supply?
    Or should I put a big capacitor after the relay to cover for the current drop and fluctuations during switching?

  • @earlhaiger
    @earlhaiger 7 років тому +1

    Hi, thanks for making this video!
    what is the purpose of the resistor in the breadboard?

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

      I've been trying to figure that out as well. I think I finally got it: to measure the resistance with V=IR directly through the thermistor, you would have to know how to ask the arduino what the current draw is.
      Since I'm assuming there's no easy way to do that, he used a voltage divider circuit so you can solve for the thermistor resistance using the known 5V, the known resistor resistance, and then asking the arduino to measure the other voltage.
      Rt = R0 * (( Vs / Vo ) - 1) or Rt= 100K ohm * ((5 V / V_measured) - 1)

  • @namaldissanayake7890
    @namaldissanayake7890 8 років тому +1

    Grate Work Bro! Keep it..

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

    hi, thanks for the video. If I want to control wall lamp from arduino, is it ok just connect lamp's vcc and gnd to relay and connect relay to arduino or should I put something to remove effect of triggering relay (high voltage, electrostatic feedback etc) ?

  • @kaspervestergaard5857
    @kaspervestergaard5857 7 років тому

    how is this possible useing a photocell in stead of temp sensor

  • @user-lm1uo1yo7h
    @user-lm1uo1yo7h 5 років тому

    Can I use the same code but using a DS18B20 for measuring the temperature???

  • @ciankircher5190
    @ciankircher5190 7 років тому

    hello, I was wondering if the arduino mkr relay sheild would be suitable for 240v AC as it's rated for 125v

  • @realak13
    @realak13 8 років тому

    can i use a relay to control Water Dispenser

  • @zuruizu3029
    @zuruizu3029 8 років тому +1

    Nice work. I have a question. Can I do it the other way around? Meaning that the relay becomes the input for the arduino. The situation is like this- when the bulb is turned off then the relay do the switching to send an input to the arduino. I'm not sure if i explain this correctly but I hope you get the idea of what I'm saying.

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

      relay is made to use a small voltage to open higher voltages. If you want to send informations about a light bulb to arduino, the light sensor would do the job. The relay works only in one way( smaller voltages opens higher voltages)

  • @KamrulHasan-my5jy
    @KamrulHasan-my5jy 7 років тому

    looks like you have designed the breadboard view with fritzing , can you please tell me where did you get that bulb part or have you made it by yourself? I couldn't find one,can you please provide me the part library for bulb.TIA (sorry for bad english)

  • @2012isRonPaul
    @2012isRonPaul 7 років тому +3

    so this is quite useful to raise chickens in a box from an egg? :e

  • @2112user
    @2112user 7 років тому

    I've got a similar circuit and sketch and was wondering it you might know of a way to limit the relay activity. I'm having issues with the temp (water in my case) that is so close to the trigger temp that the relay is triggered on/off almost like a strobe light. I know I can increase the sampling time/ loop delay, but wondered if there is a way of having the temp in real time, but limit the relay to stay in the state (on or off) for a set time before triggering again?

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

      just define the lowest temperature and the highest temperature that u want. with that u will get some of the space between the temperatures and relay will open in the lowest temperature, and close at highest temperature. in the middle it will just stay closed or open, depends if the temp. is rising or lowering.

  • @blybaly
    @blybaly 7 років тому

    Can I power high current / volt devices(like agricultural water pumps) with just a simple relay circuit that you are showing?

    • @jasoncollins4088
      @jasoncollins4088 7 років тому +1

      blybaly yes, as long as the relay is rated for amps at or above the draw of the pump.

  • @samantharobinson2700
    @samantharobinson2700 7 років тому

    If I am trying to control three different high-voltage devices with one Arduino, do I need a 3-channel 5V relay? Each device needs 100V of external power.

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

      u need 3 relays. otherwise when u connect relay on the output to all 3 of the devices that u have, all of them will turn on in the same time.

  • @2887aliahmed
    @2887aliahmed 8 років тому

    what if I want to use two different power sources to power the load (at some time I'll use the power from a solar panel and in other time from a normal home 220V for example)
    can I use both the normally closed and normally open for the same load in this case?

    • @Circuitbasics
      @Circuitbasics  8 років тому

      +Ali Ahmed I don't see why that wouldn't work. If you put the load on the common terminal and put one power source on the no terminal and the other on the nc terminal. The signal pin would be the switch (i.e. A photoresistor) for the two power sources

    • @Circuitbasics
      @Circuitbasics  8 років тому +1

      +Circuit Basics the only issue would be making sure the solar cell can handle the 220v draw from the neutral line

  • @DerUserYT
    @DerUserYT 8 років тому +2

    bad idea to connect the relay without a proper flyback diode

    • @Circuitbasics
      @Circuitbasics  8 років тому +18

      I didn't mention it in the video but these relay modules already have a diode on the PCB

  • @Mitgardxxl
    @Mitgardxxl 7 років тому

    Great !!

  • @lmaryasin
    @lmaryasin 7 років тому

    hello , please , where i can find the code , that you are using ? thanks ahead

  • @blackdedo93
    @blackdedo93 8 років тому

    why did u use the resistor ? and how do u know what resistor to use.. Please explain deeply.
    Thanks

  • @TheGamercracker
    @TheGamercracker 7 років тому

    I cant find a relay that can switch 24V devices on/of.

    • @damianverhoeks3544
      @damianverhoeks3544 7 років тому

      you can use a 220-240 volt relay but not higher than 240volts

  • @gregg5574
    @gregg5574 7 років тому

    Where can I get the code that you used

  • @srul76
    @srul76 8 років тому

    great video. do you feel safe to use the china low auality relay with high voltage?

    • @leftysomething
      @leftysomething 8 років тому

      +srul76 ? everything is china... even made iin america means made in china

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

    Hi...I have a problem... I think if arduino can helps me... Let's see... I have an axle that turns at 600rpm and it has a off-centre on it, and i want to find with strob light the degrees of the off-center... what do you think? Can you help? Thanks in advance...

  • @YoDay
    @YoDay 7 років тому

    Is there a chance of short circuit?

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

      There will no chance of short circuit as long as you connect the output to something else (like a light bulb). If there is a short inside the relay for some reason, it will just simply turn the output ( light bulb) on forever, until you manually unplug it.

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

      The only chance of a short is when you connect the relay to nothing (not even a light bulb). If such cases occur (two wires connect to nothing), then a short circuit will occur.

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

      Okay Fine, Thanks a lot for your reply!

  • @siddhantsinha9276
    @siddhantsinha9276 7 років тому

    Can i turn on/off 12V motor?

    • @Zach-uc1qv
      @Zach-uc1qv 7 років тому

      PC B yes, just use the relay as a switch in a 12v circuit.

    • @siddhantsinha9276
      @siddhantsinha9276 7 років тому

      Ok, thanks :)

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

    so unclear, whych ports goes where and why ? wich resistors to use and some capacitors and why? if i want to add delay timer it takes 3 days to sit in forums and youtube to find out modules are incomatible GRRRR