ESP8366 Arduino project with Alexa | ESP8266 ESP-12E | Tutorial # 4

Alexa turn on office lights, okay, Alexa turn off office lights Okay, Alexa turn on kitchen lights Okay, hey, what’s up messer Malik here welcome to another home automation iot. Tutorial in this tutorial We will be programming in ESP8266 ESP-12E chip I will add all the links and get a project linked in the video details below So I want to recognize this guy. I hope I’m pronouncing the name right KokoPapa All the code that I’m using for this project is based on this project with little bit modifications So thanks to him Creating this emulator for a remote switch So let’s look at the components are required for this project We need Amazon Dot or Echo We need FTDI USB to TTL converter Mini UsB cable breadboard assorted breadboard wires ESp8266 Esp 12 e board soldiering iron and resin core a mechanical relay a Solid-State relay and A prototype PCb board so this project requires a little bit of soldiering if you using this chip But if you have a version with the programmer, then you no need to do soldiering so if you have one of these boards or similar board Then you don’t need to do soldiering so let’s look at the cost of the total project so serial converter Is about $2, ESp8266? six version Twelve is three dollar Solid State relay about four and a half dollar dollar fifty for mechanical relay dollar fifty for breadboard wires and a dollar fifty for PCb Board Total cost is $14 for this project. So let’s look at the steps Install and setup adrenal Ide. I’m now going to do this in this tutorial. You can watch my Tutorial one for this series that shows you a detail Step-By-step how to install and setup Arduino Ide for ESP8266 Solder, ESP8266 Version Twelve board to a PCb board if you’re using a development board then you can skip this step Connect the FtDI converter Board to the Sb 80 to 66 Flash ESp board using Arduino Ide click mechanical and solid state relays to ESp Board power up the ESp and relay boards control both relays with your voice commands using the Lexa so let’s look at how to connect your FtDI Board to ESp8266 Board So you can see on the layout on the both boards. They’re labeled so if you look at the FTDI board We have the very bottom pin is ground you skip one pin, and then the the second pin from the bottom is 3.3 volts and then the fourth pin is Tx and V is Rx so we’re going to be using these four pins to connect our ESp board so basically Your Rx connects to your Tx pin on the ESp board and the Tx connects to Rx 3.3 Walls will be connected to VCC and EN and on the ESP board and the ground will be connected to ground of the ESP and GPIO15 to put the ESP Board into the flash board we’ll need to connect GPIO0 To ground before we boot the board. Let’s take a look at the wiring diagram first we need to connect tx 2 Rx From Esp to FTDI board then we need to connect

Rx to Tx We only need these two connections when we need to flash the chip next We need to connect en in VCC Which is a pin 3 and pin 8 to 3.3 volts then we need to connect to Gpio 15 in ground to the ground or negative So before we boot the board we need to make sure we connect Gpio 0 to the ground This is to put the chip in the flash mode if you don’t do that You won’t be able to flash your program into the chip so next let’s look at the wiring both relays to the ESp board so the way that both relays are connected is a little bit different if You can see on the solid state relays there’s only two connections positive positive and negative Mechanical relay has three connections there negative positive and a signal pen so to connect the two connected mechanical relay we need to connect the S-Pen or the signal pin to Gpio 16 I’m using Gpio 16 and 14 for this project and for Solid State relay you’ll connect the positive terminal to the GPIO14 very simple and the negative will go into the ground and this negative and positive will go to the ground and 3.3 volt so the difference in the both relays is the mechanical relay will the hitter sound in there? And it’s rated up to it’s rated for 10 amp up to 250 volts on the other hand this relay solid state relay is a can be operated from three to Thirty two bolts DC and It’s rated up to 380 Volts 40 amps, so This can drive a lot more a lot bigger. Load than this relay, so everything put together. This is how it looks? So this is my set up and we’ll walk through this step by step connect everything so I want to explain few things here so if you take a look at it, I will supply the 3.3 volts here positive negative and I’ll use this To power up everything so if you look at the relay negative goes into the negative positive goes to the positive doesn’t matter where you connect it and the signal one goes to the GPIO16 So if you count one two three the fourth one is from the top Its Gpio 16, so this is a pin one. This is pin, two three four the fourth one is GPIO16 on the Solid State Relay I connect the positive terminal to the GPIO14 which is the From the top one two three four five and then the ground goes into the ground To power up the ESp board I’m connecting the last pin on the bottom to the positive so this pin right there it goes to the positive and This pin last one is a ground and that gets connected to the negative These are only these two connectors are only connected when we want to flash the board so the Tx goes to our x to your FTDI board and Then our x goes to your tx FTDI Board, so one more thing I would like to mention I connected the EN pin, right here pin 3 and 3.3 volt VCC. They’re connected through a wire underneath. It makes it simple to power up the board and lets wiring needed on a breadboard and also the ground pin on the board is connected Underneath the Board with the Gpio 15 pin. Which is 16 and 15 both are connected and When I want to flash it what I do is

