Raspberry Pi: 16 Channel Relay how to with example software for automation projects

  Рет қаралды 215,999

skiwithpete

skiwithpete

Күн бұрын

Check in this section for all the further information relating to this video.
Get everything you need to make this project here:
16 channel relay: amzn.to/1JnojSq
Get that power connector: amzn.to/1VyXnAI
Get some hook up wire: amzn.to/1VyXso6
Get the screwdriver set: amzn.to/1JOygDi
12V power supply: amzn.to/1JnpmSh
GPIO wires: amzn.to/1VyYIYb
Raspberry Pi A+: amzn.to/1VyYdxr
----
**Remember: Help each other in the comments section. And please repost your code.
Find the scripts here:
script16_1: github.com/skiwithpete/relayp...
script16_2: github.com/skiwithpete/relayp...
script16_3: github.com/skiwithpete/relayp...
script16_4: github.com/skiwithpete/relayp...
script16_5: github.com/skiwithpete/relayp...
---
To see my other Raspberry Pi projects:
Garage door remote: • Easy Raspberry Pi Gara...
Outdoor Automated Lights: • Raspberry Pi Automated...
File Server (NAS): • RaspberryPi: File Serv...
Weather Station: • Raspberry Pi: Weather ...
How to Bitcoin Miner: • How to: Mine Bitcoins ...
Voice activated lights: • Raspberry Pi: Voice ac...
Alarm Clock Project: • Raspberry Pi: step-by-...
If you like the video or think it's useful buy me a coffee bit.ly/1kAous6
Or Buy me a coffee with bitcoin! 1HfHr25qZQjPzwphPxpNaD5CytDNYcfzrJ
Support this channel on Patreon!
/ skiwithpete
Don't forget to tell post links to any Projects you’re up to, or let me know if there's anything you’d like me to try out.

