Basic WIFI Controlled Switch Using the Wemos, ESP8266 and a Relay.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
and so checking out the video this is part two where we go over how to install the relay on top of the we mas board if you didn't see part 1 guide and go check that out part 3 we're going to be using a humidity sensor so subscribe so you can see that video when it comes out relays come in all different shapes and sizes a lot of them come in breakout boards which make it very easy to hook things up to and control them a relay is an electrically operated switch most relays use electromagnets to operate the switch these are really popular because you can control a higher voltage with a lower voltage in our case we're going to be controlling 120 volts AC with a 5 volt DC circuit relays were invented in the 1830s or 40s to be used with telegraph the we must relay shield has a normally opened and a normally closed terminal and it's operated using the d1 pin of the we Maas we're going to go ahead and just install the female headers with a longer legs so that we can install our humidity sensor on top of this but also plug this into the we mas board in our case normally open means that the fan is not going to be on until we energize the relay whereas normally closed would mean the fan is always on until we engage the relay which would turn it off here I'm using my soldering iron to draw the solder through to the other side so that the pins are a little bit longer and they'll sit easier in u---mass board you can see right here that it just kind of sucks it right down through once the solder is heated up you kind of just pull the soldering iron down and it draws it right through connecting the boards can be a little tricky you got to line up the pins and they don't always line up perfectly once they're seated in there pretty good if you notice mine still sit a little bit high hook it up and you're ready to go the first thing we want to do this is test to make sure that we have everything soldered correctly and installed correctly and the shield is properly seated we're going to navigate over to github.com slash we mas page and we're going to download the examples to a zip file in a minute we're going to use this zip file to install the example codes for the we mas board in the first video I went over how to install the Arduino IDE install the board and install the drivers for the serial to USB chip if you haven't done all that already stop now and go check that out once the example code is downloaded we want to open up the arduino ide once it's opened up we're going to go to sketch then include library and we're going to add a zip file once we click that we're going to navigate to where we downloaded the example code to in my case it's downloads folder we're going to click on the zip file and open down at the bottom in the debug window you're going to see that has been added successfully now we're going to open up one of those examples we're going to open up the real a shield example we're going to navigate file examples we must be one many examples shields relay shield we're going to use the blink without delay example we are just going to double check to make sure that we have the correct comport and we're going to go ahead and load this onto the win/loss board you'll see down in the debug menu that it's compiling and now it's pushing it over to the board and once it hits 100% or good to go it's always good to run a test code that you know works before using your own code because I had the relay board installed backwards now that we know everything works it's time to write the code so that we can control this over the Wi-Fi what we want to do now is open up a new sketch and delete the pre-written code we're going to copy and paste all that code in so we won't need what's there the code will be in the description on Instructables and on github at the end of each section I'll indicate when to pause and insert the code after I've talked about it in this section we're including the ESP library and some header information it's okay to pause now the next few lines are to declare our SSID which is our Wi-Fi name and our Wi-Fi password we'll come back to this later [Music] these next few lines will tell though we must board your local network information including the IP address that we want the we mas board to take I'll show you where to find this information soon in this next section we're going to include the hoid setup function it's where we initialize variables pin modes and start using libraries right here we're going to setup the relay pin we're going to fold it as an output and we're going to setup our serial communication the code in this next section is going to be connecting us to our Wi-Fi it's going to display a few dot and then once it's connected it's going to give us the IP address to navigate to we are now done with our setup function and are going to move on to our void loop function a void loop function will continue repeatedly until we disconnect power or reset the board in the beginning of this function we test to see what the current status of the relay is or what it should be if this next section looks familiar to you then you know HTML this portion is where we build the webpage with the two links but the code is complete we're going to jump back up to the IP address section we're going to input the correct information for your local network you can find this information very simply going down to network right click network and sharing and then change adapter settings and you want to right click on the local area network you may have more than one here click on the one that you're currently using go to properties then go down to ipv4 you want to copy over subnet mask and default gateway exactly as they are you want to make sure that you select a different IP address than the one in the ipv4 settings this IP address needs to be different than any other device on your network I chose 99 now we're going to edit the name and the password for our Wi-Fi settings SSID is the name of your Wi-Fi and the password is whatever you've made it when we go to compile this code it's going to ask us to save it because we've never saved it before it's useful to make it something interesting or something that you're going to remember I all mine the innovative tom demo after you click Save it's going to start to compile and upload process and once we hit 100% we're going to see over here in the serial terminal that it is connected successfully to my Wi-Fi network and given me an IP address to navigate to once we navigate to that wot IP address in our web browser we can see that the two links pop up now before we do anything with those two links or buttons as I want to call them we need something to control since eventually I'm going to hook this up to a bathroom fan I took this old fan I had lying around and I'm going to hook it up to the relay I started by snipping the wire in half and then stripping both ends I connected two of the ends back together I guess in the end I could have just stripped one side of this wire but since it was glued together it made sense just snip it right now always remember that this is just a test nothing has to be perfect with AC voltage it doesn't matter which wire you choose just as long as you're breaking the connection between one of them on the terminal block the center pin is the common pin so whether you chose to use it normally open or normally closed you're going to connect at least one of them to the center pin the leftmost pin is the normally open so that when we turn on the we MA strip and the relay it is not going to engage the fan it's only going through gage when we tell it to and when we energize the coil the code that we wrote was very simple and will only work if you're on your own Wi-Fi network it works even from your smartphone if you type in the IP address in my case it's 1000 done and we click on it turns the fan on when we click off it turns the fan off and back on I had a lot of fun with that thanks for checking out the video guys I hope you enjoyed it I hope you see how simple it is to get a little Wi-Fi chip and a relay up and running you can hook this up to a light you could rewrite the code to maybe have it momentarily come on when you push the link so that you can close a garage door anything you really think of that you want to control you can control with this and the simple web interface could be modified to be better looking you have any suggestions or anything you saw on the video that you think might be able to be done better let me know in the comments below if you liked this video and you want to see how I add in a humidity sensor hit subscribe that video will be coming out next thanks and take care II
Info
Channel: Makers Mad Lab
Views: 49,514
Rating: undefined out of 5
Keywords: innovativetom, innovative tom, project, ESP8266, Wemos, microcontroller, RF, remote control, electronics, hack, d1 mini, wifi, home automation, automation, cellphone, phone, home, arduino, relay, relays, esp
Id: i6sZ_leNkJo
Channel Id: undefined
Length: 9min 56sec (596 seconds)
Published: Mon Apr 24 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.