unplug the power and then with tweezers I’ll connect the the ground Pin 15 To d the fourth pin right here from the bottom which is GPio 0 or pin 18 I just short them and then power up and then let it go and The Board is the chip is in the flash mode and I can flash it so I will talk about the board since the board the size and them in the pen size is and Not meant for the breadboard so it’s really difficult. I tried to solder the board directly using the Breadboard wires, but it’s very messy, so I created this a little jig Even take me much time like 15 20 minutes to sort or up the whole thing so it You need to centimeter pins Connected here and to the the breadboard sawyer to the breadboard This is not solder because I have multiple Boards that I need to program so I needed something quick so I can pop this out pop one back in the air and program it and a player on with it The rest I use that two point five Centimeter pins underneath this PCb board which you know it’s a pretty nice So here the things were going to need for this project, so let’s look at this jig that I just created It’s pretty simple and easy it actually if you look at it. Just pops out easily I just have to be careful not to mess up the these pins, so if you can look at these pins, they’re a little bit on the angle, so it makes a Good connect with this board This board is pretty small it’s uh So these pins right here They don’t take the standard big pins the 2.5 millimeter And it’s not Bred for breadboard Friendly Let me just put this in so this is how it gets put in so you basically it’s pretty easy to So line up one side like this, so once it’s lined up on the other side if you look at it it’s a little bit of Off so you just kind of like press it press the board on the sideways Like push it on this side push it on on this side, and it will just pop in Like that so now it makes a very good connect you don’t need to wiggle it to get it good connection and It’s pretty nice so so the the one thing that I want to mention is to minimize the wiring on this because This is pin one from this and then kelp down so the third pin from this is the en pin that requires a positive voltage and also the the wreck The the pin eight needs a 3.3 volts. So what I did is I connected so instead of you know wiring it every time I just connected to a small wire underneath it underneath the board so you can see it, so If you take a look at it, just took a tiny wire and connect it to this one, so it doesn’t matter which one Gets powered up they both get 3.3 volts so on the other hand to power up this board you need a Ground connected onto the pin 15 and also the I’m sorry yeah, the ground connected to the pin 15 and also so also the Gpio 15 which is pin 16 It needs the ground So they’re connected from underneath the board if you look at it They’re kind of like I put a small wire and solder them together right there I don’t know if you can see it clearly mount let me see Yeah, so right there these are Together so that’s it so underneath it this en 2 3 BCC, and these two it’s just hard wire and