Пікірлер: 394
@highwaywarrior1078
@highwaywarrior1078 6 жыл бұрын
Pete - thanks for this comprehensive guide - it's really been helpful. Having said that and having wired everything up as you said, I too have suffered some of the same issues that others have been reporting here and I believe I have found a work-around that requires no additional components and is very straightforward. I'm using a RPi 3, GrovePi sensor board and a 16 channel relay board very similar to yours except mine is a 5V input rather than 12V. What I eventually established is that you only need one 3V3 connection from the RPi to the relay 5V pin. Leave the other 5V pin unconnected. Then only connect 1 ground wire from the RPi to the GND pin on the relay board - making sure you connect the GND on the same row as the 5V pin you have connected to the RPi. So instead of having 20 wires connecting the RPi to the relay board I only have 18. I have had no problems whatsoever since doing this and all of your scripts have worked as they should. Hope this helps everyone else.
@madmax200769
@madmax200769 Жыл бұрын
Tried that, it blew my Pi unfortunately :(
@TheMachbose
@TheMachbose 7 жыл бұрын
Hi. Wonderful job! Many thanks for that huge work. I was searching for "how to connect a SainSmart 16 channel board in the most simpliest way" and I founded it! Thanks! In my project, I want to use the 16 channels board directly on a RspiB mounted with Domoticz and an Arduino in USB mounted with "MySensors" and several sensors in a hydroponic project 100% automatized. You helped me to leave the first stone. Respect to all people sharings skills and passions over Internet. Following you now.
@zq_77
@zq_77 7 жыл бұрын
I have the same relay switch except that it runs on 5v instead of 12v (I'm powering it from a 5v 2A dc adapter). Your scripts worked like a charm. Thanks man :-)
@vikingofengland
@vikingofengland 5 жыл бұрын
When I get my man cave built, thinking of creating a smart garden with lights and auto plant watering. Thanks for the videos, really clear and understandable.
@maarijkhan626
@maarijkhan626 Ай бұрын
Is it a real cave or just a basement?
@marksonstein2807
@marksonstein2807 7 жыл бұрын
Spent an hour researching why the relays would turn on, but not turn off. Then I saw Eric Steed's post below. Changing the VCC connection from Pin 2 (5V) to Pin 1 (3.3v) and everything worked as expected.
@thomaskblr1
@thomaskblr1 5 жыл бұрын
OMFG! I wish I would have read this earlier. Spent most of the day thinking I missed a step!
@jheckerman
@jheckerman 6 жыл бұрын
This video is incredible! Thank you for all your precision and detail!!
@skiwithpete
@skiwithpete 6 жыл бұрын
thanks for your comment, please share and spread!
@bakerpmp00
@bakerpmp00 7 жыл бұрын
Connecting the 5v pins on the relay to the 3.3 v pins on the pi fixed the problem of them all turning on at once thanks!
@yvesdev386
@yvesdev386 8 жыл бұрын
This was very informing. keep it up, these are great!
@Jexjo
@Jexjo 3 жыл бұрын
Exacly what i'm searching for, thank you very much!
@Angealies
@Angealies 8 жыл бұрын
Love the videos, keep up the great work man :)
@skiwithpete
@skiwithpete 8 жыл бұрын
+Angealies Thanks. Really happy with this one. My most complete relay video yet!
@HuaweiBaru
@HuaweiBaru 6 жыл бұрын
good teacher and this good video for whom need detail instruction ... keep educate
@showmequick2245
@showmequick2245 8 жыл бұрын
This guy is good, Thank you for the video :)
@mohdasifmoulvi3854
@mohdasifmoulvi3854 5 жыл бұрын
thank you i learnt very much from u r videos
@louisstacey8060
@louisstacey8060 8 жыл бұрын
thank you so much you make the best pi projects always work thank you so much
@skiwithpete
@skiwithpete 8 жыл бұрын
thanks.
@steveg219
@steveg219 8 жыл бұрын
Awesome- really clear and complete, thank you
@anthonypottinger385
@anthonypottinger385 7 жыл бұрын
Thanks for the video (16 channel Relay Raspi)really useful. Got it all working with a Pi Zero. I noticed that the 5v back feeds from the relay board and powers the Zero, so I am wondering if 5v really needed by the relay board as it appears to provide this via the 12v connection. Going to use this to provide an automated control for my wifes doll house light with a LDR and PIR so lights will change when PIR triggers. Got a bit of programming to first!
@siamakmojdeh
@siamakmojdeh 7 жыл бұрын
Thank you so much for your video. very help helpful.
@markthrasher5847
@markthrasher5847 6 жыл бұрын
I have hooked up my 16 port relay and Raspberry 3 per your video. The problem is when the script runs, the relays lock on and won't go off. Not really sure what is going on? Can you help? Thanks
@asimmohammed
@asimmohammed 8 жыл бұрын
I learned a lot from you. you are awesome :)
@skiwithpete
@skiwithpete 8 жыл бұрын
+asim mohammed Thanks, that's very kind. Let me know if you get up to any of the projects on my channel.
@nickwall2288
@nickwall2288 3 жыл бұрын
Awesome thanks for the very helpful video
@fireeeflies
@fireeeflies 8 жыл бұрын
Thank you for replying , I' ll try to post a video, I have a 4 channel relay running some of your scripts, I have connected 1 LED light strip on each relay, running your script2 I thought the lights would turn on/off in the order the relay is switching (wave like), instead all the 4 led strips light up at the same time, what I wanted to accomplish was to have a sequence in the order the relay is switching like a light show, I know I may be confusing you with this question, so will try to post a video as soon as I can , i ordered all the same parts listed on your 4 channel relay video. Thank you so much!
@jamescue7464
@jamescue7464 4 жыл бұрын
Check your wiring, some wires may be out of sequence?
@ericcarrozzo5846
@ericcarrozzo5846 4 жыл бұрын
Great video, i too can't get it to work how you have it shown. Some of the comments have had people connect the 5V rail on the relay to the 3.3v on the PI. While this appears to work, several people said it fried the PI. I think I will have to just use two 8 channel relays for what I want to control. I wasn't too happy about needed a 12v external power source anyway.
@jamescue7464
@jamescue7464 4 жыл бұрын
Check the amperage of the 5+v on the board, if it is higher than what your pi requires it will fry your pi, if it it is too much under the amperage then your pi will not work.
@ryanhebron4287
@ryanhebron4287 8 жыл бұрын
I like how they used optocouplers on-board it makes it less worrisome about buffering the GPIO's. I did unfortunately have a death in my Raspberry Pi family. This is the cost of not checking your GPIO wiring.
@spawn666reaper
@spawn666reaper 6 жыл бұрын
I got my setup in the mail. Tried to reproduce your setup. Seems to work partially. At relay 11 all red leds dim, 12 does switches but does not click and after that the board resets or the pi reboots. I have a 2amp 12v power adapter connected, possible thats not enough? (pi is also powered by the relay board.)
@ronaldfernandes5697
@ronaldfernandes5697 4 жыл бұрын
After connecting 5v to relay throu the pie and latter you programmed the pie. After programming tte pie did you connect 12 v to relay when the 5v was connected. While programming. I would like to know
@isaacfainsod1986
@isaacfainsod1986 6 жыл бұрын
Do you know if I can use a computer power supply (12v cable) to give energy to the relays
@caspercorneliuspatontan3645
@caspercorneliuspatontan3645 3 жыл бұрын
im having some issues, with just the connections. I'm using a RPI 4 with a 16channel 5V relay board. what I'm having trouble with is that when i do a GPIO.setup all the relays with be switch on and i am unable to switch it off or control it, unless i do a cleanup. send help
@JhelumNet
@JhelumNet 7 жыл бұрын
You can be a good teacher 👨‍🏫
@daveklebt7732
@daveklebt7732 6 жыл бұрын
yes, grasshopper, after your toil in the garden of Herculean Code Edit and clean the Augean Stables of Rewire then you will eventually discover that 3.3v is correct and 5V will make you head spin for an interminable time. Only then can you pass the test and walk gently across the rice paper to brand your arms with the Rasperian logo.
@bubba1984
@bubba1984 8 жыл бұрын
so are those inputs on the board pulled up to 5v?
@dexterweb
@dexterweb 7 жыл бұрын
i've tryed with my PI3B with a 12v 2.5A power adapter and pins connected to 3.3 v on the PI side and...surprise surprise, the PI turns on without his power adapter. In some way electricity from the relay board flows to the PI and keeps it running. is this ok? should i still power the PI with its adapter?
@esteed71
@esteed71 8 жыл бұрын
I figured out what my problem was. I was using the 5 V connection from my pi zero to the board. When I switched it over to 3.3 V, everything worked like a chanp. I'm using the same exact really is you, the same smart 16 channel really with Opto couplers.
@alexeyanisimov8744
@alexeyanisimov8744 8 жыл бұрын
thanks for the tip! helped in my case as well!
@fasihzafar7423
@fasihzafar7423 7 жыл бұрын
Thanks man.............You Saved me..............!...........Such a Big Help .......(y)
@sponsjeee
@sponsjeee 7 жыл бұрын
rasp 2b worked for me 2 ! thanks
@sercio994
@sercio994 8 жыл бұрын
Thank you so much! :)
@johnlayman2836
@johnlayman2836 6 жыл бұрын
Your python programming is absolutely wonderful. I learned so much. Thank you. In the first script, I learned how you designated the pins as output pins using a "for" loop. I wonder why you couldn't do the same thing for the long section where you used "try:" I'm a beginner with python and was just wondering.
@skiwithpete
@skiwithpete 6 жыл бұрын
John Layman just wanted to show different ways.
@srfrg9707
@srfrg9707 4 жыл бұрын
I retrofited an old washing machine with this board. It came with a broken mechanical programmer. The only issue was when runing the motor at full speed the relay burned after a few uses because it was arcing (the motor turns into a generator when speeding down). I needed to add an anti arcing circuit to avoid that so it was not a big issue since I had a few spare relays to use.
@AnanFakheraldin
@AnanFakheraldin 8 жыл бұрын
Hi skiwithpete, I'm trying to connect the relay to control my home light. I use the relay to turn off/on the light from my Pi with no problems. But how can get the input from the physical switch light buttons and update the status of relay in Pi? In addition, what is the best way to add more gpio to Pi for example, I need to control 32 relays (outputs) , which means I need 60 gpios ( input + output) , Can I use a chip like this - mcp23017 ?
@ernsthaeckel5276
@ernsthaeckel5276 5 жыл бұрын
Anan My thoughts exactly! It will make the wiring, easy enough here, even more easier. What do we rate I2C or SPI? SPI Bus has great range and extendability in space. uk.farnell.com/microchip/mcp23017-e-sp/ic-io-expander-16bit-i2c-28dip/dp/1332088?CAWELAID=120173390001317605&CMP=KNC-GUK-GEN-KWL&mckv=PpFlXUmR_dc|pcrid|186409721995|&gclid=Cj0KCQiA8_PfBRC3ARIsAOzJ2up7DjZxOCZL_Cen37JrHBbdhxoFt6XbTe6iTy3dBNfTw0NxUHGfOmAaAjgKEALw_wcB
@ohhchhittt
@ohhchhittt 5 жыл бұрын
I followed your video that I must say was very easy to follow. Only thing I am not sure on is the power from the pins on the pi to the relay board. The relay board says it's an output of power not a in put. Does it do both or am I reading wrong. I'm running 12 v 1 amp power to the relay board and the 5v pin is powering my pi with no transformer. Please help me understand a little better
@jewelrybyjd
@jewelrybyjd Жыл бұрын
This video series is great. My question is. How can you turn on more than one relay at a time? Then turn them off at different times? That way they're not so patterned. They could be more random, or sync to music? Thanks for any help that you can provide.
@pgoldstein
@pgoldstein 8 жыл бұрын
Hey Mate!! Do you have any project, an idea to make it or even indicate a project including a simple wall light switch that can change the relay status. This way I could monitor, in real time and save into a database, the way I on or off lights and I also could show the real status on a webPage. Cheers
@funnyvlog9331
@funnyvlog9331 Жыл бұрын
Hi Sir pete I found your Channel it's so great,I hope I can learn your program and how use the raspberry board.God bless. I am also a new subscribers of yours . Thanks
@bakerpmp00
@bakerpmp00 7 жыл бұрын
Is the common wire connected only to the outlets and the relay, also how did you ground the outlets?
@krasate
@krasate 7 жыл бұрын
Hey @skiwithpete, great video and great focus on the camera, thanks. One question please, as i have a similar module and struggling to figure out what's wrong. If you connect the 12v power to the module and then the 5v+GND from the module to the 5v_GND of the rPi, does it power the rPi on? I connected the 12v power to the module, used a multimeter on the 5v and gnd pins and it gives me 5v. Is that normal? Could you check on yours?
@jamescue7464
@jamescue7464 4 жыл бұрын
Check the amperage on the 5+v, it should be somewhere between 1.5+ amps to 3.0 amps to power the rpi. Connect the positive of you amp meter to positive post on the board and negative to negative post on the board. Depending on which pi you are using (check what voltage and amperage is required for that pi), you ought to be able to power your pi from that board.
@alextadeo8455
@alextadeo8455 7 жыл бұрын
Could i wire up 2 16-channel relays to the Pi's 40 pins?
@jeremycaudill6916
@jeremycaudill6916 6 жыл бұрын
Any tutorials on what to do with the relay afterwards ?
@dennischang5296
@dennischang5296 3 жыл бұрын
I went ahead and weirded everything the way you have but when I go to run the script all the relay will kick on same time they will turn off when the run time is over. I also try your other script and same thing. All the relay will power on. Any idea on what I may have done wrong.
@josezepeda7396
@josezepeda7396 2 жыл бұрын
I know this video is 5 years old but I wanted to put it out there that I have a raspberry pi 4 B and I was getting all relays on at the same time when GND and 5V were supplied to both or just one. I switched that to a single row of GND and 3V3. I also had to not use GPIO4 and GPIO22, not sure why but they were supplying power in LOW and HIGH states. I changes the code for GPIO4 and 22 to GPIO23 and GPIO24 and that solved my power leak issue. Summary: use 3V3(only one row) and if any voltage leak change GPIO to another one.
@dvdgmz
@dvdgmz 6 жыл бұрын
Can the raspberry take inputs and translate them into a specific sequence of outputs?
@spawn666reaper
@spawn666reaper 6 жыл бұрын
I am planning out a project and I think this video is going to be pretty useful. Thank you so much for making it. My plan is to power some 12v 2amp devices, only, one at a time. My question. If the board uses 12v, what power supply would I need to power: the pi, relay board, and 1 relay output 12v 2 amp? Or do I need to split a separate 12v 2amp power supply into 12 outputs and wire each relay separately? (p.s. just starting out, sorry if its a noob question.)
@skiwithpete
@skiwithpete 6 жыл бұрын
The pi and the relay need separate power since it operates on 5V. There is a way to step down - but I don't do it. The question you asked though is can 12V power the relay, and power something on the other side too? Yeah, it can. Take a look at my "outdoor light setup" video, you'll see how I split the power.
@cydoniaoutlaw
@cydoniaoutlaw 6 жыл бұрын
After switching from 5V to 3.3V from the raspberry pi 3 it worked!!! Thanks for the info. Now a question... is anyone having trouble with gpio 11 &16 switching relay #1 on and off? This is driving me crazy!
@DFEUERMAN
@DFEUERMAN 4 жыл бұрын
I tried using the 3.3v and it destroyed my Pi :(
@blakechan09
@blakechan09 6 жыл бұрын
Hi great vid! How would I go on about if I wanted an input from the relay to the board? Case scenario being -- when a light in a room has been switched on, I'd like the relay to send a signal to the board that the light has been switched on? -- Would this be possible? How would I go on about tackling on this matter? Thanks!!!
@jamescue7464
@jamescue7464 4 жыл бұрын
The only way it could sense that a light has been turned on is to have light sensor at the source of the light, otherwise all it could tell you is if the relay is working or not. It could not even tell you if there is a short in the wiring to the light.
@nevinmcginnis9509
@nevinmcginnis9509 4 жыл бұрын
I am using a raspberry pi 3b+ and the same 16 relay module, When I try to run the first script16_1.py it lights all the relays up and turn off when its done counting to 16. If I try to run the script16_2.py it lights up all the relays until I hit CTRL C.
@rogerbailey3416
@rogerbailey3416 6 жыл бұрын
Greetings all I have the Sainsmart 16 channel board. I have watched the video which is very good. I have hooked my pi up the same way. But I can't seem to get it working right. When I power the pi and run the script, some of the relays come on and stay on. I have loaded your script and it still does the same thing. I wish someone could come up with the answer. I have read the comments from other folks and not really seeing the right answer to get it working. I have a 12V 3 A power supply hooked to the relay board. I have disconnected the ground wires and tried it. Still not working. I have disconnected the 5v wires and even moved them over to the 3 V side. Still not working right. I do see that your running the raspberry pi 2. Could that be the whole problem? I have seen that a few folks have got it running with the raspberry pi 3. I could use some help. Thanks everyone.
@kitajima_e
@kitajima_e 7 жыл бұрын
good project, but its good to stick to color codes especially on the power side
@henryfitzthum7563
@henryfitzthum7563 6 жыл бұрын
Hi do you know if one Can run RGB lights from this relay
@ahmadtauhid2807
@ahmadtauhid2807 4 жыл бұрын
hi.. it possible to add 8 channel relay again to single raspi board?
@eric_7761
@eric_7761 6 жыл бұрын
I´m curios. Why 12V supply if the realy partnumber says 5vdc? is there a regulator on this board
@forklift385
@forklift385 8 жыл бұрын
any way to have some sort of graphical interface that could be renamed through the graphics? Im trying for something like this for my vehicle to control lights and have a gauge display from the OBD. Id like the lights to be dimmable and color changing, then I might incorporate GPS as well
@skiwithpete
@skiwithpete 8 жыл бұрын
+forklift385 I'd use HTML/PHP because I'm most familiar with that as a language, but I'm sure you could just use Python if you wanted.
@esteed71
@esteed71 8 жыл бұрын
Great tutorial!! Very clear. I have a few questions though. I'm doing this on a pi zero so I don't know if that makes a difference. Whether I have only a few GPIO pins connected to the relay channels or all 16, when it steps through the loop to turn on the first relay, All of the relays that are wired to the Pi turn on for some reason. Also I was wondering what is the reason to have both 5v and both grounds hooked up? I tried several combinations and the only one that seemed to work as expected (partially) was when I didn't have any power or ground hooked up to the Pi. However when I try to turn on more than two relays in this configuration, the board makes a buzzing noise as if it's being underpowered. But- the relays come on one at a time as I expected them to. Any ideas?
@skiwithpete
@skiwithpete 8 жыл бұрын
+Eric Steed No, that's some unusual behavior. Are there shorts between your GPIOs? Are you sure you have an optocoupler relay? Are you supplying enough power to the Pi Zero (you should still use at least 1A)?
@RbrtWlkr
@RbrtWlkr 7 жыл бұрын
Why did you need to plug in the 5v if you are taking 12v from the power supply?
@Brounds24ify
@Brounds24ify 3 жыл бұрын
When I plug my relay all the channels light up, even with out our attached. Can someone help?
@matthewpferchy5298
@matthewpferchy5298 8 жыл бұрын
I received these relay shield from amazon and tested it but something weird, when I connect the relays to the raspberry pi 3and run the program all leds and relays automatically turn on. I'm using the same python code you use it, please any one advise what I should I do???
@henryfitzthum7563
@henryfitzthum7563 6 жыл бұрын
Hi can one use this relay to control RGB lights
@stevenfrazier7959
@stevenfrazier7959 6 жыл бұрын
Have you done anything with mqtt with any of your relays?
@juanbolivar35
@juanbolivar35 4 жыл бұрын
how do you add a lot more channels to the raspberry?
@insfnds7471
@insfnds7471 2 жыл бұрын
Nice intro to this 16channel board. One thing I question is why you would set the GPIOs to outputs before setting their state to high. Is this just a limitation of the RPi.GPIO library i.e. it won't let you set the state before it is set to an output? I've not done any gpio work with the RPI yet but I've always set the state first then enable the output that way there is no quick spike on the output.
@skiwithpete
@skiwithpete 2 жыл бұрын
I don't remember why I did this. I think it's because I had two types of relay. One that started high one that started low, so this set them all to same state... But I'm not 100%
@fuzzywuzzy9550
@fuzzywuzzy9550 6 жыл бұрын
would you use a relay and a motor controller
@Lurxyboy
@Lurxyboy 8 жыл бұрын
Hi mate, really nice video! I almost have the same setup at home (I am waiting for my powersupply, I run with 12V 0.6A atm and a RPi B+) the problem that I struggle with is that all the 16 channels turn on at once as soon as I change the GPIO state from IN to OUT. It doesnt matter how much I change from LOW to HIGH the relays stay turned on forever. the relayboard that I have is an ebay kina version could it be that the relayboard is faulty and how can I test this out? what do you think is the problem? if anyone here have any ideas that might help that would be great.
@fasihzafar7423
@fasihzafar7423 7 жыл бұрын
i have also the same problem, 2 channel relay works perfectly,when i connect 16 channel, the relays stay turned on forever.i am using 12v 2 amp power-supply for relay.
@ValentinScarevnea
@ValentinScarevnea 5 жыл бұрын
Hi, is it necessary to use both 5V pins?
@fireeeflies
@fireeeflies 8 жыл бұрын
Hi, love your video, Im totally new at this, I have set this up and have a question, I connected led lights to it, but all the lights turn n at the same time, is that whats supposed to happen or should they light up in a sequence, thanks,
@skiwithpete
@skiwithpete 8 жыл бұрын
impossible to tell what you're asking - can you take a video and post it here?
@jamescue7464
@jamescue7464 4 жыл бұрын
Test your relay board, it may be defective?
@dennischang5296
@dennischang5296 3 жыл бұрын
I notice when the GPIO is set to "output" doesn't matter if it's true/high or false/low, there is some voltage coming out of that GPIO pin. Very low .179volts, this is why I think the relay stays on, and doesn't turn off for me.
@garryhartlin2504
@garryhartlin2504 6 ай бұрын
In order for the relay board to work for a Raspberry Pi 4 you must ensure the inputs are active HIGH. Most boards out there are active or trigger LOW. If you have a active LOW board you will need to place a Darlington sink drive ahead of the relay board inputs. Use something like a ULN2803. You will need two of them, cost about $1.25 each.
@carlosarias9191
@carlosarias9191 7 жыл бұрын
Hi I want to that but with a NFC controller my idea is when I leave to the home 🏡 put the card #1in the NFC and the home loss all the energy. And close the door and.. when arrived to the home open the door with other card #2 and put the card #1 in the NFC and the home have energy again and when put the card #3.. six lights in the home turn on ,,, so you know how to do a remote control for the smartphone
@cylycious
@cylycious 5 жыл бұрын
Hi Pete, Great tutorial, especially for beginners like me! I must be doing something wrong, though. I used a rp3 and python 3.5 so I added parentheses to your script. I tried to run 16_1 and 16_2 and in both of them at start all relay diodes light up and only switch off when I ctrl+C the process. Any idea what I could be doing wrong? Thanks so much, I love the way you explain things! :)
@skiwithpete
@skiwithpete 5 жыл бұрын
They're activating on the low setting
@cuchuoisalay9263
@cuchuoisalay9263 6 жыл бұрын
I have a trouble when I turn off the relay. The code I used is the same as you but I debugged it, when it run to "GPIO.setup([PIN_NUMBER], GPIO.OUT]", the relay of this PIN_NUMBER is turned on. Can anybody help me for it? THANKS
@skiwithpete
@skiwithpete 4 жыл бұрын
turning off that pin, will turn it off. You will find that in the code as well.
@AndrewMurphy8383
@AndrewMurphy8383 6 жыл бұрын
@skiwithpete I am trying to write a script that would turn on one relay and it stays on while using ur script how would add or mod ur script to leave on one while the others are off if u could help you could give me would welcome
@skiwithpete
@skiwithpete 6 жыл бұрын
Watch my 4 channel relay video to see more script examples
@haplomic9616
@haplomic9616 Жыл бұрын
Thanks!
@skiwithpete
@skiwithpete Жыл бұрын
Awesome. Thank YOU
@Ed19601
@Ed19601 5 жыл бұрын
The problems that various people describe here that all the relays immediately turn on all together isquite explainable when you know the anatomy of this board: It isnt really made for 3v3. The input consists of an optocoupler that has its anode tied to +5Volt via a 1k resistor. The GPIO of the Raspberry then connects to the cathode of the optocoupler. On the secundary side of the optocoupler the collector is tied to 5Volt and the emitter is pulled to earth via a 10k resistor. The emitter then drives an ULN2803 which is an open collector, so it has the relay between the output and the 12 Volt. So here is what happens with the signal: Raspberry LOW -> optocoupler +serieresistor get 3V3 ->optocoupler opens ->emitter goes HIGH -> INPUT ULN2803 goes HIGH ->OUTPUT ULN2803 goes LOW -> Relay activated. So, as you can see from this, and which is clear from the script, you need a LOW to activate the relays and a HIGH to deactivate the relays. Now that is where the problem is. The 3V3 RASPI has no problems creating a LOW to activate the relay, but what happens if you send a HIGH. For arguments sake lets say that a HIGH on the raspi is 3Volt. That means that the optocoupler + serieresistor will still see 2 Volt.Not much, but it might be enough to open up the optocoupler, which will activate the relay, just as a LOW signal did. So why did not everybody have that problem, why did it work for Pete and not for others? Simply because of variation in components. So, what to do? Well, the easiest is to add 16 transistor leveladapters that have their collectors connected to the input of the board. added bonus is that they also invert the signal so you get an active HIGH contraption another solution is to bypass the LM2576 and feed the primary optocoupler with 3V3. Though adding the 16 resistors is a good solution, it is kinda ironic that those 16 resistors by itself already are capable of driving 16 relays
@matthewdornfeld2126
@matthewdornfeld2126 5 жыл бұрын
Do you have a model/part number that would be good for testing?
@Ed19601
@Ed19601 5 жыл бұрын
@@matthewdornfeld2126 it is about the one in the link in the discription. Further discussed here: arduinodiy.wordpress.com/2018/09/04/the-16-relay-module-and-the-raspberry-pi-not-an-ideal-marriage/
@IstiaqueAhamed
@IstiaqueAhamed 7 жыл бұрын
Can I use 12V, 5A power supply ?
@lups1488
@lups1488 7 жыл бұрын
love the video have not seen anyone provide a detailed video on how this board works. i am trying to build one to control christmas and halloween lights. i have a pi 2 model b and when i use your script all the realys turn on at once and once the count goes to 16 they all shut off. i changed the gpio numbers in the code to match my version of the pi and now a random half turns on all at once and then off at the end of the sequence. anyone have any ideas where i went wrong?
@skiwithpete
@skiwithpete 7 жыл бұрын
Are you using the BCM GPIO numbers or the GPIO numbers? Try changing the initial setting from hi to low to see if that changes the outcome.
@prakashkumkar7263
@prakashkumkar7263 6 жыл бұрын
hii sir i want arduino uno code for 16 channel relay for my home lighting on and off please help me
@apbesieged
@apbesieged 6 жыл бұрын
Is there something like this with a silent alternative. I'm noticing in the video they each make a click when turning on. My goal is to add lighting to a Lego city i am making and would like to have software turn on and off lights at random intervals. I would prefer there isn't a constant clicking sound being emitting from under the table.
@skiwithpete
@skiwithpete 6 жыл бұрын
Solid state relays might be a possibility, but they require higher voltages passing through them in order to operate.
@Soumyajit737
@Soumyajit737 5 жыл бұрын
Please add a video on how to control a DC motor using Raspberry Pi
@dmitrijbilalov
@dmitrijbilalov 8 жыл бұрын
Thx!
@efenditube
@efenditube 7 жыл бұрын
a big thank you !!!
@igormenin
@igormenin 7 жыл бұрын
Hi skiwithpete! I have a project to start automating the lights of my house. I have this board of 16 channels, and bought a plate with network interface RJ45 style the SaintSmart. I'm just doubt with the module supply to the relay because of the 16 relays will use at least initially 14 and do not know what the correct amperage to use this module with all this capacity?
@skiwithpete
@skiwithpete 7 жыл бұрын
do not play with mains electricity. wiring lights is dangerous! and must be left to professionals!
@igormenin
@igormenin 7 жыл бұрын
Exactly. Was I who made all the electrical network from my home.
@daveofyorkshire301
@daveofyorkshire301 2 жыл бұрын
For christmas lights you wouldn't want all that clicking, you'd use a MOSFET OR SSR (solid state relay)... They use less power, are silent in operation of and can switch at significantly faster rates. Plus a bank if them would take up significantly less space...
@dennischang5296
@dennischang5296 3 жыл бұрын
Learn a lot from this video. I do have one question. If I was going to wire in some water pumps to this relay. Does the positive wire from my pump go into the center of the relay? The ground for my pump does it go into the relay or should it go back to the power supply?
@skiwithpete
@skiwithpete 3 жыл бұрын
Yeah this only interrupts one wire in the circuit. Positive or neutral it doesn't really matter. But in your example, yes interrupt the positive and the neutral goes straight back to power.
@dennischang5296
@dennischang5296 3 жыл бұрын
But I can ground back to relay also right?
@skiwithpete
@skiwithpete 3 жыл бұрын
@@dennischang5296 No, it's like a light switch. You only interupt one side of the circuit. Both sides don't terminate back.
@darshitthakkar1439
@darshitthakkar1439 4 жыл бұрын
hi i tried same in my raspberry pi 4 (prog used script16_1)my relay card is not operating can any one help???
@masehacker
@masehacker 8 жыл бұрын
This worked for me finally with a SainSmart 16-Way Level Conversion Module for Raspberry Pi. I made a template for a php menu system that has on/off menu and a status red/green light to see which one is on atm. If you are interested msg me. Very simple to install just unzip and run a sudo cp command to get the files in the right directory.
@pranavjgangani
@pranavjgangani 7 жыл бұрын
I just bought a Sainsmart 16 way Level converter after reading the comments here. Could u guide me how to connect the pins between Pi, 16-way level converter and 12v 16-Ch Relay?
@balgruufthegreater9072
@balgruufthegreater9072 8 жыл бұрын
I want to make a home automation and i bought a 16 channel relay like that for switcking a few things like the gate opening and so on. Everything should be controlled by a server application which i am doing installed and hosted on a raspberry pi. Here's the question: how can I get inputs like checking if the doorway is open?
@skiwithpete
@skiwithpete 8 жыл бұрын
+Balgruuf The Greater I'd use this: amzn.to/1Jrihjt and poll it for status every 2 seconds or something.
@balgruufthegreater9072
@balgruufthegreater9072 8 жыл бұрын
Thanks
@jackfernald8823
@jackfernald8823 7 жыл бұрын
Alright, I have no idea what I'm doing and I've been at it for the last 3 hours. When I run the first program you have all the relays turn on but when it runs through each one individually nothing happens. I've done some testing out found if I set the pin on the board to output the relay activates but when set to input the relay deactivates. I can't control the relay by setting the pin high or low just by changing the mode of the pin to in vs out. Why is it doing this? and how can I fix it?
@lukasweishaupt2708
@lukasweishaupt2708 4 жыл бұрын
I know your comment is already three years old, but did you fix this issue? And if yes... how?
@turke6756
@turke6756 4 жыл бұрын
Lukas Weishaupt this is the issue I’m working on now let me know if you have a solution
@SnowPuffKing
@SnowPuffKing 4 жыл бұрын
@@turke6756 same issue here
@turke6756
@turke6756 4 жыл бұрын
Okay I got it to work with the raspberry pi. My particular relay board and probably yours too works on 5v logic and the pi is 3.3v logic. All you need is a logic level converter can be bought for dirt cheap. (Relays requires the 5v to signal off position so you can turn it on but not off)
@turke6756
@turke6756 4 жыл бұрын
Tim Neeley I think I figured it out check my comment below
@kugathasanshanjeeva8537
@kugathasanshanjeeva8537 3 жыл бұрын
Can you please explain me how to connect large number of relay example - 32 / 48 relays to raspberry pi 4 @skiwithpete Thanks in advance
@ninoinreno
@ninoinreno 7 жыл бұрын
Great video!! If I wanted to connect (4) 16 channel SainSmart relays, could a single raspberry pi run all four relays? Thank you!
@xmetrix
@xmetrix 4 жыл бұрын
3 years later nobody answered your question, how sad. yea you could but you would need a way to control 64 pins. think multiplexers. shift registers, etc. it is possible to control hundreds of gpio pins with only a few.
@joshuamontalbano1875
@joshuamontalbano1875 4 жыл бұрын
(yes this is 3 years later but 3 years ago i was not into tech) it is possible using MCP23017 chips with IC2 controlling them, you're in for a long ride if you want 16 individual relays working though its a steep learning curve but there are several tutorials on this chipset
@MERTVRU
@MERTVRU 4 жыл бұрын
Super!
@adiasbr
@adiasbr 7 жыл бұрын
Great project. Useful videos for beginners. Can you explain how safely i work with 110 volts?
@skiwithpete
@skiwithpete 7 жыл бұрын
Take some electrician courses. They're typically offered at local community colleges and you can do the basics in just a couple of hours.
@adiasbr
@adiasbr 7 жыл бұрын
Thank you. I have other question: it´s necessary to use a resistor in each relay?
@AndrewMurphy8383
@AndrewMurphy8383 6 жыл бұрын
I am trying to write a script that would turn on one relay and it stays on while using ur script how would add or mod ur script to leave on one while the others are off if u could help you could give me would welcome
@AndrewMurphy8383
@AndrewMurphy8383 6 жыл бұрын
I am trying to write a script that would turn on one relay and it stays on while using ur script how would add or mod ur script to leave on one while the others are off if u could help you could give me would welcome
@vladagrigoroae1767
@vladagrigoroae1767 Жыл бұрын
super nice video, i got the same relay board but it's either damaged or there is something I cant't get right. I am using an esp32 as controller, but the relays are activated as soon as i connect the board to my esp, no matter if i set the IO high or low. Now the esp32 outputs 3.3 for high ... i suppose the PI outputs 5v. Also i have noticed on your video you are setting the I/O to LOW for the relay to actuate ? ... should it be a HIGH to actuate? Also I noticed on my board that even without the 12v (only 5 v from the esp board) the leds still light up ... the LED should be ipto-isolated from 5v (they are on the 12v circuit) ... is my board broken or there is a flaw in the design of these boards ?
@skiwithpete
@skiwithpete Жыл бұрын
I just had someone else say the same thing on another video. Take a look to see if you can find a recent comment here that mentions the same
@vladagrigoroae1767
@vladagrigoroae1767 Жыл бұрын
@@skiwithpete Found the issue, first of all the board works at 5v so for esp you need a 3v to 5v convertor (there are logical convertors for this). The relays requires a LOW state to activate and a high state to be off. The 3.3v from esp is not enough to be considered HIGH this is why the relay see 3.3v as LOW .. you need 5v to shut them off. Hope this helps other in this situation. After this implementation the integration works perfect
@GregorySchwartzkopf
@GregorySchwartzkopf 4 жыл бұрын
According to Sainsmart the 5v pins are powered by the connected 12v power supply (courtesy 5v power according to them). According to RPi docs the USB power supply also delivers 5v on the RPi 5v pins. Can you explain why you've connected these all together?
@petergosselin1180
@petergosselin1180 4 жыл бұрын
On the 8-channel relays there is a VCC and JD-VCC jumper connection which links pins for the 5V power to the board, to the 5V power for the optocouplers. On the 16 channel, there is no connection linking them. And when powered only 5V there is not sufficient power to run all 16 relays (as you'll find through experimentation). When running on 12V alone, the optocouplers do not trip (as you'll find through experimentation). So it is my assumption that the 12V runs the power for the relays, while the 5V is the power for the optocouplers - though I don't have any documentation to back up this finding.
@GregorySchwartzkopf
@GregorySchwartzkopf Жыл бұрын
@@petergosselin1180 Actually the voltage regulator on the board (LM2576) can supply up to 3A on the 5V rail, which is more than enough to drive the 16 optocouplers and other ICs on the board, and even has power left over to power a small pi (Zero W takes max 370ma). The 12V rail drives the relay coils, and when they're all on it draws a little under 500ma according to my experimentation. You cannot run this board on a 5V supply alone, as it won't drive the relay coils reliably. Furthermore connecting the 5V or 3.3V rail from the Raspberry Pi to the 5V rail on the Sainsmart board as shown in this video (with the USB power attached to the PI) is a bad idea and will likely end up killing the PI, and even if it doesn't it's bad practice. I found a really easy solution to this in the amazon reviews for this board of all places, which I posted in another comment.
@GregorySchwartzkopf
@GregorySchwartzkopf Жыл бұрын
==Credit to AJ in Amazon reviews for this method... it works great and gives you the ability to have led indicators for the relays external to the board. Scripts provided here will work as is== ====DO NOT CONNECT THE POWER PINS TOGETHER ON THE PI AND RELAY BOARD (Unless you are not using a USB to power the PI and want to use the 5v rail on the board to power a low power Pi-- I wouldn't do anything larger than a Zero W as other PIs draw a lot more power)==== For those that need help this is the easiest way to connect them to the Raspberry PI: The relays are triggered on when the pin of the relay is pulled LOW (0) volts. the pins are made for an Arduino but will work with the PI if you connect a 3V LED between the relay board and the PI GND pin on relay board ----------> GND pin on Raspberry PI Relay Board Pin------> LED Anode (Long Wire) / LED Cathode (Short Wire) -------> GPIO of Raspberry PI you will have to do this 16 times. This has the added benefits of; Indicator if relay is supposed to be on to mount in project box side/top (Unused just leave inside) Relays do not trigger ON when rebooting the PI Relays do not trigger ON when PI is off all parts are cheap and comparable with using resistors. How this works: When the LED is used this way it is essentially a device that drops the voltage by 3V. converting any excess power to light. The PI requires 3.3v maximum to its pins. This method reduces the 5v to 2v for the PI. (You can check with a multi-meter) When the PI GPIO is HIGH (ON) there is 3.3v at the PI and 5v at the relay board. Because the LED requires 3v to operate and there is only 1.7v the led does not conduct power and the opto-coupler in the relay board stays deactivated. When the PI GPIO is LOW (off) there is 0v at the PI and 2v at the relay board. Because the PI is forcing the pin low the LED begins to conduct, turning on, The current limiting resistors in the relay board keep the LED from conducting too much power (and burning out) and still provides enough to activate the opto-coupler causing the relay to activate.
@timothyphan3959
@timothyphan3959 6 жыл бұрын
will the Pi have enough 5V power to control two 8-channels relays to make a 16-relays solution?
@xmetrix
@xmetrix 4 жыл бұрын
if you're using relays with external power to trigger the relays you should be fine since the 5v is simply there to trigger the optocoupler to send the external power to energize the relay
@thifabri
@thifabri 6 жыл бұрын
Hi skiwithpete, I followed all steps with all attention, but when I tried to execute wich one code, all relay was activated. Do you know how can I solve it? Thank you and congrats for the great video.
@skiwithpete
@skiwithpete 6 жыл бұрын
Thiago Fabri this is likely caused by a non-optocoupler relay.
@lincqimiq5265
@lincqimiq5265 6 жыл бұрын
Will this work on Mac computer?
@xmetrix
@xmetrix 4 жыл бұрын
Your description links to the 12v version of the relay board. I have the exact same board and these scripts do not work. Can you confirm you have the same board as you linked to because somethings wrong on my end.
@skiwithpete
@skiwithpete 4 жыл бұрын
I just went and looked, and I can confirm that I have the 12V version of this board, exactly as linked, and that I'm powering with a 12V power supply and driving the relays with with the Raspberry Pi.
@xmetrix
@xmetrix 4 жыл бұрын
@@skiwithpete ok thanks for the confirmation. clearly there's an issue with my relay board or difference in raspberry pi's, maybe the rpi a has more driving current than the 3? Either way none of your scripts work for me. I mainly write all my code in javascript and it works fine with my 2 channel 5v relay boards when i have a handful of them connected. Gotta find my multimeter to debug the problem =( Figured i'd just follow someone elses known working code to rule out any issue with my software side.
How many relays can I connect to one Arduino?
9:38
AnotherMaker
Рет қаралды 49 М.
🌊Насколько Глубокий Океан ? #shorts
00:42
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 12 МЛН
Sigma Girl Past #funny #sigma #viral
00:20
CRAZY GREAPA
Рет қаралды 33 МЛН
Tom & Jerry !! 😂😂
00:59
Tibo InShape
Рет қаралды 65 МЛН
The Petabyte Pi Project
22:27
Jeff Geerling
Рет қаралды 2,2 МЛН
DON'T Use Raspberry Pis for Servers! (Use THIS)
16:23
Hardware Haven
Рет қаралды 1 МЛН
RASPBERRY PI - All  About controlling Relay Boards for Home Automation
15:05
The Raspberry Pi Pico WAS Overrated! But that changed!
10:18
GreatScott!
Рет қаралды 595 М.
Try these 16 Brilliant ESP32 projects!!!
11:18
ToP Projects Compilation
Рет қаралды 548 М.
Tag her 🤭💞 #miniphone #smartphone #iphone #samsung #fyp
0:11
Pockify™
Рет қаралды 18 МЛН
ИГРОВОВЫЙ НОУТ ASUS ЗА 57 тысяч
25:33
Ремонтяш
Рет қаралды 336 М.
КРУТОЙ ТЕЛЕФОН
0:16
KINO KAIF
Рет қаралды 2,1 МЛН