Home automation using NodeMCU and Google Assistant

In this article, we will discuss steps by steps on how you can make home automation using NodeMCU and Google Assistant.

What is Home Automation?

A home automation system is something that connects all your electrical or electronic appliances to the internet. You can control all of these devices from your smartphone also you can call all of these as IoT (Internet of Things) devices. 

In the case of IoT, special hardware is embedded with the devices that are configured with software in order to control from anywhere & make it a smart device. All data are being transferred over the network no human to human or human to machine interaction is required. Everything is based on cloud computing. So Let's automate our home by making voice-controlled home automation using NodeMCU and Google Assistant.

Home automation using NodeMCU and Google Assistant

Home automation using NodeMCU and Google Assistant

So these are all the components that you will need in your project:

1. Node MCU ESP8266 Board.

2. Relay Module.

3. 9V Battery.

4. Switch.

5. Breadboard.    

So first of all, I started interfacing with all these electronic components. After placing electronic components on a breadboard, I connected all the electronic components after that our prototype is finally ready now.

Circuit Diagram 

Let's move towards the step by step process:

> First of all, you have to open Google Chrome and go to the website which is Adafruit.

> Sign up for this website now after successfully signing up in the web site go again to Adafruit, so now, this is the interface of this website.

> For creating the dashboard click on "Action" button and then click on create a new dashboard nowhere type the name of your dashboard.  

For Eg: Google assistant home automation and in the description, you can add any information related to your the project.

> Now click on create option now our dashboard is successfully created now then click on create a new block option then choose a toggle switch then here you have to type a feed name, in this case, I have entered "Relay 1" as a feed name because we're going to use this same feed name in our code, then click on the create option now the first feed is created. Repeat the same process create a second feed which is "Relay 2".



> After creating two feeds select the first one and click on next step now type the "Block title name" in this case I am putting it as "Relay 1" and here button on text value should be "1" and button off text value should be "0".

> Now click on create block option so now the first block is successfully created in the same way create another block for that go in the "Add block" option select "Toggle" switch and select the second feed and then click on next step now type the block title which is "Relay 2" and button on text value should be "1" and button off text value should be "0". After that click on create a block option now, our two blocks are successfully created.

> Regarding code if you face issues then feel free to contact me.

> To upload the code, first of all, you need to install the NodeMCU board if you haven't installed the NodeMCU board this code will not work. Check Using Arduino IDE to Program NodeMCU

> After installing the esp8266 board this "esp8266 Wi-Fi.h" library will be automatically added.

> Now to install the "MQTT" library go on chrome and type "Adafruit MQTT library master". 

> Then go on "GitHub" website and download "MQTT zip library".

> Go to "Sketch" and click on include library and "Add zip library" then select the MQTT zip library from the folder or location where you have downloaded and click on "Ok" so the library is successfully added.


> In the code insert "your Wi-Fi SSID" and "password" with your hotspot name and its password and remember that the feed name which is a "Relay 1" or "Relay 2" must be the same in code.

> Go on "Adafruit" website and click on key option so here you will find the "user name" and "active key" just copy the username and activation key in the code. 

> After making changes in code click on compile option after successful compiling connect your NodeMCU board to your PC and then select the port and select the board which is NodeMCU esp8266 then Click on the upload option.

> Now the code is successfully uploaded now let's move towards the next part.

> Go to the "IFTTT" website so then sign in with the same Gmail that you have used in the "Adafruit" website. So after signing up, click on the "Create" option.


> Click on "if this" and then search service "Google Assistant", then click on the "Connect" option and then choose the Gmail which you have used it until now.


> Click on "Say a simple phrase" then here type what do you want to say I entered "Turn on light 1" one and in turn, the assistant should respond to "turning on light 1". At last click the "create trigger" option. 

> Now tap on "that" i.e on "+" and select the service "Adafruit".

> Click on "Connect" and here "authorize" it and then select "Send data to Adafruit IO" then select the feed name which is "Relay1" and data to save should be "1" for switching on the relay then click on "create action" so now our first applet is successfully created.


> So now create the same applet for switching off the "Relay1" for that repeat, the step above and here you can type "turn off light 1" and Google assistant should respond "turning off light 1".

> Select "Adafruit" then "Send data to Adafruit IO" then select feed name which is the deliverer but data to save should be "0" this time as we are using it for switching off the "Relay 1". After that click on "create action" so now our two applets are successfully created.

> As we are using  2 relays so that's why we have to create two more applets for "Relay 2" so just repeat the steps above which are similar as we created for "Relay 1", but here remember that the feed name should be relevant.

> Now our four applets are successfully created now it is time to check our project so in this way you can connect any AC appliances to these relays.

Warning: Beware while connecting AC appliances as it uses high voltage. Always double check your connection before switching on as you can get an electrical shock.

How it works?

While testing this project just remember to switch on your Wi-Fi or hotspot then connect it to the power supply and switch on the device and that's it you are ready to go.

Post a Comment

If you have any doubts, please let me know! Do not Post Any Spam Link!

Previous Post Next Post