DIY Smart Switch - Part 1 how to use a relay

Published 2017-05-14
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.

All Comments (21)
  • 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 YouTube.
  • 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.
  • I saw about 5 videos on YouTube 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!
  • @Poolboy28560
    Everyone on Youtube 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.
  • Thank you, I was looking for information on how to connect the AC side of the relay, and you covered it perfectly.
  • @aboulfoof
    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!!
  • @misterspot3470
    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.
  • @sirmaverickrock
    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.
  • Awesome video man. Thank you so much. Taking your time to explain to this level of detail is highly appreciated.
  • @colorpanda8409
    Great video! How do you make the 5-volt source in your box?
  • @vigi86
    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
  • @WVelasco9977
    Thank you! I’ve just found your Chanel and I’m ready to learn more from you.
  • @jaywhited1174
    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!
  • @AllanKobelansky
    “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.
  • @smileykneez
    Very organized and well-presented information. Very useful. Great job!
  • @huhocheung15
    Clear to understand. Great compared with many others.
  • @dan2thi
    Very clear explanation! Thank you!
  • @cottondai
    Awesome tip and clear tutorial. Thank you.
  • @AntoniaWarren
    A really good video here. Very clear and easy to understand.