You’re done. So this way when you just give it a voltage three point three on this pin Or this pin. They both get powered up and then ground These both are ground and to put it in a flash mode before you power up You need to make sure that you connect Gpio zero which is pin 18 on This right here this pin needs to be connected to ground to flash it. So what I usually do is I Just kind of like grab these two pins like this with my tweezers and And power it up, and then let it go and I’m go to them in the flash mode, and you just flash it So that’s pretty easy okay, so we’re going to wire this thing up now so I’m going to just connect this to the breadboard goes in like this, easily and Next I’m going to do is take the fTDI board and So basically and the pins are the first one is ground the third pin is the 3.3 volt VCC. Make sure this is Jumper wire set to 3.3 volt not five Because you can switch this over here if you connect it to the first one and the second one and will be 5 volts So and then this one is a Tx and then the second last pin from the left is they are expain so if you look at the Wires so the black one is going to go to- my red is positive the Brown or whatever the color is it’s Tx and that needs to go into our x on the eSp and This is the Rx that goes through the Tx or the ESp board so let’s connect this So you take a look at it? So I’m going to see if I could put it on there We go and connect these wires so the black one goes to ground So I’m going to put that there supply the ground and this is for the positive Volts, so this is this step is to flash it So I’m providing the negative and positive to the whole rows here so I can hook and hook them up and connect them so now we know the first first wire on this is our x the white one and this second one the brown one is t x so the white one goes into The white one is going to go into this Connector right here next to this one because this is a Tx and this is our x So then we put the white wire here and the Brown here So we’re going to connect that Okay, so we’re good with this this is and this is going to hook up to your PC to flash it So for this wiring to do hook this board to the breadboard. We’re good here So once we’re done programming it we can unplug these two and then we’re good. So next what I did is to provide a 3.3 volts to the ESp Board I Cut this little wire It’s easier because if there is the regular wires it kind of makes it messy and clutter, so it’s harder to Understand which wire goes where? So I’m going to connect this to the 3.3 volt pen on the ESp Board so basically If I can see it through the camera, it’s a little hard sometimes Yep, like that. You just press it it and you can see this is connected So you can see this 3.3. Volt is connected to the positive. Which is this positive in this row? And then it’s also because underneath ik I connected it to a wire to the en pin So they’re both are going to get 3.3 volts

so next for the negative I Cut up at this short little wire so it’s easy to see where we’re connecting the wires So I’m going to connect this to here the ground pin for the ESp Board and Then I’m going to connect this to the negative Role right there so from the FTDI. There is a negative Coming from this row so that gets connected to the negative So that’s up. That’s powering up the ESp board and Let’s hook it up and flash it So I’m going to connect this it’s not connected to the computer yet So as I told you when I’m going to power up I’m going just going to grab these two wires and short them right there. I mean you can put a switch here, I Didn’t do it because then all more wires and makes it more complicated So I want people to I know follow through the tutorial in a visually it’s it’s you know easy to follow So before I connected to the computer. I’m going to Twitter’s, I’m going to short these and then let them go once it’s powered up So let’s take a look at it. Let’s do that So to upload the program We open up We open up the reno ide open up the project that you downloaded from github few things you need to change here the very first thing is this ssid you need to make sure you put in your access point, or Wi-Fi router name here Make sure you connect it to 2.4 gigahertz router. It doesn’t work with 5 gigahertz Um in here you put in a password For your router and you need to make sure That you connect to the same network Amazon Echo, or dot is connected to also? I’m using I’m using GpIo 16 and Gpio 14 on esp An ESp version 12a board so you can change it if you need to use different pins To flash the board you need to go first and make sure you select the node McU version 1.0 Esp 12v module you select that and then whatever port you have you select the port? and basically from there on once you put your board in the flash mode you can you know upload flash it and then it’s going to compile and we can wait and So I’m going to show you guys something. I actually Didn’t connect the positive wire correctly So the positive wire was connected on a wrong Slot in here on a wrong pin. So you fixed it moved it here So I’m going to put the chip in a flash mode again and try to upload the frame where again Let’s click and upload it’s compiling and it should upload shortly And you should see the led blinking on the board So as you can see the led is blinking on ESp Board So it is flashing So once it’s completed hundred percent. I will remove the are xTx pins Going to also open up this the serial console, and once it’s latched its going to show you the IP address of your

