DIY Smart Switch - Part 1 how to use a relay
ฝัง
- เผยแพร่เมื่อ 6 ก.พ. 2025
- In this video series I'm going to show you how to get started in home automation with a simple project that will allow you to control your lights and other devices in your house.
One popular home automation project that many people start with is controlling their lights. There is a great satisfaction that comes from being able to control a light using your own electronics and code. However a major roadblock for many people is the realization that they have to work with mains voltage which can be dangerous if you don't know what your doing. In reality learning how to safely work with the high voltage an high current electricity in your house is not as difficult as you may think. If you aren't comfortable with how the electricity in your house works, I encourage you to spend a few minutes researching the topic on the internet. Make sure you are getting your information from reputable sources. In a future video I'll show you how to control lights and appliances in your house without having to mess with high voltage electricity. It's a pretty neat little trick and I'm excited to share it with you.
There are several ways you could tackle the problem of controlling a light in your house. The first, and definitely most popular approach to this problem is using a relay to switch the voltage on and off. The lights in your house are connected to a mechanical switch on the wall that you have to toggle on/off with your hand. A relay does the same thing as the switch on the wall, except that instead of toggling the switch on/off with your hand, you can do it with low voltage and low current electricity. You can buy relays from places like Amazon, eBay, Adafruit, or sparkfun. If you don't mind waiting a few weeks, eBay is by far the cheapest place to get them. I recommend getting one that's soldered to a breakout board. You can get them with single relays, or some come with 2, 4 and even 8 channels of relays. I'm going to use this board with 2 relays, even though I'm only going to be using one of the channels.
Huge thanks to my *channel members* who make these videos possible. If you want to support what I do and get access to free project files, an awesome discord community, and much more, head over to *www.patreon.com/bytesizedengineering* or click the *join* button here on TH-cam.
Just one issue, as seen at @4:35 those black wire leads have too much insulation removed, either not in far enough or need trimming so that bare copper is not exposed.
Everyone on TH-cam talked about "the signal". I kept thinking it was 5V+, which of course didn't work at all. THANK YOU for the minor detail about it being COMMON or GROUND! NOW MY CIRCUIT WORKS!!!! Thanks again. Now subscribed and I will be back.
I saw about 5 videos on TH-cam about relays and understood nothing! But, this video helped me understand relays completely! It's so easy for me now! Thanks for all the info!
The Reviewologists should have watched greatscott’s video
Exactly!
Watch this then : th-cam.com/video/uniaiJmSch0/w-d-xo.html
So humble... "I'm not claiming to be an expert in this topic [...] but I did work as an electritian and I do have a degree in electrical engineering". Dude, you're a PRO... lol
Victor Fernandez did
He's not very professional for being a pro he has stripped way too much wire going into the relay leaving high voltage exposed ...
Being a electrical engineer and a electrician are different fields. Smart people though
Thank you so much. There are a ton of videos, when you search for pi relay, that cover the "connecting it to the pi and writing code to control it" angle, but this (after tons of searching) is the first one that actually covered the other side of things.
“wire nuts” -> marrettes. Also the live wire and the neutral were really close together attached to the relay. Use heat-shrink tubing as a best practice.
ME? - I JUST USE GUM!!! :P
maybe do it properly with wire bootlaces. The way you have shown is just not safe.
It’s 2 years later. Your video was well done. And you could have complicated matters by following my advice. But keeping it simple was the right direction.
This video is ok but your t-shirt is the best!
The world's best teacher
That is way too generous, but thank you
This video is probably the best explanation you can find on TH-cam. Clear and straight forward. Million likes!!
Thank you! That means a lot! I appreciate your feedback!
@@bytesizedengineering is it possible to connect the two relays in such a way that when powered the Normally open will close and the other one will open which is normally closed? What I am saying let us suppose we have two power connected to two relays from two different sources, How can they be connected or wired in such a way if possible that when one power is on the other one is off? Think about it , seems a good project if it can be done?
I didnt understand this video very good, so what kind of relay do you need to use for a wired magnetic window switch, to turn off and on the air conditioner when window opens or closes. AC 3000w. Thank you, best regards
So i ordered the one with 4 relays, connected it to my centralised electric space heater, one is for a water pump and other 3 are for heaters, every heater is 8 KW, i was not sure how powerful these relays out so i used theme to activate and deactiate existing 40KW relays inside the heater, i used the rpi4 1gb bc it has a poe gigabit port, slapped in a 16GB U10 card, i brought the poe enabled gigabit cat6 cable to the heater, tempreture dial was already connected to the main home server, installed Pihole on that pi to and just ordered the case with a fan from aliexpress, i made a quick app (i am a java developer) and voila now i dont need to go down to the basement to turn on or of the heater, although on all of the pcs i have made a small java gui for that, i am planing to make my whole house smart using raspberry pis
Interesting. I'm new to these relaying thingy.. I saw the relay you using stated 5v. Can it be use with 120v? Am I missing or skipping something here?
There are basically two power types used here one for controlling the relay (in this case 5v) and one for usage (in this case 120v) you control with the 5v when the 120v are aviable for the lamp hope i could help
Great video! How do you make the 5-volt source in your box?
I have a question I would like to ask you..I certainly hope you will respond. Every one talk about relays and 12 volt or 5 volts DC current , but no one talks about AC current. ...Question: i have an eletric front door lock in my house..it is actually a patio metal door to the street. The intercom connected to it is about 40 meters away upstairs on the 3rd floor apt. I purchased a cheap kit. one phone one front door bell...It comes with the transfomer inside the phone unit. 110 AC to 12 volts AC, The 12 volt AC output has to travel the 40 meter span to the lock. It drops tension...and the lock fails to open..is erratic, sometimes it work and others dont...By the way the cable used is CAT5. i found out there are 2 ways of correcting this issue; 1) is to replace the cable with a twin pair gauge 16 for the lock ..and keep using cat5 for the bell communicator. 2) is to add a relay and another transformer near the door..Here is the tricky part.. the relays on the input part operate at 5 and 12 volts DC and can output 10A 125 volts AC..CORRECT ?? I need to basically design a circuit that would behave the way i want it.. So how you i go about doing this...Should I use one of those modules with a rectifier bridge so i can convert ac to Dc on the input side...and have the 12 volts AC on the out put side ??....Your ideas will be greatly appreciated..Thanks in advance....
I have 1 of the 5dcv to 110 relays. I'm trying to create a Poe using Bluetooth. I was hoping that my signal lead would come from my BT signal as my connection is made to the BT Device?? Your saying ground is signal. So do you know a a way to make the relay activate from a BT receiver board?
Awesome video man. Thank you so much. Taking your time to explain to this level of detail is highly appreciated.
Thank you! And Thank you for taking the time to comment!
@@bytesizedengineering Can I control load of max 15 amps under 12 volt DC as along as it maintains the same output power rating?? Example Say, 20 Amp, under 12 v dc, power 240 watt as against the rated 10 Amp X 24 v of same 240 watt, or 15 amp, 12 volt....!!??? I'm really confused with these power and current. Awaiting clear concept. Thanks.
If you want to control the power of higher voltage equipment like servers and even lights I like using an Intelligent APC (7800 or 7900) PDU over a network with fence_apc installed on a Linux device. That's for anyone who might actually have a need for that. That way you can use your GPIO pins for things like sensors, etc, etc.
Well done!! Excellent easy explanation, was looking forever for a simple explanation of using the SRD-05VDC-SL-C 1 relay module with a push button without arduino, was finally able to understand the input connection of the relay thanks to your explanation and video, thank you!!
Best explanation found so far. Any good reply would be appreciated for the following questions in regards to connections.
For the load, or black wires, I presume the connections on the module for the current would enter on the NO, and feed the lamp through the COM. Or does it matter?
So to properly connect the active magnet, I would presume COM would connect to DC-, while NO would go to IN on the module.
I already connected 12V LED lights using relays and now trying to use this different type of relay for a closet light triggered by magnets.
In the 12V schematics for LED strips, the NO on the module loops back to DC-, which becomes impossible with 120 volts.
As for the exposed wires. If they would touch, then the module would be defeated and the lamp would stay on. The issue is that if they barely touch, arcing could happen and this is considered a very serious issue.
Clear to understand. Great compared with many others.
Sir can u help me to complete my fun home project please the topic is very relevant to your understandings and expertise
Thanks for the video. I have an emylo relay, but I was afraid to hook up 120v to the small terminals. I'm good to go now. Thanks again!
Will this same process work to turn off a dehumidifier should a little giant condensation pump fail? I’m assuming a larger relay would be needed, but the process would be the same?
Thank you, I was looking for information on how to connect the AC side of the relay, and you covered it perfectly.
Thanks for the video , please tell which relay should be used for 15amp appliances like gizzer fridge, please give the detailed name of relay,, thank you
Thank you for your video
I have one qustion please
why you didn't connected the signal to the positive 5 volt?
If you split the signal wire and place them in the twee middle pins. Would that switch both relays at the same time?
Awesome tip and clear tutorial. Thank you.
I love the way you explained everything. The cameras were perfect. If you ever have time to do the same with your auto switch, that would be awesome.
You shouldnt have so much of the bare copper sitting out of the relay, if they only slightly touch all current will flow through the small surface area making it heat up and most likely cause a fire, and the circuit breaker will not trip to prevent it
exactly my thought!
@@therealb888 ^
4:38 in case somebody is wondering. but yeah, that is super dangerous!!
@@gene_Code ur the man!
Good lord yes XD literally the worst thing to show people that exposed copper is okay!
Good explanation, easy to understand. Thanks
Hi
I've got a question when you connect the 2 black wires why don't you use the other port.
And what the other port for
Sorry I'm new to this
Hi! What is the circuit already connected to the board in minute 5:00? and You mentioned that do no t connect to a fridge or vacuum cleaner, but can I connect it to my automatic door motor?
I want to control several 12v lighting circuits and I'm looking at multi channel relay boards. They all have only one power input. Does that put all my devices on one power supply, because you could get up to 10 amps pretty quickly!
very detailed info, thasnks a lot! this is what i was searching
Great explanation and also showing.. well done
Hi, what kind of switch can you use for signal? Push button switch works?
Man, I did not understand it why the signal connector should be ground to get the relay activated? To activate the relay, shouldn't we apply 5 VDC to activate its coil? Your clarification is much appreciated... Thanks for your very helpful and useful training videos
There is usually a transistor that drives the coil. Depending on what type of transistor (N channel, P channel, NPN, PNP) will determine which logic level turns on the relay. This particular module has active low logic which means you ground the control signal to turn on the relay. Hope this helps!
I have a question. Why cut the other two cables if we were going to reconnect them regardless?
I need your help regarding relay. I want to rotate motor one cycle clock wise and one cycle anti clockwise. Yousing 24 volt/4amps adaptor.
When handling your signal wire like shown @6:40 make sure you are isolated and have no connection to ground. Otherwise you will close the circuit by just touching the exposed part of the signal wire and potentially hurt yourself.
I recommend to use a button on the breadboard to test your relay and not do what is shown in this video!
Very clear explanation! Thank you!
Just to remind you, HIGH voltage is voltages above 999 volts. LOW voltage is 999 and below. Here in Sweden we also have something called "Klenspänning" which is a specific voltage below 50 volts which is suitable for toys because it's safer.
Nice. For me high voltage is anything I'm afraid of touching for fear of getting zapped!
@@bytesizedengineering hahah good answer! It's a correct way to treat electricity
I really wonder if it replace 110acv with 12dcv battery then is it possible to control 12volt electronic devices?
Thank you so much! You’re a great teacher wish I could have you for ever question
Thanks for watching! Good luck!
Please share the link in which you electronically activate the relay
Hi Zach, there is an issue that is worth exploring. It is cool to have a relay but if you have other people using the appliance can we have 2 switching options? This mean a person can either switch it on using the normal unmodified way and also an option to use a relay that is triggered by electronics. Otherwise it will be annoying to people who is standing next to the appliance who could just flip a normal switch but you will tell them to do some other routine 🤦🏻♂️
Yes you could easily do this by having a manual switch in parallel with a relay, however the manual switch would act as a relay override switch, the relay would not function again until the manual override switch had been turned off. A solution could be to use impulse/rocker switch connected to a latching relay
Thanks for the video. Good stuff. One minor suggestion; ditch the music or turn it down. It is really distracting and got pretty annoying pretty quick.
Thanks for the feedback! I'm still learning how to make/edit these videos.
Very nice video, helped a lot!
Im confuse how do you control it then ? Do you have to keep turning it on manually?
Using the jumper cable on the breadboard. You connect the small cable when illumination is required. Note: If you have children I would recommend they ask an adult to make the connection(s) when needed (you may also provide a battery-powered torch nearby - affix torch to the lamp base using #18 twine,or similar).
Question: should i control neutral wire or the live wire with relay?
hi sir, normally the refrigerator draws 6A amps to 9A so will it be safe to use this relay if the device draws maximum of 9A given that relay has a rating of 10A.
That's pushing it too close. They make relays rated for much higher current.
In fairness, your experience as an electrician years ago is a far greater indication of your knowledge in this subject. My dad is an extraordinarily accomplished principal electrical engineer and probably the smartest person I know... but probably couldn't use a multimeter if his life depended on it
Why do you connect neutral and ground together?
Can I control load of max 15 amps under 12 volt DC as along as it maintains the same output power rating?? Example Say, 20 Amp, under 12 v dc, power 240 watt as against the rated 10 Amp X 24 v of same 240 watt, or 15 amp, 12 volt....!!??? I'm really confused with these power and current. Awaiting clear concept. Thanks.
I would read the datasheet of the relay you have. If you don't have the datasheet find something similar on Digi-Key and read through the datasheet.
Hi Zach, how can I get one of those ‘I’m an engineer’ T-shirt’s like your wearing? I’m always saying that exact phrase to my wife, a T-shirt like yours would say it even better!
I'm not sure. My sister got it for me when I graduated from school
Very nicely explained
While impossible to predict,how someone will hear instructions, but at least one though you neat to connect the ends safety ground, and together when slicing that extention cord. When you meant to reconnect green to green, and reconnect white, white. I suggest eliminating the background music. Respectfully adds no value your production, and could interfere with your talk through. The only time I could hear the relay with you con controllin the tesk lamp. This would have been good place to inform your veiwers that low voltage conductors should be separated from the high voltage conductors, in a real world installation. BTW; this video found it's way to Facebook after someone link to it in a technical forum. I will subscribe, and keep an eye out for your follow up vids in your series.
"I am an engineer. To save time let's just assume I am never wrong."
I knew a Civil Engineer who insisted that 220 volts was the same as three phase.
He absolutely INSISTED that he was right because he had a CE degree.
Sometimes I wondered if he really did have a degree or if he lied about it.
Engineers are wrong all the time! Myself included!
I have a two channel relay and i am using it with the arudino board for my project when i give a low signal the relay starts and when i give a high signal the realy turns off why is that so need help
Great video, cheers mate! Also, 10amps seems *plenty* for a fridge :-)
My 6' tall Bosch fridge is 90W, which at the 220V we have here, and with P=VI, is half an amp.
Yup. Mind you, I can’t see why you would want to turn off the fridge with a switch, sensor, wifi etc 🤔
Which end of black wires connected to the common and normally open terminal. The one to the wall is normally open and to the lamp is common? Thank you
In this configuration it doesn't really matter. Since the wall wire is the one we're switching, I would connect that to common, and the lamp to normally open. It will work just fine if you have them the other way.
Hello , this vedio was very helpful , thank you. However what is the equipment connected to lower end ofyour breadboard?
I think you're asking about the breadboard power supply.
Could you tell me if there is a "touch activated" relay available? I'm talking like a bug touching it. It's something fairly unique I am inventing and can't seem to find something like this. Great video also! I enjoyed watching them.
Look into capacitive touch sensors.
Can you set it to turn on using 5V instead of ground if you change the position of that yellow jumper so that it connects Vcc and Gnd instead of VCC and JDVcc?
You sure can
the relay has this rating
10a 30vdc 10a
does this rating can apply on dc load too?
Very organized and well-presented information. Very useful. Great job!
It is quite clear that you know what you are talking about and your explanation was first rate. Unfortunately, your choice of background music was not pleasant. I hope you take this bit of criticism in the same spirit I am giving it. thanks.
Thanks for the feedback.
I am not an electrician, but from what I understand you should never connect the ground and the neutral together except at the main service panel. The neutral has a returning current and if the ground is connected to the neutral the ground wire will be live too.
THX, just working with a 2 realy module and I was doing something wrong, you told me what :D
I know only an idiot like me could interpret it in this way, but in the hope this comment helps someone. At 03:02 he says connect the ground and neutral wires together - and I know if you watch closely he shown ground to ground and neutral to neutral in the video but just for clarity he means ground to ground and neutral to neutral - not as could potentially be interpreted as connecting ground and neutral together!
A really good video here. Very clear and easy to understand.
Thanks +Antonia Warren
Hey can you help me. I want to make a tv that turns off when people come over to look at it.. Do i use normally closed? Will.it.open when coms? I want it so people in a gallery see a screen with a video feed and come over but a motion sensor turns it off when they are near. Thanks if you can put me on the right tracking without using arduino
That sounds like a cool project! I see that you found my other video showing the PIR motion sensor. I would start with something like that and connect it to the normally closed terminal. Good luck!
thank you sir i was able to successfully make a relay switch that powers a space heater and a humidifier.
Glad to hear!
f you can please solve this problem.
i have a toy. at the time of starting o or opening it flash light 3 time.
now, my ask is. how to get that 3 or 4 or 5 time flash? i want to make a thing where i need that system.
Thank you! I’ve just found your Chanel and I’m ready to learn more from you.
Can you send link where you buy the multimeter😁😁
How do I modify a 12V 433MHz wireless remote control switch relay receiver and transmitter? Someone in the area (neighbor) is using the same frequency.
I'm not sure I can help. Sorry.
Would a relay work for smaller voltages. If I was needing 12 volts in and a smaller voltage out could I put a resistor for the amount of voltage that I need coming out? Is there an easier way of doing that that or would a relay work? Also how would I go about hooking a toggle switch like a light switch to make it to where if I turn it on or off it turns the device on and off. Any help would be appreciated. Thanks
I'm unclear on what you are trying to do. A little more information would be helpful.
can a 5 volts power supply work as well and a breadboard power supply? you know. the kind you use to charge a cell phone? or better yet , a usb 2.0 connected to a pc?
Yes, any 5V supply will work
fantastic. Thank you
thank you very much. very carefully explanation
How schematic will be look like if I still want control light by switch and relay?
I have a power supply for the DC motor on my Sherline miniature lathe with a relay like this. I overloaded the motor the other day turning some difficult material, and it shut down the power supply.
It happened a couple more times, before I could get finished with the piece, and now the motor doesn't run.
I could hear a relay click when this happened, and thought it was a circuit breaker in the power supply. Now, I have it open, and can't find a circuit breaker. I do find a Songle SRD-05vdc-SL-C relay.
It is obviously not clicking, as it should. I've read about relays with overload protection, but it doesn't appear this is such a relay. Could it still have functioned as an overload? And could it have died in my 'adventures'?
Thanks, for any help. I know enough to get me in over my head, but not enough to dig myself out.
GeoD
Triacs are another solution to home automation and controlling AC loads
There’s SSR too!
Hello I have a question. I have the sonoff 4ch pro 2 and have connected to my garage door. now I want a back report via a switch on my phone app that is possible.
I can't see if the door is open or closed on my phone
Has any of the relay ever short or malfunction while you get the wires connected ?
Shouldn’t be powered while working on it
@@GeneralRozcoe Thanks. Just curious as I almost got my fingers burnt at one time (with the power on) 😓
I will recommend using wire ferrules on the end of wires. be safe and happy when u r playing with high voltage
Thanks for the feedback
i have an electronic device that has a 56 volt battery with max of 20 amps. I am trying to add a second battery to the equation so that I can switch between battery 1 and battery 2. i would like the switch to be as small as possible. it could be manual or Bluetooth. any suggestions?
no suggestions, sorry
What that yellow jumper does?
As a student taking ECET, I HIGHLY recommend not to use a cord to connect to the lamp like in the video. Some of the copper wires could still be exposed and when touched can be very fatal. I suggest buying a GFCI outlet, then encasing the outlet and the relay in an outlet box.
Thanks for the tips!
Makes sense... btw what's the difference between fatal and very fatal? One kills you and the other? Is it like being pregnant and very pregnant? (just pulling your leg a bit...)
look at it from this angle - you can be pregnant with one fetus and you can be pregnant with 3 of them. then you are "very pregnant" , especially at later stages :)
@@mmca2 lol
What kind of control signal you gave to the breadboard. I didn't get that? WHat you did on the bread board side?
I was swapping the relay's input pin between 5V and Ground to turn on/off the relay
Hi I like this innovation and how well you create your videos. So easy to learn from them. Question. How secure is this setup? Can any1 with the app just come within a distance of 50M to my house and turn on my lights, turn on my blender and turn my TV off while I am watching Black Panther?
I think you might be referring to my sonoff switch video? The device is connected to your wifi router which should have some sort of encryption. You would need to look into that more though.
Isn’t it possible to just use the relay in the outlet instead of buying an extender and if so isn’t it dangerous that right?
im corrently working on a related project,and i have just one doubt. instead of the breadboard power supply,can i use a 9v battery,if yes how? please respond asap
You can use a different power supply
Is the output dc ?
Question for you. I’m trying ontrol a linear actuator so I can just retract the actuator when turned off and then extend the actuator when turned off? I am trying to control a door to open and close. Can I use a relay and can I make it wireless with Alexa or Google? Thanks.
Sounds like a great project, I believe I answered your personal message in my inbox.
Hey, i have question, can i use this to wire the intercom indoor unit, in order to open the gate of the building?
I wouldn't recommend tampering with property you don't own.
Great video! Do you have a video on how to use a relay to open/close an electric DC 12V valve? I assume you need a two-channel relay to set the reverse polarity? Thanks again for the video
A solinoid is usually used in irrigation
Why not control the neutral wire with the relais to avoid high voltage on the relais? (i'm a hobby engineer only)
Thanks for the vid! How could I use a 5V relay to get dry contact output?
The NC, C, and NO terminals will be dry.