Google Assistant home automation with Nodemcu ESP8266

Google Assistant home automation with Nodemcu ESP8266

Hello, welcome back. In this tutorial, we will learn how to make a Google Assistant home automation project using the Nodemcu ESP8266 board. Also, this tutorial includes how to turn ON and OFF a LED using the Google Assistant. But, once you understand the basic principle here, you can control every electrical appliance in the house using relays. Also, this project is based on IoT technology. This project for mainly need two applications. That is, the Blynk app and the IFTTT web app. OK, now let’s learn how to do this project step by step.

What is the Google Assistant

Simply put, this is an artificial intelligence service created by the Google. Through this, we can get the service using our voice. Also, we can see this service in all smart devices. That is, smartphones, smartwatches, Tabs and smart home devices.

What is the IFTTT

IFTTT is a service designed to respond to events. That is, an app with a large amount of software that connects devices and services together. Also, this IFTTT application works closely with various service providers. We can use this application mainly for various services like home automation and posting the same content on several social media platform. For that, we can use the “applets” in this application. So, click this Wikipedia link for more details.

OK, let’s do this project step by step. The required components are given below.

Step 1

Firstly, identify these components.

Step 2

Secondly, connect these components. To do this, use the circuit diagram below.

Google Assistant home automation with Nodemcu ESP8266

Step 3

Thirdly, let’s set up the Blynk app. For that, follow the step below.

  • First, download and install the Blynk app in to the smartphone and sign up the app using your email. Now, click the “New project” button.
  • Then, enter the project name as you like. After, select the device and connection. Finally, click the “Confirm” button.
  • OK, now we can see the project interface. Next, let’s add the widget to the project. For that, click “+” icon and include a one button widget.
  • Next, let’s set up settings of this button widget. For that, click the button and enter the name as you like. After, change the PIN to D2 and mode to switch.
  • Lastly, customize this interface as you like. OK, the Blynk app is ready for our project.

Step 4

Next, let’s set up the IFTTT application. For that, follows the steps below.

  • First, go to the IFTTT web page and sign up using your Gmail address.
  • Then, click the “Create” button and follow the steps below.
  • In this step, select the address where you want to use Google Assistant.
  • OK, now we have to give the necessary commands to turn the LED on. First, give the command that the LED should be ON. I have given as “LED bulb ON”. Then you can give two more commands if you want. These are the optional. Next we have to give the voice command that we can get from Google assistance. For that, I have given as “OK, The LED bulb is ON”. Give it a name of your choice too. If this work is done, click the “Create trigger” button at the end. After, follow the steps again.
  • Now, all we have to do is fill in the details. First, we will create a URL. We need to create this link as follows.

http://blynk cloud ip/blynk auth token/update/relay pin

  • First, let’s get the Blynk cloud IP. For that, run the command prompt (CMD) on your computer. Next, type ping and press Enter. Then, we can see the details related to the Blynk cloud. From here. All we need is the IP address.
  • OK, now let’s get the Blynk auth code from the Blynk app registered Gmail.
  • Now we can create the above URL. It is as follows.

This URL does not work for you. It should be made as mentioned above. Now, we add this information to the web application. Enter the URL first. Then, change the method to PUT. Change the content type to Arduino / JSON. Enter [“1”] for the body. After, follow the steps again.

  • Next, we have to create the voice command to turn off the LED. For that, do the same steps as mentioned above.
  • Now, let’s create a voice command to turn off the LED. I have given as “LED bulb OFF”. Enter this as you like. Then, enter the voice command given to us by the Google Assistant as “OK, The LED bulb is OFF”. After, click the “Create trigger” button. Then, follow the steps again.
  • Now, let’s connect a LED off command with this app. For that, we use the same URL we created above. Here we need to change the value entered the body. For that, use [“0”]. Now, click again the “Create action” button. Then, follow the steps below. Now, you can see the two voice commands that we have created.

Step 5

OK, all apps are ready. Let’s now creates the program for this project. It is as follows.

/*Google Assistant with Nodemcu
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "";
char ssid[] = "";
char pass[] = "";

#define LED D2

void setup() {
  Blynk.begin(auth, ssid, pass);
  pinMode(LED, OUTPUT);

void loop() {;

Code explanation

Firstly, libraries are included.

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

Now, include the Blynk auth token and WI-FI connection details.

char auth[] = "Y_zYDj7j8rlp1DfihdOHZXhAHgnY4oOz";
char ssid[] = "SriTu Hobby";
char pass[] = "12345";

Next, the LED pin is defined.

#define LED D2

In the setup function,

void setup() {
//The blynk library is beginning
  Blynk.begin(auth, ssid, pass);
//The LED pin is set as an output pin
  pinMode(LED, OUTPUT);

In the loop function, the blynk library is run.

void loop() {;

Step 6

Now, select board and port. Afterward, upload this code.

Finally, now run the Google Assistant service on your smartphone and try the voice commands we entered above. OK, enjoy this project. The full video guide is given below. So, we will meet in the next tutorial.

Google Assistant home automation with Nodemcu ESP8266

Similar Posts

Leave a Reply

Your email address will not be published.