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

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

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

  • @mujahidalfattaah5957
    @mujahidalfattaah5957 4 года назад +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

  • @maxr382
    @maxr382 5 лет назад +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.

  • @vks002
    @vks002 5 лет назад +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 2 года назад

      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 2 года назад

      @@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 2 года назад

      @@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 2 года назад

      @@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.

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

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

  • @EricJorgensen
    @EricJorgensen 5 лет назад +13

    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 3 года назад +2

      my god, this has worked, thank you

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

      this is the easiest solution, thanks so much!

    • @omg.itswendelin9374
      @omg.itswendelin9374 8 месяцев назад

      Thank you

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

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

    • @iansibuma
      @iansibuma 5 месяцев назад

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

  • @alvinmast8551
    @alvinmast8551 4 года назад +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 Год назад

      This idea works perfectly simple fast and to the point

  • @AsDurTube
    @AsDurTube 5 лет назад +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 4 года назад +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 Год назад

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

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

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

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

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

  • @elektron2kim666
    @elektron2kim666 10 месяцев назад

    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.

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

    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!

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

    Glad you're back

  • @user473
    @user473 5 лет назад +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 3 года назад

      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?

  • @BrunoGaspar5
    @BrunoGaspar5 5 лет назад +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 5 лет назад

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

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

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

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

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

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

      @@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 🤣

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

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

  • @bjirlar
    @bjirlar 4 года назад +4

    Thx... Your video save my project 🙏

  • @IIIXJannikXIIIDE
    @IIIXJannikXIIIDE 2 года назад +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?

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

    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 2 года назад

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

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

    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

  •  3 года назад

    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.

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

    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

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

    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 3 года назад

    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 3 года назад

    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.

  • @Lillibel-Web
    @Lillibel-Web 5 лет назад +2

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

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

      Yeap. 5V should work well on Raspberry Pi

    • @jakhva
      @jakhva 4 года назад +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 4 года назад

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

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

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

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

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

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

    Works perfecty for me! Thanks a lot!

  • @MuhammadAli-ys5hq
    @MuhammadAli-ys5hq 4 года назад

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

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

    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  5 лет назад

      Sure. That would be no problem

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

    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  5 лет назад

      Look for trimmer not pot 😉

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

      Thank you Gyro, I added a link to this video in my robot arm project under description (ruclips.net/video/0TPGga4PDmM/видео.html). I really appreciate your work.

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

    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?

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

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

  • @Josh-oe4ex
    @Josh-oe4ex 5 лет назад

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

  • @alexandru-cosminvintila6115
    @alexandru-cosminvintila6115 4 года назад

    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...

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

    Thankyou Very Much Sir

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

    you are perfect good man !!!

  •  5 лет назад

    what about swapping the pnp with p channel mosfet?

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

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

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

    Use an binary optocoupler

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

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

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

      No

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

      @@Gyro1 Stand by mode?

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

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

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

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

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

      ruclips.net/video/p7wmzAzDX-Q/видео.html

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

    Thanks !!!!

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

    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.

  • @rikkardo9359
    @rikkardo9359 6 лет назад +3

    Oof

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

    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 6 лет назад +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 6 лет назад +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?