How to make 5V relay work on raspberry pi (hack)

Sdílet
Vložit
  • čas přidán 11. 09. 2024

Komentáře • 88

  • @maxr382
    @maxr382 Před 5 lety +2

    Thanks for doing this video. Some posers may not notice that the transistor in the schematic is the one that comes in the board. You are just hacking one component to make it work. BUT - I have just finished experimenting with the values, and the best working value for me is 20k ohms between center and Vin. You mentioned being able use a pot between 10k and 100k. I would recommend >30k on the pot.

  • @mujahidalfattaah5957
    @mujahidalfattaah5957 Před 4 lety +1

    Buddy, you are my hero, I've not sleeping for two days caused by this problem, and u save me with this video, thank you my friend, now I can sleep, peacefully

  • @alvinmast8551
    @alvinmast8551 Před 3 lety +5

    I think simply putting a diode (or series of diodes) in series with the signal wire should work as well. The voltage drop across the diode will allow the voltage on the transistor to go all the way HIGH to 5 VCC where it would otherwise be blocked at 3.3 V which is the HIGH state of the signal pin on PI. 3.3 volts is still enough lower than 5 to keep the relay turned on. Therefore the minimum voltage drop that you will need to have across the diode (or diodes) is (5V minus 3.3V) 1.7 volts. Three regular diodes should have approximately 1.8V which should work. Connect the cathode (the end with the stripe) to the PI and other end to the relay module signal pin. (If you want to try something different, you could try using an LED with ~1.7V drop.)
    PLEASE NOTE: I didn't try any of this yet. This is just my speculation of what should work.

    • @miko192837
      @miko192837 Před rokem

      This idea works perfectly simple fast and to the point

  • @EricJorgensen
    @EricJorgensen Před 4 lety +12

    It's way easier to use a random LED (and maybe a current limiting resistor) as a current sink between the "in" pin and the gpio pin, so that when the gpio is pulled low the relay is triggered (and the LED maybe lights depending on the CLR)

    • @SirDrakeful
      @SirDrakeful Před 3 lety +2

      my god, this has worked, thank you

    • @OlivierVanHeulen
      @OlivierVanHeulen Před 3 lety +1

      this is the easiest solution, thanks so much!

    • @omg.itswendelin9374
      @omg.itswendelin9374 Před 3 měsíci

      Thank you

    • @dedesite86
      @dedesite86 Před 2 měsíci

      Sorry, but I don't understand what you mean, can you be more specific ?

    • @toastedbagel9095
      @toastedbagel9095 Před 19 dny

      ​@@dedesite86 gpio pin > cathode > led anode > relay signal pin

  • @bradserls7875
    @bradserls7875 Před 3 lety +1

    Thank you so much for this tip. I couldn't for the life of me work out why this wasn't working!

  • @TheOneWhoHasWallnuts
    @TheOneWhoHasWallnuts Před 5 lety +8

    genuine TONGLING quality :P

  • @vks002
    @vks002 Před 4 lety +1

    Hey Buddy , you saved my day, I have been looking for the simplest way to make these 5V relays work with 3.3V and didn't want to use a lot of components. This is by far the best way! thanks again!!

    • @ashritpawar2001
      @ashritpawar2001 Před 2 lety

      did you try this ??? does it work? please let me know as soon as possible. I'm doing a project using this technique, please help

    • @vks002
      @vks002 Před 2 lety

      @@ashritpawar2001 Well I did and it worked but getting the sweet spot of the pot is a bit tricky. You have to adjust it for turning ON properly and then it doesn't turn OFF. So you have to adjust again, then turn ON becomes an issue so you adjust many times to arrive at a place where both ON and OFF work fine.

    • @ashritpawar2001
      @ashritpawar2001 Před 2 lety

      @@vks002 thank you sir. what if we cut off the o/p by GPIO pin after some time, does it still be activated ???

    • @vks002
      @vks002 Před 2 lety

      @@ashritpawar2001 Not sure if I get your question clearly. The state of the relay should follow the GPIO input. So assuming you have an active LOW relay module, a LOW on GPIO will turn the relay ON and a HIGH on GPIO will turn it OFF.

  • @IIIXJannikXIIIDE
    @IIIXJannikXIIIDE Před 2 lety +1

    Didnt work for me. However I adjust the trimmer, it never turns off again.
    However, WITHOUT the mod, using 3.3V from the Pi, it works! wtf?

  • @bjirlar
    @bjirlar Před 4 lety +4

    Thx... Your video save my project 🙏

  • @AsDurTube
    @AsDurTube Před 4 lety +7

    I use the same relay board with no MOD. When I connect VCC to 5V on PI (as it should be) it only turns on, not off. When I connect VCC to 3,3V on PI it turns ON/OFF changing LOW or HIGH on the IN connected to PI - I would say: works as expected however VCC to 3.3V instead of 5V. As I am not an expert I have no idea why 5V does not work while 3,3V works and what can happen if I continue use this relay with VCC plugged to 3,3V?

    • @alvinmast8551
      @alvinmast8551 Před 3 lety +5

      The reason 3.3V works and 5 volts doesn't. The relay module is looking at the voltage between "VCC" and "IN", when you connect a pin to "IN" that has a high state of 3.3 volts the voltage is still 1.7 volts lower than VCC. Apparently 1.7 volts difference is enough to turn the relay on. To let the relay turn off you will need to allow the voltage on "IN" go all the way up to voltage that is on VCC.
      About the worst thing that could happen with to lower voltage is: reliability problems. That is: the relay might not consistently turn on when it's supposed to.

    • @selenaaktar5744
      @selenaaktar5744 Před rokem

      Thanks you a lot I got my relay working on nodemcu❤

    • @utkuduman7231
      @utkuduman7231 Před rokem

      @@alvinmast8551 so is it possible to run with 5v or not ? do i need 5v or 3.3v ?

  • @elektron2kim666
    @elektron2kim666 Před 5 měsíci

    It's called level shifting as the Pico/RPI is built for 3.3-3.6 volts signal lines. It's a trouble source and you need to be sure it doesn't go over the specs. Always think it through, back and forth before you blow something out by "let's try it this way" and it's too late after a bit of smoke or dead devices. With more signal lines use a level shifter module. This "hack" is a normal procedure, but might not work always.

  • @user473
    @user473 Před 4 lety +5

    If anyone wants to use resistors instead: the values that worked for me are 33k in place of the default 1k resistor and 56k to VCC (fits nicely between the legs of the transistor if you find an SMD one).

    • @azfilmmaking6734
      @azfilmmaking6734 Před 2 lety

      Can I just add a 2k resistor between the legs of the transistor? Seems like with 1k it gives the same 3.3v almost as 33k plus 56?

  • @zabagar
    @zabagar Před 3 lety

    I replaced a dead relay with this model and couldn’t get it to work with my Pi. Now I know why. I could do your mod but it’ll be easier to purchase the same model relay as the one that died! Great video though, thanks!

  • @patrickm9953
    @patrickm9953 Před 3 lety

    Thanks !! I thought I was the only one having this problem. Your Very Well Produced video really helped me.

  • @fladam8584
    @fladam8584 Před 5 lety

    Glad you're back

  • @jurgenenders132
    @jurgenenders132 Před 4 lety +1

    I made this MOD .It Works fine for me. Thank You

  • @BrunoGaspar5
    @BrunoGaspar5 Před 5 lety +5

    I just connect the VCC to 3.3v instead of the 5v and it works perfect.... is there something wrong with that solution?
    Thanks!

    • @BrunoGaspar5
      @BrunoGaspar5 Před 5 lety

      @@stevechacon1613 for me it is still working with the 3.3v lol in my case it did not work with the 5v

    • @BrunoGaspar5
      @BrunoGaspar5 Před 4 lety +1

      @@stevechacon1613 yap exactly that. But with the 3.3v it worked as normal

    • @BrunoGaspar5
      @BrunoGaspar5 Před 4 lety

      @@stevechacon1613 sure, www.ebay.com/itm/5V-1-Channel-Relay-Module-Interface-Board-220V-for-Arduino-PIC-AVR-DSP-ARM/293069763253

    • @georgeprout42
      @georgeprout42 Před 4 lety

      @@stevechacon1613 I'm dumber. I was looking into 3v relays and completely forgot that I have a bunch of these boards at home already. So thanks for the reminder 🤣

  • @dedesite86
    @dedesite86 Před 2 měsíci

    I got the same relay (actually 2 in the same board) and unfortunetly it doesn't work with the 3.3V from a Raspberry pi Pico... I'll maybe try your hack, but on my board I can supply to a different VCC for the relay circuits, so I may create something less hacky with a voltage regulator.

  • @BlkNit60
    @BlkNit60 Před rokem

    Thank you!!!!, just what I needed!

  • @speedyairsoft1877
    @speedyairsoft1877 Před 2 lety

    idk if im doing something wrong my 5v relay isnt being powered on. on the board it haves g v and s but the but the only time i do get it to turn on is when i have 3v or 5v going into it s which i assume is the switch and the ground on the v which i also assume is the volts and when i add more power to the g which is the ground it clicks and if i put more power into it while plugged into the printer and its on it turns off

  •  Před 3 lety

    I got two of those and not surprisingly I could not get the first one to work. The second one worked without any mod though.

  • @MuhammadAli-ys5hq
    @MuhammadAli-ys5hq Před 4 lety

    Thanks a lot.. It saves my money and time.. God bless you

  • @pcysneros
    @pcysneros Před 3 lety

    This was a year ago is there a better way now? Is there a relay module you don't need to solder anything to?

  • @Berghiker
    @Berghiker Před 3 lety

    Can I use the same battery for both outputs on the relay for 2 different circuits? I did this but the relay keeps clicking. It can't stay on.

  • @freedomishealthy1086
    @freedomishealthy1086 Před 2 lety

    Can I use a "2 Channel Logic Level Converter 3.3V to 5V TTL Bi-directional Module" instead? I've already got one on my board for something else and am only using one channel.

  • @jonathanoeijoeng
    @jonathanoeijoeng Před 3 lety

    Is there no other pin that can give 5V ? I remember you mentioned in your previous video that the reason you use that pin is because you use 3.3v relay, does it mean there is other pin that can be used with 5v relay ? Thanks so much

  • @hienthanhquan
    @hienthanhquan Před 4 lety

    Works perfecty for me! Thanks a lot!

  • @omkarbansode6305
    @omkarbansode6305 Před rokem

    Thankyou Very Much Sir

  • @NevaEdizUfuk
    @NevaEdizUfuk Před 2 lety

    you are perfect good man !!!

  • @bellwlobell3199
    @bellwlobell3199 Před 2 lety

    i have question . If JDVCC use +5v (power supply), GND use -5v(power supply) , VCC use +5v (Raspberry pi), IN1(GPIO 17), IN2(GPIO 27),IN3(GPIO22)and IN4(GPIO23). can do like that?

  • @codyrap95
    @codyrap95 Před rokem

    If you are using RPi Pico you can use `machine.Pin.OPEN_DRAIN` instead of `machine.Pin.OUT`

  • @smartassist9700
    @smartassist9700 Před 4 lety

    Question please Sir.... is it much different using arduino instead of raspberry pi? Are you familiar with arduino?

  • @Josh-oe4ex
    @Josh-oe4ex Před 4 lety

    A bidirectional logic converter would work as well? Or no?

  • @calvinbarajas5144
    @calvinbarajas5144 Před 5 lety

    Thanks Gyro for a great hack/mod. Can you tell me where you purchased the ultra small pot please. I've looked for them and can only find the bigger ones. Thanks very much.

    • @Gyro1
      @Gyro1  Před 5 lety

      Look for trimmer not pot 😉

    • @calvinbarajas5144
      @calvinbarajas5144 Před 5 lety

      Thank you Gyro, I added a link to this video in my robot arm project under description (czcams.com/video/0TPGga4PDmM/video.html). I really appreciate your work.

  • @calvinbarajas5144
    @calvinbarajas5144 Před 5 lety

    Thanks for the great video. Do you know if I can run DC voltage on the NO/C terminals even though it says VAC everywhere on my 5v Relay? I'm trying to power an electromagnet with DC voltage (10V, 2A). Thanks very much.

    • @Gyro1
      @Gyro1  Před 5 lety

      Sure. That would be no problem

  • @sandidwikurniawan1809
    @sandidwikurniawan1809 Před 4 lety

    can i do this trick on relay module 2 channel version?

  •  Před 4 lety

    what about swapping the pnp with p channel mosfet?

  • @Lillibel-Web
    @Lillibel-Web Před 4 lety +2

    I don't understand why you cant use the 5V pin. Why it wont work?

    • @ygreq
      @ygreq Před 4 lety

      Yeap. 5V should work well on Raspberry Pi

    • @jakhva
      @jakhva Před 4 lety +2

      @@ygreq Tried it. Doesnt work. But you can just use the 3.3v pin on the PI instead of the 5V, and not bother with doing a custom circuit. Just got it to work now, using pins 13, 17 and 6.

    • @TommyLimKW
      @TommyLimKW Před 4 lety

      @@jakhva This is brilliant! It works without soldering.

    • @BrunoGaspar5
      @BrunoGaspar5 Před 3 lety

      @@jakhva I was doing that and working, and for some reason now it does not work anymore :/

    • @jakhva
      @jakhva Před 3 lety

      @@BrunoGaspar5 see if any wires got out of place or if the relay is still fine. Did you change anything on the software side?

  • @alexandru-cosminvintila6115

    I don't know what to do. All the time, my pin gpio 2(pin 3) stays high. Doesn't work to turn it off...

  • @musthycmbs20
    @musthycmbs20 Před 5 lety

    Thanks !!!!

  • @muratkancaoglu3284
    @muratkancaoglu3284 Před 4 lety

    Use an binary optocoupler

  • @_emrekocak
    @_emrekocak Před 4 lety

    Can you share which compenent use in 0:23 please?

  • @diyer1190
    @diyer1190 Před 5 lety

    When you turn off the printer remotely, the Raspberry pi also power off?

  • @rikkardo9359
    @rikkardo9359 Před 5 lety +3

    Oof

  • @two_boys_and_a_camera
    @two_boys_and_a_camera Před 3 lety

    For all those people with 5v relays, I had the same problem with it not working. I got it working by using pins 4, 6, 8. If this still doesn't work change it to Gcode command in octoprint.

  • @worms32
    @worms32 Před 3 lety

    This method requires a high level of soldering skill. Here is an alternative method that can be applied: ogrenilendersler.blogspot.com/2020/12/5v-relay-usage-with-raspberry-pi-for.html

  • @robson6285
    @robson6285 Před 5 lety +1

    What a bad designd electronics. Okay it works, just. But use a NPN with two resistors and no need for a trimpot so the transistor will easy switch between totally open and close. Why you used a PNP here? Thats terrible because this will switch depending on the difference between the drive 0 to 3,3v and the 5v rail, so you need to adjust so it can switch on/off on 1,7 and 5v ! You should use the 0v rail as the common, so the transistor will switch on any driving voltage above 0,6v or higher with your choose the resistors.

    • @SianaGearz
      @SianaGearz Před 5 lety +1

      I wonder what you mean exactly. Looks like this relay switches on when it's pulled down by an open-drain output of a microcontroller or microprocessor, where the processor would sink maybe 5 mA of current and the transistor gain of about 200 would make it into up to 1A, with about 100-300mA being necessary to drive the coil.
      You mean NPN switched collector, low side switching? How do you prevent 5V going into the 3V3 IO?