• EUR€
  • £GBP
  • $USD

ESP8266 Project: ESP8266 & Amazon Alexa for home automation

DFRobot Apr 11 2018 898

In this video we show how you can control anything from lights to heaters to whatever plugs into a wall socket using your voice, an Amazon Echo, a Wemos D1 mini, and a relay. Super simple setup, takes about 10 minutes to go from old-school to ultra modern tech!

Conversation with Alexa 
Hey what’s happening Guys? It is the day after Christmas and I’m sitting here in the living room enjoying a lovely warm virtual fire- that’s actually my television but uh the reason why we are sitting here in the dark is cause I wanna show you a couple of things and one of them is, I got an Amazon Alexa Dot for Christmas. 

The Echo Dot allows you to talk to him more in your home. It includes a built in speaker but you can also connect to an external speaker.

Alexa, Stop. I actually did not expect her to pipe up right there so that’s kind of funny. Anyway, so that’s it. Alexa, what time is it?  The time is 4.41 PM. 

Pretty cool, Anyway, so we’re sitting here in the living room and I want to be able to turn on and turn off different things, kind of a smart home thing and I have one thing to do already which is the sonoff which I showed you guys in the earlier video. So we turn over here to this corner of the room which is rather dark. There is a giant life size cut up of Darth Vader. Alexa, turn Vader on. Ohhh! Yes, indeed. I like that. Alexa, turn Vader off. See how easy that is? Now the next thing that I wanna add is the fish tank. So instead of getting another sonoff, what I was thinking is we would do it with something that we already have here and something that we are quite familiar with -The ESP 8266. All we need is one of them, the USB wall charger and a relay. Let’s go put it on together and see how much fun we can have. I have all our parts here. We have a we most D1 mini, a relay, and the 12-volt power packs for my fish tank. Now what I want to do here is to split these wires just like that. Really simple, and then once they are split I’m going to cut the 12-volt wire and then strip it and then I twist them and tin them. Really easy here. It’s older and the shouldering iron.

Such a girl! And once it’s done, we are just going to nick up the ends so I’ve got a millimeter sticking out because really that’s all we need. Then we are going to put it into our really. The middle is the common, this is the normally open, and this is the normally closed, so we’re gonna put the two wired between the normally open and the common. Doesn’t matter which way they go. So, once that’s done, and then all we have to do is hook our we most up to this relay. I’ve got this set up with green, as five volt and orange is brown. Green is our 5 volt, orange is ground, and yellow is our signal. That’s it for our hardware set up, all we need to do now is upload the code and we should be good to go.

Alright guys, the first step is, we’re gonna need two libraries that is the Fauxmo ESP library and the ESP async TCP library. Once these two libraries and downloaded, then we just need to install them. There is a link down below where you can download them. So let’s go into the documents right there and we rename without the master at the end of it. We rename this one too to Fauxmo ESP and then just like that, we will copy them into our Arduino library’s folder and that should it. Next step is, we need to restart the Arduino IDE to recognize the new libraries. All right, you guys ready for the code? See how simple it is? So we include Arduino, ESP8266 Wi Fi and Fauxmo ESP. Next we need to put in our Wi Fi SSD and our Wi Fi password. Then we would be setting out Serial Baud rate- I’m setting it for 115200 here, you can set up whatever you want. Now we create an instance of fauxmo ESP called the Fauxmo. Next we are gonna come down here and set up a Wi Fi- our mode is going to be station mode. Then we are going to connect right here, Wi Fi begin using the SSID and password that we define right here. After that its going through this little jicama jiggle to connect and when it’s done, it will print us the message, telling us that it’s connected. Now here we clean out the garbage and we set up our Fauxmo. We have our pin in this case set to D2, Wi Fi set up, our fauxmo, we add device and we name it - in this case, it’s called fish tank, and we say Fauxmo on message go the call back and then the only thing in the loop is fauxmo dearth handles. Now we go back here and look at this function called Call back and this is going to print device, and then device name. It’s going to print the state whether it’s on or off and it will also turn it on or off. So let’s upload this code and let’s check it out. Alright I’ve already uploaded the code. Not that you can see anything here. The next step you need to do is we need to load our Amazon App and were going to come down here to smart home, were going to add a new device, I’ve already done it in this is this case is fish tank so you can see how easy that is and now, when the red light comes on, the fish tank will turn on, so let’s give it a shot. Pardon me; if this is a little loud, my echo dot is across the room. Alexa, turn fish tank on.


It’s on. So Alexa, turn fish tank off.


Guys how much easier could it possibly be than that? All right. I’m gonna go and install this on my fish tank. All right guys, we are right back to where we started and I’m sitting on the couch with my virtual fire. Alexa, turn Vader on. Oh nice. Alexa turn fish tank on.


Aha. I love it. This is so much fun. Alexa turn fish tank off. 

Alexa turn fish tank on.


Alexa, Red Alert. Alexa Stop. Okay guys, that’s it. I hope you enjoyed this I’ll put a link to the code down below if you did give me a thumbs up, feel free to comment and share and don’t forget to subscribe. That’s it. I’m out. Peace.

Alexa code zero zero zero destruct zero.
I’ll see you guys later.

Async TCP Library:  https://github.com/me-no-dev/ESPAsyncTCP

Wemos D1 Mini : http://amzn.to/2DmfMgW

Relay: http://amzn.to/2DknnMI

Echo Dot: http://amzn.to/2BYHqnO

The code: https://pastebin.com/A95HzH7n

The original video is here.