Using Relays and Relay Boards with the Raspberry Pi

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

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

  • @EccentricBillionaire
    @EccentricBillionaire 10 лет назад +14

    Holy CRAP!! This is an AMAZING tutorial. I just spent the past 6 hours learning everything you explained in 10 minutes. Wish I had found this tutorial first, but I guess the past 6 hours weren't completely lost since I did end up learning something. But man....I mean really, this is just incredibly well done. Thanks! you rock!

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

    Thank you, your videos are fantastic. You´re really a gifted person to teach electronics.

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

    Very well explained. Clear, concise and straightforward without losing the detail of the topic. To explain things like this takes real skill, great work.

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

    I know you haven't uploaded in quite a few years, but your tutorials really helped me a lot when I was getting started with the Raspberry Pi controlling electronics

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

    Thanks so much for the video. I bought one from amazon and was scratching my head when it didn't work like I expected.

  • @wm0davis
    @wm0davis 10 лет назад +7

    First of your videos I've watched. Excellent and accurate coverage. Wish more YT videos were as well organized and presented.

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

    Best video on explaining the mechanism of a relay for projects working with Raspberry PI I have ever seen :)

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

    9:55 - THANK YOU. This is in fact the most important part of your video. Because how can any RPi or other project enrich your life, if it … well, _ends_ it? Safety first. Always.

  • @Your_Friend_Corey
    @Your_Friend_Corey 11 лет назад

    Just got my 8 relay board the other day. This video will help a bunch. Thanks.

  • @milsystems
    @milsystems 11 лет назад

    Thank you for this super video! This helped me to get my 8-Relais Optocoppler running and I got the knowledge from your video how it is working and has to be connected. My 8 Kanal Channel 5V Relais Relay Converter Modul worked fine with VCC and JDVCC connected via the jumper! I'm looking forward for new videos as they are very interesting and good produced! Thanks for your time you spend here!

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

    I've managed to get the board working this way:
    - using the jumper for JD-VCC and VCC
    - connecting the VCC pin of the input pin group to one of the 5V pin of GPIO
    - connecting the GND pin of the input pin group to one of the GND pin of GPIO
    - connecting the IN1 and IN2 pins to GPIO pins set as OUTPUT and initially set as HIGH

  • @hkrware
    @hkrware 10 лет назад +9

    One of the best explained videos i have ever seen! I would shake your hand if I could! There's always something to learn from such people!

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

    Thank you for this informative video. Helped me get up and running in no time.

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

    effin awesome.. covered alot of material but i appreciate the calculations and circuit explanations such as using beta value to calculate the necessary current limiting resistance

  • @updowndown
    @updowndown  11 лет назад +1

    You certainly can do that, and in both cases you will need 1 GPIO pin. Either a GPIO pin on Vcc, with the control pin connected to ground, or Vcc attached to 3.3V and a GPIO pin connect to the control pin (like in the video). The only time an issue would arise would be when using more than one relay on the board. Because the two relay modules share Vcc, a GPIO pin on Vcc would affect both modules. Of course, if you're not using the board, your suggestion would work perfectly fine.

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

    Very good explanation!! Now I know how it works. Great man.

  • @updowndown
    @updowndown  11 лет назад +1

    Yeah, a single transistor and a relay will do the job just fine. The optocoupler is there only for protection, and I made a point of discussing it as a large number of relay boards use it. Unless you're going to use a separate power supply to connect across the relay coil, you might as well not use the optocoupler as your bypassing the electrical isolation by connecting anything on the right side of the optocoupler to your Raspberry Pi.

  • @axa.axa.
    @axa.axa. 5 лет назад

    Awesome explanation of what going on here, saved me a lot of reasearch effort. I wouldn't normally sub to such a channel, electronics is more like an 'video on demand' sort of thing for me, but your videos are top shelf.

  • @TradieTrev
    @TradieTrev 10 лет назад +4

    Great video Gavo! Those prebuilt ones are handy as!

  • @updowndown
    @updowndown  11 лет назад +2

    You might be able to control the relay coil with 3.3 V (a gpio pin). On my board, one relay worked this way, and the other didn't. So it's definitely something you can test out with your own relay board, as relay modules are not all created equal.
    A transistor is also an excellent solution, and it's what I tend to connect my GPIO pins to. The only reason I didn't suggest them with the board is because I wanted to avoid using additional components.

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

    Amazing. Some of the best tutorials out there.

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

    Outstanding video. Thank you!

  • @Mindaugiuxss
    @Mindaugiuxss 9 лет назад

    Excellent video! Really helpful. And Subscribed!

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

    An old video for sure, but rather than a current limiting resistor on the opto-isolator, one could simply use a current regulator. These are available with a fixed mA limit (with 2-pins in an SMT package), and can have a VMax of 220Volts (like a CL220K4: www.digikey.com/product-detail/en/microchip-technology/CL220K4-G/CL220K4-GCT-ND/4918704). This way it basically doesn't matter what voltage you put on the opto-LED circuit or the relay control side of the isolator (within common voltage ranges of course). Using a current regulator means your current is capped at the design current and you never have to go back in an recalculate/rework a constructed circuit once built.
    To drive the relay coil a MOSFET and a current regulator would again be more flexible. 60mA can be current regulated with monolithic current regulator parts (two 25mA and a 10mA in parallel gives you 60mA, so does three 20mA regulators in parallel). Using those regulators would then ensure that the coil only ever see the POWER it was designed for, and the relay would work with a supply of 5VDC up to the power rating of the current regulator. To protect the MOSFET, a zener would need to clamp the gate to under its maximum voltage, and a current regulator would need to limit both the current conducted by the opto-trans-out, and the zener. Since a MOSFET gate only needs to be charged with a voltage/current and not driven by a continuous current, this value can be very low (sub-milliamps) - which reduces the total circuit power draw. Remember, ten 6mA LEDs draws as much power as one 60mA relay coil.

  • @DiegoAlvarez-to9wj
    @DiegoAlvarez-to9wj 8 лет назад

    Wonderful explanation !! I loved as graphics components and the electrical circuit . thank!!

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

    Great video helped me a lot

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

    Thank you So much sir it really solved a big Problem of Mine
    Thanks alot

  • @Uberlaser
    @Uberlaser 10 лет назад

    Really excellent descriptive video. Thank you

  • @AmartyaDattaGupta
    @AmartyaDattaGupta 10 лет назад

    Excellent video! Really helpful.

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

    Really good tutorial.

  • @AalokSathe
    @AalokSathe 10 лет назад +3

    thanks a lot. very useful

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

    Best video found! Thanks

  • @bastnt
    @bastnt 9 лет назад

    Thanks for the detailed, well explained, informations !

  • @glassonionman
    @glassonionman 10 лет назад

    Excellent video!

  • @jmanatee
    @jmanatee 9 лет назад

    Excellent explanation,... Thank you from a newbie.

  • @ilducedimas
    @ilducedimas 10 лет назад

    Simply amazing, thanks for your hard work

  • @ACPCalin
    @ACPCalin 11 лет назад

    Thank you! By the way, you make really good and interesting videos on your channel!

  • @WolfieWeb88
    @WolfieWeb88 10 лет назад

    Great video, I learned a lot.

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

    Great tutorial, thank you!

  • @Jan.-
    @Jan.- 6 лет назад

    Thanks,
    (8:34) Had problems with mine running at the 3.3v from the raspberry and switching 230VAC 2A. Changing the R1 (1kΩ) Resistor to a 510Ω one worked for me perfect!

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

      I switched it to 680 ohms. Some relays worked, some didn't. Might try 510.

  • @xtrapix
    @xtrapix 10 лет назад

    Great video! I believe I'm using the same relay board as you, and only one of the relays would turn of if I connected Vcc to 3.3v. I'd measured the voltage across the coil and it was 2.7, so I guess that wasn't quite enough. All works well if I use Vcc = 5v. I assume that slight differences in the transistor or relays would affect this. Now the coil voltage is about 4.6, which works great.

  • @chengbinhou5432
    @chengbinhou5432 10 лет назад

    Thanks! It helps me a lot!

  • @system247
    @system247 10 лет назад

    Really useful video! Subscribed!

  • @borisrunakov1662
    @borisrunakov1662 9 лет назад

    Great Video!! Thank you !

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

    thanx for the superb tutorial..

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

    Thank you for your information. I believed that my module relay can't use more.

  • @Ken-S
    @Ken-S 9 лет назад

    Great video!

  • @nigamjain3624
    @nigamjain3624 9 лет назад

    Helpful! Thanks a lot!

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

    hey!! awesome project

  • @jleslie48
    @jleslie48 10 лет назад

    finally!!! an explanation on how the 3.3 volts and the vcc works! thank you. curious, can I use another gpio pin as VCC?

  • @DotcomL
    @DotcomL 10 лет назад

    Amazing explanation! You have a new sub :)

  • @n1ugl
    @n1ugl 9 лет назад

    This helped me a lot using the pre-built board, but for some reason did not quite work. I found that I had to send +5 to VCC and VCC-DJ, and that I did not need a ground. With +3.3 at VCC, the relay never got more than 3V across the magnet

    • @SebastianIbieta
      @SebastianIbieta 9 лет назад +1

      Matt Brennan Hi, for me it didn´t work either, i have the model b rev2 rpbi and i guess the 3.3v gpio data is not giving much current. I see the led blink at the relay control and the relay is not giving output voltages when it should, also i´m not hearing the relay sound switching. Did you use the jumper to provide 5v to JD-Vcc and Vcc, and what do you mean by not needing ground. thanks

  •  10 лет назад

    good advice can you make another video showing best safe way to run ac through the relay as best you can as i dont mind danger but want things to stay working, maybe by using different relays and an inline fuse etc for example many thanks

    •  9 лет назад

      tried that 3.5 volts not enough to activate it!

  • @RadioTrefoil
    @RadioTrefoil 9 лет назад +1

    If I wanted to make this into an "active high" relay, could I feed the 3.3V GPIO output to Vcc, 5V to JD-Vcc, and then tie GND to the GPIO input of the board? That way the optocoupler has 3.3V across it (and the resistor) when GPIO is HIGH and 0V when GPIO is LOW?

  • @Sam-tg4ii
    @Sam-tg4ii Год назад

    For a beginner working with 12v devices, do you recommend transistors or relays, generally speaking? Thanks

  • @tichris08
    @tichris08 8 лет назад +2

    Wait I'm a bit confused. In the first circuit, the current goes from 5V -> GND and that makes sense to me.
    In the version with the board however, it goes from 3.3VDC -> GPIO pin. It seems to me like the current comes out from VCC and it comes out of the GPIO at the same time that it would be a problem. Does that not reverse the way that things work?

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

      The current comes out of the difference of Vcc and GPIO. In the module version when the GPIO is LOW, it is actually sinking current

  • @hier0phant336
    @hier0phant336 11 лет назад

    Thanks!

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

    Very well explained. Sadly so stones there is a module designer who thought "JD-VCC?, Jumper?, Wait let's just hardwire that" arduinodiy.wordpress.com/2018/09/04/the-16-relay-module-and-the-raspberry-pi-not-an-ideal-marriage/
    Just a remark, you suggest that one option is to desolxer the resistor and replace it with a seeker one. I am not sure that is the right choice: the voltage drop will remain the same, but now there will be a higher current owing. If any you should replace it with a higher value. In that case desoldering isn't necessary, just add one at the input lines. Having said that, I think with the 1k, the optocoupler and LED in series the 1.7 volt drop the current flowing will be practically zero

  • @redsub93
    @redsub93 10 лет назад

    Gaven, im doing a project for a course in my college and i want to create a wireless door lock, what i had in mind is a relay, electromagnetic door lock and the raspberry pi connect all those together and i could build it, so am i missing anything or should i be using something much simpler design ?

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

    The last part of the video. Telling to connect
    5V Rpi to JD-VCC
    Pin6 Rpi to GND
    pin7 Rpi to IN1
    pin1 Rpi to VCC
    Does this circuit will not damage anything? especially the raspberry?
    I'm confused because you introduced to us the using of Resistors,Diode,transistor and Optocoupler. So is it fine not to use those? just the direct connection from Rpi to Relay then?
    Need ASAP reply . This is for our thesis project

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

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

  • @code_cutter
    @code_cutter 11 лет назад

    Wouldn't it be simpler and more economical to find an optocoupler that requires

  • @jviezel
    @jviezel 10 лет назад

    I could only get this to work by connecting Vcc to the 5v pin on the RPi and connecting Vcc to JD-Vcc using the jumper. When I connected Vcc to 3.3v rail, the red LED would light but the switch would not activate (there was no audible "click")

  • @ACPCalin
    @ACPCalin 11 лет назад

    In the video you used a GPIO pin of the Raspberry Pi to control an optocoupler which in turn controlled a transistor which in turn powered the relay. Was the optocoupler really necessary? Couldn't you have just used a transistor and a relay? I didn't need an optocoupler to control a small relay with my arduino, just a transistor. Or is the optocoupler there because you don't want the GPIO pin to be destroyed by some kind of voltage spike?

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

    What about if i use a small sensor with 5v. this relay is too big for small microcontrollers

  • @osiris1309
    @osiris1309 11 лет назад

    Why is the optocoupler connected to the 5v power supply?? Couldn't it be connected to the GPIO out directly? The 3.3v generated by the GPIO pin can power the the optocoupler.

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

    Why such complexity? What is the risk of Pi -> relay -> device? Sorry if I missed it, but I've seen other videos skip the optocoupler, diode etc. TIA

  • @XCyrusStudios
    @XCyrusStudios 9 лет назад +1

    Howdy! What's the function of the JD-VCC jumper?

  • @Crazy8xxx
    @Crazy8xxx 9 лет назад

    Great video and tutorial. Q: can the relay output 24v as your relay was outputting 9v for the LED.?

    • @revanthkumar7059
      @revanthkumar7059 9 лет назад

      if u give 24v supply to the COM pin it will be transferred to the NO pin when the Switch is closed.

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

    We have two plug-in relay boards for Raspberry Pi. What would it take for you to review them?
    Mihai Beffa
    Sequent Microsystems

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

    mains are some scary things to mess with 12 volt dc systems are as well but I been messing around with it and havent burned zaped or blew anything up with whats your thoughts on a 12 volt set up at around 220 ah drawing .750 ma @ 5 volts 24/7? its just a common led think its a bad ideah for light

  • @skar603
    @skar603 9 лет назад

    i am fixing to purchase a rasberry pi, relay board, and touch screen. i want to make a 12v switch box with a touch screen. have any of yall already written a program for the interface? im in the process of trying to figure out python and figured if someone already wrote a program, it would save me a LOT of time

  • @sn4k3PT
    @sn4k3PT 10 лет назад

    Can we use a darlington array (ULN2003A) to simplify the circuit?

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

    Why can't I control the power of a 230v AC with my raspberry pi 5v ?
    The power just stays on even tho the relay is off, or on..

  • @84ggo84
    @84ggo84 8 лет назад

    what happens to the raspberry if the optocoupler relay border is broken ?

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

    Hi. Could you explain more about the extra power requirements? Just to clarify, you need 2 power supplies, a USB powering the pi which sends some of the required power to the relay for the LED, and a second power supply connected directly to the relays outward face and the ground for the LED, right?

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

      Also, is the point of using the relay to isolate the 9v power source so it doesn't interfere with the 5v arduino board and blow it up while maintaining control of the external object with the board?

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

      A voltage source represents a "potential difference" in electric terms. So, the GND rail for each source is NOT an absolute 0 value, and also the independent GNDs will not be on the same level as each other. Instead of thinking of the + and - terminals as 5V and 0V, you can also think of them as +2.5V and -2.5V (i.e. the potential difference is still a 5V supply), or even +4V and -1V (it is still a 5V supply). There is no such thing as absolute 0V GND (the GND on different supplies will be different and hence represent a voltage potential difference even between independent GNDs). The power from the positive terminal from one voltage supply must return to the negative terminal of it's own supply, so this is why you need circuit isolation. If instead the entire circuit could be solely powered from the micro-controllers own power rails then there would be less need for isolation since you could instead limit current through the use of resistors, but in this case if you are controlling actuators and motors then the arduino cannot possibly supply the needed current (or voltage) required for those actuators to power the motors, and some components in a circuit just need more than 5V to work. You need voltage-source isolation in this situation.

  • @PaYtrIxHD
    @PaYtrIxHD 8 лет назад +4

    Oh man, you fucking helped me :D I love you :)
    I didn't know that the GPIOs provide 3.3V and i also didn't know that the inputs need 5V to get triggered^^ So i have a few questions and i hope you could answer me some of them ;)
    1. Why is a octocoupler used to trigger the transistor? I could just power the Transistor with a GPIO pin directly?
    2. What are the cons of providing the Optocoupler with 3.3V if you just have GPIO with 3.3V outputs?

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

      PaYtrIxHD The optocoupler acts like a switch, such that it is used to isolate the circuit so that it will prevent any damage to the Raspberry Pi when working with higher current and voltages. Therefore, it only activates at certain states. Since the Raspberry Pi has a low current output, it would be wise to use an optocoupler to keep things separated so as to not fry the Pi when messing with higher voltages/currents. Check out his optocoupler video where he goes more in-depth. Good stuff.

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

    When you say high current, what do you mean? I want to use one of these to turn a mains light on and off.

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

    i use module relay when no load connected to the relay every thing well when it connected to 220ac it take a time and then the lcd display strange symbols the power of the relay and the lcd from arduino

  • @chemjblab
    @chemjblab 9 лет назад

    Does anybody know if is the second transistor on the right side of optocoupler needed ?

  • @borisrunakov1662
    @borisrunakov1662 9 лет назад

    Hello ! Is there a link for the relay shield you use ?
    Thank's in advance

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

    how did you calculate 5.1k ohms for base lead?

  • @ACPCalin
    @ACPCalin 11 лет назад

    Couldn't you have just powered the relay coil from the GPIO pin of the raspberry pi or connect a gpio pin to a transistor which controls the relay coil?

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

    can i use this relay with the raspberry pi to power a 19" lcd monitor?

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

    @8:35 could you add a resistor in parallel

  • @DiegoAlvarez-to9wj
    @DiegoAlvarez-to9wj 8 лет назад

    Gaven, How i do to control several relay ? regards.

  • @gauravharchwani
    @gauravharchwani 9 лет назад +2

    How do i deal with voltage spikes from the relay that are causing my micro controller to reset ?

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

      The answer is in the video. You will need a diode in parallel to the relay.

  • @cryptodude_btc
    @cryptodude_btc 9 лет назад

    9:56 ... lol ... wise to put in a disclaimer :)

  • @David-dq2hu
    @David-dq2hu 9 лет назад

    could you please show so code in python for the prebuilt relays boards

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

    can i request for a wiring diagram between pi 2 with relay 5 pin but not relay board? thanks

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

    I am trying to use a Keyes 4 ch solid state relay It's a red circuit board with blue terminal. there are tons for sale on ebay. I can get the leds on the inputs tp go on and off with the Raspberrypi, but the relays themselves do not change state. I have connect them up using a 5 volts, a 22o ohm resistor and an led. The led will sometimes light up as it should, but then it stays on. Anyone know what I am doing wrong? Any help is appreciated.

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

      Hey! Did U Solve This Troubleshooting Issue?? Just asking..I might be a help. ~*;p

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

    hi could anyone help i would like to control a 4 channel relay with raspberry pi to turn on -off in sequence sometimes all together sometimes two at a time -one at a time and be able to alter time between them
    thanks

  • @zynthos9
    @zynthos9 9 лет назад +3

    1:30
    How do you know that the required current is about 60ma?
    I looked at the datasheet here:
    www.ghielectronics.com/downloads/man/20084141716341001RelayX1.pdf
    It seemed to be different than what you mentioned.

  • @user-xz9st8hm1n
    @user-xz9st8hm1n 6 лет назад

    god bless

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

    Where do you buy those relayboards?

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

    ☠☠☠ Just remember folks the relays on that panel are NOT safe to use to switch MAINS VOLTAGES directly - the air-gap is not good enough (needs to be around at least 7 or 8 mm for 220-250V type voltages) i.e. the space between the bits of metal that would be connected to the Mains are not far enough from the bits of metal that are connected to the RPi and which you might touch... ☠☠☠

  • @Paulzmusic
    @Paulzmusic 9 лет назад

    New videos?

  • @milsystems
    @milsystems 11 лет назад

    I don't agree with it. It's the only video, i found on youtube, where the function of an optokoppler-relais is explained! I think it's worth knowing, what you connect here instead of frying your pi!

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

    damnit. i just wanted to power a light controlled by the raspberry pi. damnit...

  • @mihirpatil8843
    @mihirpatil8843 9 лет назад

    Do a picamera vid plz I'm a noob