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

  Рет қаралды 216,606

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
@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.
@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 :(
@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 :-)
@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!
@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 2 ай бұрын
Is it a real cave or just a basement?
@yvesdev386
@yvesdev386 8 жыл бұрын
This was very informing. keep it up, these are great!
@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!
@Jexjo
@Jexjo 3 жыл бұрын
Exacly what i'm searching for, thank you very much!
@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!
@HuaweiBaru
@HuaweiBaru 6 жыл бұрын
good teacher and this good video for whom need detail instruction ... keep educate
@mohdasifmoulvi3854
@mohdasifmoulvi3854 5 жыл бұрын
thank you i learnt very much from u r videos
@siamakmojdeh
@siamakmojdeh 7 жыл бұрын
Thank you so much for your video. very help helpful.
@louisstacey8060
@louisstacey8060 8 жыл бұрын
thank you so much you make the best pi projects always work thank you so much
@skiwithpete
@skiwithpete 8 жыл бұрын
thanks.
@showmequick2245
@showmequick2245 8 жыл бұрын
This guy is good, Thank you for the video :)
@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!
@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!
@nickwall2288
@nickwall2288 3 жыл бұрын
Awesome thanks for the very helpful video
@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
@bubba1984
@bubba1984 8 жыл бұрын
so are those inputs on the board pulled up to 5v?
@steveg219
@steveg219 8 жыл бұрын
Awesome- really clear and complete, thank you
@isaacfainsod1986
@isaacfainsod1986 6 жыл бұрын
Do you know if I can use a computer power supply (12v cable) to give energy to the relays
@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.
@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.)
@alextadeo8455
@alextadeo8455 7 жыл бұрын
Could i wire up 2 16-channel relays to the Pi's 40 pins?
@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
@sercio994
@sercio994 8 жыл бұрын
Thank you so much! :)
@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?
@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
@caspercorneliuspatontan3645
@caspercorneliuspatontan3645 4 жыл бұрын
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
@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?
@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.
@henryfitzthum7563
@henryfitzthum7563 6 жыл бұрын
Hi do you know if one Can run RGB lights from this relay
@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
@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
@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.
@stevenfrazier7959
@stevenfrazier7959 6 жыл бұрын
Have you done anything with mqtt with any of your relays?
@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.
@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.
@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.
@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
@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
@dvdgmz
@dvdgmz 6 жыл бұрын
Can the raspberry take inputs and translate them into a specific sequence of outputs?
@ValentinScarevnea
@ValentinScarevnea 5 жыл бұрын
Hi, is it necessary to use both 5V pins?
@ahmadtauhid2807
@ahmadtauhid2807 4 жыл бұрын
hi.. it possible to add 8 channel relay again to single raspi board?
@jeremycaudill6916
@jeremycaudill6916 6 жыл бұрын
Any tutorials on what to do with the relay afterwards ?
@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.
@eric_7761
@eric_7761 6 жыл бұрын
I´m curios. Why 12V supply if the realy partnumber says 5vdc? is there a regulator on this board
@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.
@henryfitzthum7563
@henryfitzthum7563 6 жыл бұрын
Hi can one use this relay to control RGB lights
@juanbolivar35
@juanbolivar35 4 жыл бұрын
how do you add a lot more channels to the raspberry?
@RbrtWlkr
@RbrtWlkr 7 жыл бұрын
Why did you need to plug in the 5v if you are taking 12v from the power supply?
@fuzzywuzzy9550
@fuzzywuzzy9550 6 жыл бұрын
would you use a relay and a motor controller
@IstiaqueAhamed
@IstiaqueAhamed 7 жыл бұрын
Can I use 12V, 5A power supply ?
@Brounds24ify
@Brounds24ify 3 жыл бұрын
When I plug my relay all the channels light up, even with out our attached. Can someone help?
@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.
@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.
@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.
@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)?
@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.
@rogerbailey3416
@rogerbailey3416 7 жыл бұрын
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.
@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???
@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.
@josezepeda7396
@josezepeda7396 3 жыл бұрын
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.
@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.
@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
@prakashkumkar7263
@prakashkumkar7263 6 жыл бұрын
hii sir i want arduino uno code for 16 channel relay for my home lighting on and off please help me
@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.
@AndrewMurphy8383
@AndrewMurphy8383 7 жыл бұрын
@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 7 жыл бұрын
Watch my 4 channel relay video to see more script examples
@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?
@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%
@lincqimiq5265
@lincqimiq5265 6 жыл бұрын
Will this work on Mac computer?
@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
@haplomic9616
@haplomic9616 Жыл бұрын
Thanks!
@skiwithpete
@skiwithpete Жыл бұрын
Awesome. Thank YOU
@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
@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.
@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.
@MERTVRU
@MERTVRU 4 жыл бұрын
Super!
@kitajima_e
@kitajima_e 7 жыл бұрын
good project, but its good to stick to color codes especially on the power side
@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???
@timothyphan3959
@timothyphan3959 7 жыл бұрын
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
@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 5 жыл бұрын
I tried using the 3.3v and it destroyed my Pi :(
@yumaxbox
@yumaxbox 7 жыл бұрын
Having a problem, following your great video. Every script i ran turns all the relays on at once and the only way to turn them off is by exiting the script with Ctrl-X Any ideas ?
@yumaxbox
@yumaxbox 7 жыл бұрын
BTW I am using a raspberry pi 3
@yumaxbox
@yumaxbox 7 жыл бұрын
Also, my 12V supply is 2A is that a problem ?
@bobbyhill3740
@bobbyhill3740 7 жыл бұрын
I am having this same issue. Did you find a solution?
@Excess-qn7qh
@Excess-qn7qh 7 жыл бұрын
same for me :( raspberry pi 3
@bobbyhill3740
@bobbyhill3740 7 жыл бұрын
I figured out a solution to this issue. Connect the 5v Constant pins on the Relay to the 3.3v pins on the Raspberry Pi.
@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.
@dmitrijbilalov
@dmitrijbilalov 8 жыл бұрын
Thx!
@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
@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
@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 7 жыл бұрын
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 7 жыл бұрын
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
@ProDesigneHd
@ProDesigneHd 8 жыл бұрын
what wire gauge did you use to connect the channel relay to the power source? For my own project I used 14 awg and was really hard to put in since it was too big
@skiwithpete
@skiwithpete 8 жыл бұрын
+ProDesignHd I'm using just 24AWG for the 12V.
@ProDesigneHd
@ProDesigneHd 8 жыл бұрын
thanks for specifying :)
@ahmedalzayani8883
@ahmedalzayani8883 8 жыл бұрын
+skiwithpete 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 automatically turn on. I'm using the same python code you use it, please any one advise what I should I do Link for the relay I have it www.amazon.com/SainSmart-101-70-103-16-Channel-Relay-Module/dp/B0057OC66U?ie=UTF8&psc=1&redirect=true&ref_=oh_aui_detailpage_o00_s00
@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.
@dbweathe
@dbweathe 8 жыл бұрын
I get that the relay board needs 12v on it's own, but why did you connect the 5v wires and grounds from the pi?
@skiwithpete
@skiwithpete 8 жыл бұрын
+Darren Weatherall without the grounds, the 3v3 of the GPIOs wouldn't flow. The 5V is a different question. I never thought to disconnect that, might be worth a try...
@dbweathe
@dbweathe 8 жыл бұрын
+skiwithpete Thanks for the quick reply. I took another look at my relay (I have the sainsmart ssr 8 channel board), and it's a 5v board with only one power source. I followed your video and everything works great. Thanks, you've helped me get on my way to building my xmas light project.
@CloverGao
@CloverGao 7 жыл бұрын
Hi. I had my raspberry pi 2 connected to a 2 channel relay for a while and yesterday I upgraded to 16 following your tutorial. My raspberry pi shut itself off today and was much warmer than usual. I wasn't sure why so I unplugged the raspberry pi. To my surprise the still had power which made me confused. I googled and I found out its possible to power the raspberry pi through the pins. I used a volt meter to test the two 5 volt pins on the board relay board. With my raspberry pi unplugged and the Relay plugged it, it shows there's 5 volts outputted to the 2 pins. I unplugged the 3.3 volt from the raspberry pi to the board and it works fine for now. If someone else has the time, can they confirm this.
@johnlayman2836
@johnlayman2836 6 жыл бұрын
The sainsmart 16 channel relay board produces its own 5 volt through a transformer. If you hook up 3.3 volt from the Pi, you risk ruining your Pi. Some say it will work without the Pi 3.3 or 5 volt from the Pi. I believe this relay board has been modified since this video was produced.
@adamqwan7628
@adamqwan7628 6 жыл бұрын
This may have happened to me. Pi no longer boots and shows a red LED after switching to the 3.3 pins. Maybe a good warning for others
@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
@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.
@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
@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.
@TheDmussaw
@TheDmussaw 6 жыл бұрын
do you have a script to turn each relay on off from command line
@skiwithpete
@skiwithpete 6 жыл бұрын
TheDmussaw no. You'll need to make that yourself.
@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.
@sahilharit7736
@sahilharit7736 8 жыл бұрын
Can I give my relay ,the 5V power through VCC through any external 5V supply without connecting it to my raspberry pi's 5V GPIO (and ground GPIO)?But only connecting the commanding GPIO between pi and Relay.
@skiwithpete
@skiwithpete 8 жыл бұрын
+Sahil Harit Yes, but you will still need to connect it to the Raspberry Pi's GND as you need the 3V3 from the GPIOs to ground on the Pi.
@sahilharit7736
@sahilharit7736 8 жыл бұрын
+skiwithpete ok, thanks!
@johnisler560
@johnisler560 7 жыл бұрын
HELP I have a problem... I have all the same things as him except when I try to run the code, instead of turning relay 1 on then relay 2, ect, all relays turn on. The code is still saying that it is turning on the relays but they are all on. They are wired the same as his i have checked many times. I need help!!
@Darry86mike
@Darry86mike 6 жыл бұрын
i have same issue. any solution?
@stefanoferri5850
@stefanoferri5850 8 жыл бұрын
Hello, but the links are not to be interfaced with resistors and transistors? I bought: www.sainsmart.com/relay-1/16-channel-12v-relay-module-for-pic-arm-avr-dsp-arduino-msp430-ttl-logic.html The module comes with 5V to raspberry... do not burn? Thanks PS where can I find the instructions to connect raspberry pi 2 B to the 16-channel module relay?
How many relays can I connect to one Arduino?
9:38
AnotherMaker
Рет қаралды 50 М.
Викторина от МАМЫ 🆘 | WICSUR #shorts
00:58
Бискас
Рет қаралды 5 МЛН
ОБЯЗАТЕЛЬНО СОВЕРШАЙТЕ ДОБРО!❤❤❤
00:45
Home automation that's private and local?! (Home Assistant Yellow)
19:49
RASPBERRY PI - All  About controlling Relay Boards for Home Automation
15:05
Try these 16 Brilliant ESP32 projects!!!
11:18
ToP Projects Compilation
Рет қаралды 560 М.
Using Shift Registers to Get UNLIMITED GPIOs for our project !!
12:40
How To Control A Solenoid With A Raspberry Pi Using a Relay
6:15
Core Electronics
Рет қаралды 87 М.
DIY Raspberry Pi Racecar Dashboard: The Ultimate Guide
15:11
BEAVIS Motorsport
Рет қаралды 727 М.
low battery 🪫
0:10
dednahype
Рет қаралды 1,7 МЛН
КРАХ WINDOWS 19 ИЮЛЯ 2024 | ОБЪЯСНЯЕМ
10:04
Хакер взломал компьютер с USB кабеля. Кевин Митник.
0:58
Последний Оплот Безопасности
Рет қаралды 2,3 МЛН