Voice Controlled Home Automation | Google Assistant | NodeMCU

Voice Controlled Home Automation | Google Assistant | NodeMCU

In our previous tutorial, we have created a Home Automation using NodeMCU and Blynk. Using Blynk, we can control the devices anywhere in the World. We connected our NodeMCU with an optocoupler based relay and programmed it with Blynk code. Actually, it’s very simple and no programming knowledge is required.

Now in this tutorial, we will add an additional feature to control the device using your own Voice using Google Assistant and IFTTT.

IFTTT is called as ‘If This Then That’. We can create our own applets and connect them with the available services. We will create a trigger and then connect it to an action to perform our specific task. In our case, the trigger service will be ‘Google Assistant’ and the Action will be ‘WebHooks’. Let’s go ahead and start our tutorial.

For those who have not created the Blynk App and not programmed the NodeMCU follow this link for the previous tutorial.

If you have already had your Blynk App ready let’s continue.

Step 1: Install IFTTT app from Google Playstore. (You can also use the Website too).

Step 2: Now open the App. In the Homepage, Click the My Applet Icon bottom right corner.

1. Home Page

Step3: Click the ‘+’ Sign to create a new applet.

2.My Applets

Step 4: In the next screen click the ‘This’ text to create a trigger.

3. Create Trigger

Step 5: Search Google Assistant for our Trigger Service. If you are using this for first time in IFTTT, Google Assistant will ask to allow access for IFTTT.

4. Search Google Assistant

Step 6: Choose the ‘Say a simple phrase’ option.

5. Choose Simple Phrase

APPLET FOR TURNING ON THE LIGHT:

Step 7: Now configure the trigger options for ‘Turning ON the Light’. Fill the following

What do you want to say: Turn ON Factory Light

What another way to say it: Turn ON the Factory Light

What do you want the Assistant to say in response?: Ok, Powered ON.

Note: All the fields are custom. You can use your own phrases.

6.Configure Trigger ON

Step 8: Now let’s create the Action to our trigger. Choose the ‘That’ option on the screen.

7. Choose that

Step 9: Search for the ‘WebHooks’ action service. And tap on it.

8. Search WebHook trigger

Step 10: Now choose the ‘make a web request’ option.

9.Make Web request

Step 11: Now configure the action service for ‘Turning ON the Light’.

Here the Blynk server IP address is 188.166.206.43 followed by blynk authentication Token and update pin.

So if the web request is triggered and it will update the Blynk.Then it sends the command to our NodeMCU.

The settings will be

URL: https://188.166.206.43/YourBlynkAuthToken/update/D16

Method: PUT

Content Type: application/json

Body: [“0”]

Important Points:

In place of ‘YourBlynkAuthToken’ replace it with your Blynk Authentication Token that you flashed on your NodeMCU Board. You can also get this on your Blynk App or in your email.

The D16 (GPIO16) is the Pin number of Arduino UNO and it is mapped to D0 in NodeMCU. Please refer the nodeMCU and its equivalent Arduino Pin. This configuration will control the D0 Pin on the NodeMCU.

10. Configure Trigger ON

Step 12: Now click the Finish button to create our Turn ON Applet. Now we need to create an OFF Applet to turn OFF the Light.

11. Finish ON Applet

APPLET FOR TURNING OFF THE LIGHT:

Step 13: Now follow the same steps from step 2 to create an OFF Applet. The Google Assistant Trigger configuration will be

What do you want to say: Turn OFF Factory Light

What another way to say it: Turn OFF the Factory Light

What do you want the Assistant to say in response?: Ok, Turning OFF Factory Light

Note: All the fields are custom. You can use your own phrases.

12. Config OFF GA trigger

Step 14: The WebHooks action service configuration will be

URL: https://188.166.206.43/YourBlynkAuthToken/update/D16

Method: PUT

Content Type: application/json

Body: [“1”]

Important Points:

In place of ‘YourBlynkAuthToken’ replace it with your Blynk Authentication Token that you flashed on your NodeMCU Board. You can also get this on your Blynk App or in your email.

The D16 (GPIO16) is the Pin number of Arduino UNO and it is mapped to D0 in NodeMCU. Please refer the nodeMCU and its equivalent Arduino Pin. This configuration will control the D0 Pin on the NodeMCU.

13. Config WH OFF trigger

Click Finish on the next screen.

That’s all our configuration is done. Make sure the NodeMCU is online and connected to the internet. You can check it in your Blynk App. Now try saying the phrases you have given in the configuration followed by ‘Ok Google’ on your Android phone. Here we have given ‘Turn ON Factory Light’ so we need to tell

OK Google, Turn on Factory Light

It will reply ‘Ok, Powered ON’. And the Light connected on D0 pin of NodeMCU will be turned ON.

Google Assistant

In the new Google Assistant update, you can say ‘Hey Google’ instead of Ok Google. Both will work fine.

Other NodeMCU Tutorials:

If you need to implement this idea using Two way control (By Physical Switch and NodeMCU Relay) you can check this tutorial – Home Automation with Wireless RF Remote control using 2-way switch.

IOT Home Automation using Blynk and NodeMCU

Upload Sensor Data to ThingSpeak using NodeMCU

Getting Started with NodeMCU Wi-Fi Development Board | ESP8266

Flashing SONOFF Firmware on NodeMCU

Share this post

Comments (5)

  • iman Reply

    Hi, do not be tired. Thank you for the helpful content you provided
    I wanted to know there is no specific code for webhoke?
    We should not have a server and we have to control it with Gmail. What should we do?

    December 25, 2018 at 8:36 PM
    • Sharath Reply

      Webhook is kind of service to process your request. All you are sending is the specific parameter to that code and get our job done.

      For not using any external server, you need a microprocessor like Raspberry Pi to authenticate your email account locally and control your local devices. Otherwise you need to use some services like WebHook, Adafruit, Blynk,etc.

      December 26, 2018 at 11:06 AM
  • iman Reply

    Where should I receive url?
    How do I find the ip address I used in url?

    December 25, 2018 at 8:41 PM
    • Sharath Reply

      The URL Mentioned there is for Blynk Server (188.166.206.43). You have to directly apply that IP Address and no need for finding Any IP.

      December 26, 2018 at 11:11 AM
  • Võ Thanh Minh Nhật Reply

    Let me ask why I want to say turn off fan but the D0 leg not interrupting

    January 11, 2019 at 7:25 PM

Leave a Reply

Your email address will not be published. Required fields are marked *