Thanks, this worked great. Was a bit hard to see which RPi pins you used but after checking your website I was up and running 👍 So many google results insist you need additional components so I'm glad I found your vid. I found that a multimeter with continuity test was really handy to check which contacts are being closed when the relay engages.
Thanks a lot. Made it very clear on how to use relay 5VDC with Pi. Saved me a lot of time and extra ordering relay 3VDC. Excellent tutorial!! Thank you!!!
@@SachinWable Uhm actually I dont remember perfectly. I think I still have the same relais tho. It is working and I have no idea what my problem was back then xD I have it on Pin 18, set up as output and it works normally by gpio.output(18, gpio.HIGH) or LOW to disable it again. I have a raspi 4
The gpio.low may not turn it off, but the cleanup call should. Unfortunately, I think this is just a function of the relay board not being designed for the 3.3V source on the pi. I wish that more tutorials made this clear.
If driven by an npn transistor the Triggervoltage shouldn't be a problem, but this one looks much like one that's driven by a PNP, then the voltage may be a problem arduinodiy.wordpress.com/2018/08/07/re-inverting-an-inverting-relay/
@@stuartg40 The Pi provides pins for 5V, but those are for power. The pins we use for GPIO actually output 3V or 3.3V. www.raspberrypi.org/documentation/usage/gpio/
Thanks for this. Ive brought the same relay however it doesnt switch from the 3v. When i drop the relay ever so slighty it then switches to on. Could this mean faulty relay, connection issue or something else? Much appreciated
I built this exactly the same as you - the green light on the relay turns on and off at intervals but it doesn't seem to power the 12V side - is it because my relay is too cheap and doesn't work with 3.3V ?
hi, great video! i iam working with a pi 3 and don't have the same results, i had worked with node red and y i had to be use a logic converter to 3,3v (pi out) to 5v relay in and vcc.
I noticed that, when I output from GPIO pin, no matter High or SLOW, my relay turns off Only after I change my code in the following can the relay be able to be switched by me. import RPi.GPIO as GPIO from time import sleep try: while True: GPIO.setmode(GPIO.BCM) GPIO.setup(21, GPIO.OUT) GPIO.output(21, True) print("high") sleep(2) GPIO.cleanup() print("low") sleep(2) except KeyboardInterrupt: print("key board interrupted") GPIO.cleanup()
Hola bro, muy buen contenido,aunque tengo una duda, porque al utilizar tu codigo,en vez de que se respeten los time, estos se suman, lo cual hace que el encendido dure más, y no se detenga, que me recomiendas hacer?
The pin on the RPi? Thats constant 5v from the power supply. The GPIO pins output 3.3v, the relay expects 5v. You need to something in between the RPi and relay to get this to work (or get a 3.3v relay)
I know this is old, but maybe it'll help someone else. If it has a high/low jumper, set it to HIGH. This will allow a low voltage range like 3v-5v. If you set it to low it only seems to take in the 5v as a trigger.
Hi was looking for the same answer and I found it in a raspberry Pi forum: You need to use 3.3V for VCC (instead of 5V), then you can use 3.3V from the GPIO to trigger it. Just don't use 5V at all for these single channel relay boards. I tested it and it worked for me (see yt video My1BDB1ei0E )
As you describe in the end, I to am having problems. I’ve switched cables multiple times, tried deferent pins. Even added a 2n2222 transistor with a 1k resistor to the signal wire to try and resolve the issue. Still no luck. Would you recommend a totally different relay then the one you are using in the video? Because that’s the one I’m having problems with.
This relay has a pull-in voltage of max 75 % its nominal voltage. Since this is the 5V version, up to 3,75V is required to make it operate so it can't be reliable on the RPi.
I would like to add a relay to turn on and off my CPU fan so if the temp on my cpu gets too high then the relay would close and start my fan and then if the temp dropped below a cooler temp the relay would open up and turn my cpu fan off....im wanting this so that the fan will not be running all the time and help save the life of the fan and not drawing power from the Pi when not needed. Thanks for any help !!
Can I use the 12v power source to also power a led light? Connect the led light ground to the ground of the 12v power, and then the positive to another relay?
The pull-in voltage is max 75 % its nominal voltage. Since this is the 5V version, up to 3,75V is required to make it operate so it can't be reliable on the RPi.
I have tried this but it doesn’t for me. I have 5v relay module as soon as I connect vcc to 5v pin, ground to ground pin and in to pin 18 which is set to out both relay lights glow. Even if I change pin status of 18 to dh or dl it doesn’t control relay at all. It always glows both the lights. But if I remove and connect pin 18 then it turns on and off the relay state. I have no idea why pin 18 high and low not controlling the relay. Any idea on this? Thank you.
hello, I can't speak English. I'm using google translate. I'd like to ask. I get the message "RPi.GPIO as GPIO no module" what is the solution? I have installed but it didn't work. Please help me 🙏🙏
How can you have the linear actuator move in reverse? What changes in the wiring and in the code? Ideally, I have 2 push buttons on my breadboard and I want one of them to push it forward and one of the to reverse it,
I know for a regular DC motor, I would need a motor driver and I am comfortable using the L293D to drive it's direction but I am unsure what to do for my 12V linear actuator with relay
I also had an issue where I tried GPIO14 and 15 and it wouldn't work, but did on 21. Is that just a fluke or is something to that? It seemed like you had a similar issue.
I think the 5V logic makes it unreliable with the RPI. I've read online that there is a hack where you add a resistor and it will work better with the RPI.
I had to add a resistor to my gpio pin on boot. It didn't matter what pin I assigned. My python accident work perfectly. The reboot/boot was my issue because it activated the relay. But with one and or two workarounds. 1. User a resistor., 2. Create a bash script to 🔥 a python script at boot.(I still could not get my direct python script to for at boot alone. So I used a bash in-between.)
that relay is 5V which means if your output is less than 5V, you can control the relay to close, if larger than 5V, relay is open...but raspberry GPIO pin can only gives you 3.3V maximum...how can you control that relay???
Hey YK Y, you're correct in that the 5v relays may have issues with the pi. (I made this tutorial a while back and have been meaning to update it) You can try using a 3.3v relay instead. Also I found this hack which may work in the meantime: ua-cam.com/video/p7wmzAzDX-Q/v-deo.html
Mathias Højsleth You can find the spec for this product, usually the working load is printed on the body, like 3A/50VDC or 5A/250VAC etc. and you can also select those products which you can set the mode to be “high-voltage-triggered” or “low-voltage-triggered”.
Finally, this is the first video I've seen of relay set up with the code that's step by step and understandable. Thank you!
Thanks, this worked great. Was a bit hard to see which RPi pins you used but after checking your website I was up and running 👍
So many google results insist you need additional components so I'm glad I found your vid. I found that a multimeter with continuity test was really handy to check which contacts are being closed when the relay engages.
Great tutorial ! Though I used a little different relay from your vid but it still worked perfectly with your code. Thank you so much !
Thanks a lot. Made it very clear on how to use relay 5VDC with Pi. Saved me a lot of time and extra ordering relay 3VDC. Excellent tutorial!! Thank you!!!
I have the same relay, but it always turns on once the GPIO is set to OUT, and only turns off when the GPIO is set to IN
Same problem for me as well, any solution for this?
@@SachinWable Uhm actually I dont remember perfectly. I think I still have the same relais tho. It is working and I have no idea what my problem was back then xD
I have it on Pin 18, set up as output and it works normally by gpio.output(18, gpio.HIGH) or LOW to disable it again.
I have a raspi 4
The gpio.low may not turn it off, but the cleanup call should. Unfortunately, I think this is just a function of the relay board not being designed for the 3.3V source on the pi. I wish that more tutorials made this clear.
If driven by an npn transistor the Triggervoltage shouldn't be a problem, but this one looks much like one that's driven by a PNP, then the voltage may be a problem arduinodiy.wordpress.com/2018/08/07/re-inverting-an-inverting-relay/
I thought the GPIO was 5V. Why is everyone now saying 3.3V? TIA.
@@stuartg40 The Pi provides pins for 5V, but those are for power. The pins we use for GPIO actually output 3V or 3.3V.
www.raspberrypi.org/documentation/usage/gpio/
Thanks for this. Ive brought the same relay however it doesnt switch from the 3v. When i drop the relay ever so slighty it then switches to on. Could this mean faulty relay, connection issue or something else? Much appreciated
I built this exactly the same as you - the green light on the relay turns on and off at intervals but it doesn't seem to power the 12V side - is it because my relay is too cheap and doesn't work with 3.3V ?
Great video! Would it be possible to power the relay with a battery pack? Any tutorials on how to do it?
hi, great video!
i iam working with a pi 3 and don't have the same results, i had worked with node red and y i had to be use a logic converter to 3,3v (pi out) to 5v relay in and vcc.
À
I noticed that, when I output from GPIO pin, no matter High or SLOW, my relay turns off
Only after I change my code in the following can the relay be able to be switched by me.
import RPi.GPIO as GPIO
from time import sleep
try:
while True:
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.OUT)
GPIO.output(21, True)
print("high")
sleep(2)
GPIO.cleanup()
print("low")
sleep(2)
except KeyboardInterrupt:
print("key board interrupted")
GPIO.cleanup()
Worked without any glitch 👍🏽. Excellent tutorial
Hola bro, muy buen contenido,aunque tengo una duda, porque al utilizar tu codigo,en vez de que se respeten los time, estos se suman, lo cual hace que el encendido dure más, y no se detenga, que me recomiendas hacer?
What do u mean by changing the jumpers?
PLs explain !
How is your 3.3v GPIO output switching your 5V relay?
on the top right pin the voltage is 5V
The pin on the RPi? Thats constant 5v from the power supply. The GPIO pins output 3.3v, the relay expects 5v. You need to something in between the RPi and relay to get this to work (or get a 3.3v relay)
I know this is old, but maybe it'll help someone else. If it has a high/low jumper, set it to HIGH. This will allow a low voltage range like 3v-5v. If you set it to low it only seems to take in the 5v as a trigger.
@@fouroakfarm I also came here to answer the question but still not a right one..
Hi was looking for the same answer and I found it in a raspberry Pi forum: You need to use 3.3V for VCC (instead of 5V), then you can use 3.3V from the GPIO to trigger it.
Just don't use 5V at all for these single channel relay boards. I tested it and it worked for me (see yt video My1BDB1ei0E )
Those GPIO pins are in incredibly anemic... Designed originally for 3mA... 15mA is pushing it. That took me by surprise.
Your video tutorials are the best!
Can you use a relay to throttle a motor precisely? Say, run 30%, then 50%?
can I avoid powering the relay via raspberry and power it with another power supply, by only letting the signal cable come out of the raspberry?
Very nice, I like this tutorial 👍
Hey I have the same relay module you showed first, how can I get that one working?
As you describe in the end, I to am having problems. I’ve switched cables multiple times, tried deferent pins. Even added a 2n2222 transistor with a 1k resistor to the signal wire to try and resolve the issue. Still no luck. Would you recommend a totally different relay then the one you are using in the video? Because that’s the one I’m having problems with.
This relay has a pull-in voltage of max 75 % its nominal voltage. Since this is the 5V version, up to 3,75V is required to make it operate so it can't be reliable on the RPi.
hi ty for the vid. the relay act as a switch and a volt divider between the power supply and the R-pi?
because of the 3.3 volt limit in the R-pi
ty.
I would like to add a relay to turn on and off my CPU fan so if the temp on my cpu gets too high then the relay would close and start my fan and then if the temp dropped below a cooler temp the relay would open up and turn my cpu fan off....im wanting this so that the fan will not be running all the time and help save the life of the fan and not drawing power from the Pi when not needed. Thanks for any help !!
I have a similar project with arduino and everything was fine until yesterday my relay chatters whats the problem?
Thank you, this was a very well done tutorial!
Can I use the 12v power source to also power a led light? Connect the led light ground to the ground of the 12v power, and then the positive to another relay?
Didn't understand how you can safely control a 5V Relay with the output of the Pi (which is 3.3v).
The pull-in voltage is max 75 % its nominal voltage. Since this is the 5V version, up to 3,75V is required to make it operate so it can't be reliable on the RPi.
Only tutorial which worked for me, thanks so much! works for arduino too!
Thanks for this video i used this to make a shel server that can turn my pc on and off anywhere so i can always stream to it to game or code
I have tried this but it doesn’t for me. I have 5v relay module as soon as I connect vcc to 5v pin, ground to ground pin and in to pin 18 which is set to out both relay lights glow. Even if I change pin status of 18 to dh or dl it doesn’t control relay at all. It always glows both the lights. But if I remove and connect pin 18 then it turns on and off the relay state. I have no idea why pin 18 high and low not controlling the relay. Any idea on this? Thank you.
Whereas I am able to control led light through the same output pin 18 but not relay.
Great video. I have the same relay unit and the code example is spot on. Got it working for my with my rPi Zero W. Thanks very much.
hello, I can't speak English. I'm using google translate. I'd like to ask. I get the message "RPi.GPIO as GPIO no module" what is the solution? I have installed but it didn't work. Please help me 🙏🙏
really very useful and informative
How can you have the linear actuator move in reverse? What changes in the wiring and in the code? Ideally, I have 2 push buttons on my breadboard and I want one of them to push it forward and one of the to reverse it,
I know for a regular DC motor, I would need a motor driver and I am comfortable using the L293D to drive it's direction but I am unsure what to do for my 12V linear actuator with relay
hello, Thanks a lot for this video. It is exactly what I was looking for :D
I also had an issue where I tried GPIO14 and 15 and it wouldn't work, but did on 21. Is that just a fluke or is something to that? It seemed like you had a similar issue.
I think the 5V logic makes it unreliable with the RPI. I've read online that there is a hack where you add a resistor and it will work better with the RPI.
I had to add a resistor to my gpio pin on boot. It didn't matter what pin I assigned. My python accident work perfectly. The reboot/boot was my issue because it activated the relay. But with one and or two workarounds. 1. User a resistor., 2. Create a bash script to 🔥 a python script at boot.(I still could not get my direct python script to for at boot alone. So I used a bash in-between.)
Hey so why use a 12v PSU? Is that what the DC motor needs? Sorry, I'm new to electronics forgive me!
Used for demonstration purposes. Definitely double check to make sure your dc motor has similar voltage specifications.
A lot of the things used by the relay (eg motors, solenoids) are 12V
hey im new to the raspberry pi and just wanted to ask how do i load the script into the pi? in the video you skipped over this part
nvm figured it all out great vid mate!
Wahts I connect to a 24 volt power suply
that relay is 5V which means if your output is less than 5V, you can control the relay to close, if larger than 5V, relay is open...but raspberry GPIO pin can only gives you 3.3V maximum...how can you control that relay???
Hey YK Y, you're correct in that the 5v relays may have issues with the pi. (I made this tutorial a while back and have been meaning to update it)
You can try using a 3.3v relay instead. Also I found this hack which may work in the meantime: ua-cam.com/video/p7wmzAzDX-Q/v-deo.html
@@PiddlerInTheRoot I just found out, if you connect the relay with 3.3V power, and send signal with 3.3V you can actually use that 5V relay.
@@yky1360 is that safe to do when the relay is controlling a 220v circuit?
Mathias Højsleth You can find the spec for this product, usually the working load is printed on the body, like 3A/50VDC or 5A/250VAC etc. and you can also select those products which you can set the mode to be “high-voltage-triggered” or “low-voltage-triggered”.
@@yky1360 ok, but what you are saying about connecting the 3.3v does that mean I should use the 3.3v gpio instead of the 5v on the PI?
Thanks!!!!
very helpful for meeeeee, thanks
Good video.
Thanks a bunch!
Can you use it in europe where mains voltage is around 16Amps?
I'm pretty sure the one in my tutorial is rated for 10 Amps.
Thanks!
so could you run this with a SD card?
Nvm
Thank you. :)
Lol video