The Esp Board at this point it is connected to your network So while you’re flashing the ESp board open up? this serial monitor And you should see a similar output from your board and this tells you you know that It is connecting to this your network now. It’s a connecting to your router and it opens the IP address that means it’s on the network and the rest of the information for the board So once this is connected so basically now. What are we going to do is we’re going to unplug the Rx and Tx the communication wires and then hook up the relays and Ask Alexa to discover the device even before you actually do that. Let’s hook up Alexa and then ask it so um while you’re flashing your While you flashing your board ESp Board? You could click on this icon right here serial monitor it will open up this window Once it completes flashing. It’s Gonna restart and it’s going to give you a similar output if you look at connected to and this is your this is going to be your wi-Fi router name that you put it in and Once it obtains the IP address will show you the IP address here And this means your ESp board is connected to your network at this point So what we’re going to do next is we’re gonna have before we unplug anything We’re going to go ahead and ask Alexa to discover devices And to make sure that everything is connected and you can see the output and that should matches and that should match similar to my output Unless you’re going to have a problem. If it’s not connected correctly So let’s do that first so I have a Alexa a dot here, so I’m going to Give a command So let’s see what happens on serial output Alexa discovered devices Starting discovery this can take up to 20 seconds if you have philips you press the button on your bridge So as you can see it actually send commands and Discovery is complete I found two smart home devices If your philips bulbs were not discovered please press the button on the bridge and rerun discovery So as you can see it discovered two devices even though we only have just one board hooked up So you can use you know? more details on it and set it up in a program and You’ll be able to control multiple devices with single Board So we’re going to go ahead and give just commands to turn on and off thing and we see serial output if we see anything happening and Then we’ll just go ahead and plug in over relays with it to make sure that it can control the relays Alexa turn on office lights Okay, as you can see it just sent the the command to turn on one of the devices so the output is going to be similar, so As you can see it is we haven’t hooked up anything yet But we’re going to go ahead and hook it up in a minute But I always I want to make that it’s able to discover two devices and able to send commands You want to test it before you hook up anything else? Alexa turn on kitchen lights Okay So this looks good. It’s working so what we’re going to do is we’re going to go ahead and plug in both relays so Plugging in relays, it’s very easy so very first thing we’re going to do is plug in this solid state relay So I got these two wires Hooked up to the solid state relay here one to the negative and one to the positive the positive one goes to the Gpio 14 and this one goes to the ground so as you can see As you can see here this is ground, so I’m going to plug this in here and this is done

and Also, this goes to the Gpio 14 now before I do that. I’m going to actually unplug the FtDI board, so I want to power it down. I don’t want to short anything Power it down, so I’m one guy. I’m going to do is connect this to the GPio So if you count from the top, it’s a one two three Four and the fifth, so this one is Gpio Fifth one is 14, so I’m going to put this and put this there two three four so there we go, so Now we’re going to take the solid state now. I mean the mechanical relay and So we have the negative so we have the negative goes into the ground positive go to the 3.3 volts and This signal goes to the GPI of 16 even though this is a 5 volt relay It still is unable to operate it if we have enough juice, so let me connect this So the ground goes to the ground the red One goes to the positive and the signal goes to the GPIo 16 There we go That’s it. We’re connected and we don’t need these two wires to flash it This is only needed to flashing it. So I’m only some only Powering up the board actually the these two wires using the power from it, and that’s it, so So on this relay when I give commands you’re going to see this light coming on and off I don’t have any hooked up here anything. I will just make sure you guys can see the light coming on and off Turn on office lights Okay Alexa turn on kitchen lights So something is connecting so something is connected drawing The solid State relay is connected wrong because it didn’t turn on let me check What’s going on here? So guys looking through the camera. It’s really hard to figure out The port I can’t see it very well, so I had it hooked up on the wrong Pin here on a breadboard so I had to move one up, so it’s the first second third The fourth One is the the gPio 16 and then the fifth one is GpIo 14 So let me try it again Alexa turn on office lights Okay, Alexa turn off office lights Okay, Alexa turn on kitchen lights Okay, Alexa turn off kitchen lights okay, so guys please give me a feedback and tell me what you liked about this tutorial what you don’t like and also if You guys can let me know what you like me to cover in next few tutorials These are the basic building blocks Eventually we’re going to be creating the whole automation system for the house Where we’re going to be connecting different things To a single console and control it that way So these are building blocks, so I have not shown your project where you actually put everything together, so I think next few tutorials We’re going to get the basics done and then we’re going to build these small devices and I’m going to show you how to connect them to your lights or your Fan or different devices as you like to connect to so folks this is it for this tutorial until next time bye