Voice Controlled Home Automation | Google Assistant | NodeMCU

Back to Blog
Voice Controlled Home Automation | Google Assistant | NodeMCU - Voice Controlled Home Automation | Google Assistant | NodeMCU - Voice Controlled Home Automation | Google Assistant | NodeMCU - 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 (70)

  • iman

    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

      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

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

    December 25, 2018 at 8:41 PM
    • Sharath

      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

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

    January 11, 2019 at 7:25 PM
  • Anil kumar

    I have completed all the basic things which u have mentioned above in the discription but i need the the program to dump into the Node MCU module…. can u provide it for me

    February 20, 2019 at 2:50 PM
  • Tayyab

    Hello-

    The Tutorial was very help… Great!!.. Now say if I had a two relay (Could be of any number) and wanted to control using 2 different boards for each relay using the same IFTTT account. How can I do..

    Thanks

    February 22, 2019 at 4:40 PM
    • Sharath

      In blynk you need to create the no. of switches you want. Then you need to configure it in IFTTT app (for ON and OFF states of each switches). You doesn’t need to flash any programs in NodeMCU. All you need to do is in these two apps only + Hardware connections. No changes in code. Also note that, in IFTTT it takes equivalent UNO GPIO pins. So refer the pinout in previous tutorial.

      February 24, 2019 at 9:36 AM
  • Angel

    Hello, placing my data says that the token is invalid, when it really works by inserting it into the nodemcu code. Pinging the address of India responds correctly, then it does not

    March 2, 2019 at 10:16 PM
    • Sharath

      I didn’t get the question clear. Can you tell me exact error locations?

      The auth token will looks like this without any spaces “cd98afbe5ea9448e8ad6fc” within double quotes. From where you are getting this invalid token error? And from where did you tested the pinging details? The pinging details confirm you have proper internet but did the nodeMCU is on the same network?

      March 4, 2019 at 10:38 AM
  • Anil kumar

    with blynk it is absolutely working but while using google commands my loads are not responding, where will be the problem I am not able to rectify it… please can u help me.
    I have been completed all the steps which u have mentioned in above……

    March 25, 2019 at 2:33 PM
    • Sharath

      You have to check the ‘url’ in IFTTT part. Copy paste it in some browser & test it.

      March 26, 2019 at 11:04 AM
  • Lozzi Gabriel

    Unable to make web request. Your server returned a 400

    voici mon erreur via IFTTT ????

    April 2, 2019 at 11:21 PM
  • Lozzi Gabriel

    Voici mon ligne URL , https://188.166.206.43/2da2f1e96e2c492bb401a925b2b47d64/update/D0
    cela ne fonctionne pas

    April 3, 2019 at 7:30 PM
    • Sharath

      Seems like they changed the URL API Format. But in the documentation, they still show the old method only.
      Link for REST API Documentation – https://blynkapi.docs.apiary.io/#reference/0/write-pin-value-via-get/write-pin-value-via-put?console=1

      They have a test option so that you can enter your API Key and see the responses it got.

      Try this (not sure it will work):
      Open Command Prompt and type ‘ping blynk-cloud.com’ and test with that IP Address you have got.

      April 4, 2019 at 1:44 PM
      • Lozzi Gabriel

        voici la réponse ” Invalid token.”
        Je ne comprend pas ??
        Test avec nec token même défaut….

        April 5, 2019 at 1:18 AM
        • Sharath

          Please open Blynk App and Press the Cog Wheel on your Project Dashboard. You can see ‘Auth Tokens’ You can copy and paste it somewhere or email to get the tokens of that project. Verify that tokens you got from blynk and the tokens you pasted in the URL. Both should have to be the same.

          April 5, 2019 at 10:44 AM
          • Deepak Kumar

            Applet is running well but there is no response from blynk to node mcu,the web hook is not working well.please resolve my issue I am searching the url in browser it says wrong request format

            April 5, 2019 at 2:34 PM
  • Deepak Kumar

    Applet is running well but there is no response from blynk to node mcu,the web hook is not working well

    April 5, 2019 at 2:11 PM
    • Sharath

      Update: (26/4/2019) I tested it and it works very well. Maybe you are having any network issue or the Blynk server is down/maintenance.

      Yes, In the last comment also he mentioned the same. Maybe they changed the API. I will update you if I find any document release.

      April 5, 2019 at 5:13 PM
  • naveen kumar

    all the above procedure i followed…but when i commanding to google it takes the command but it doesnt either turn on or off the light..how to link ifttt with nodemcu

    April 26, 2019 at 2:40 PM
    • Sharath

      Check Step 11, and properly update your Auth token in the URL. The auth token you got in Email.

      April 26, 2019 at 5:25 PM
  • om kumar yadav

    all the relays are turning on but fourth relay is not turning on when i give voice command through google assistant.My Relay To Node connection is given below

    DO to IN1
    D1 to IN2
    D2 to IN3
    D3 to IN4
    GND to GND
    VCC to VIN

    May 27, 2019 at 7:17 PM
    • om kumar yadav

      also relay 4 is turning off by giving the voice command but its not turning on

      May 27, 2019 at 7:18 PM
      • Sharath

        Try replacing the last two relay pin numbers. If again the 4th relay is not working now then it might be the power is not enough to power up all relays together. Otherwise, the relay is failed.

        I think most probably the power is not enough to drive all relays together. The solution is you have to give separate power supply at least 1 Amp to drive those.

        May 27, 2019 at 10:08 PM
        • om kumar yadav

          DO to IN1
          D1 to IN2
          D2 to IN3
          D3 to IN4
          GND to GND
          VCC to VIN

          Mentioned above all connections are right?

          now coming on the consequences you have given , all the relays are working when i switch it on or off through blynk app but when i use google assistant fourth relay is not turning on but it’s turning off from google assistant.Although i have checked IFTTT applets several times.

          May 28, 2019 at 12:14 AM
      • Sharath

        As mentioned in the previous blog, ‘I found that the D1, D2, D5, D6 are good to use for without any flickering of Relays.’

        These are the best pins to use with NodeMCU. Because few pins of NodeMCU have alternative functions. So it will interrupt each other’s functionalities. If you look at the pin details of NodeMCU you can figure it out.

        May 28, 2019 at 10:21 AM
        • om kumar yadav

          well thanks for the circuit diagram , now relays are working properly.

          May 28, 2019 at 3:04 PM
  • jayakrishna

    Hi Sharath, i am new to this world. Will try to explain my problem as short as ican, plesae help me solving the below issue.
    What am i trying to achieve ?
    Trying turn on a Zero watt bulb
    What is the problem i am facing ?
    Bulb is not turning on
    What did i do ?
    I am using Blynk app -> IFTTT -> Webhooks (using Google assistant) -> Arduino UNO (IDE) ->4 way Relay -> Connected to a Zero watt bulb

    Using Board -> Arduino board
    Replaced the authentication token in the code ( Since i am not using node mcu relay not using ssid & pwd)
    Now when i turn button ON / OFF in the Blynk app in the mobile, i see the a small inbuilt light on Arduino UNO board, turning ON and OFF. Which inturn Turning ON and OFF Relay 4 (i have connceted to IN4).

    But from Relay 4 (IN4) the bulb is not turning ON and OFF (Am i missing anything here ? in terms of code OR connections? please help me brother.)

    FYI Connections i have made:
    Arduino UNO – Relay
    5V – VCC
    GND GND
    D13 IN4

    Relay – Bulb ( this part i believe i am messing up)
    i have a bulb with two wires
    a male and female plugs connected together (2 wires connecting them)
    Cut down one of the wires of male and female plug and one Connected to relay,(COM)
    the other i joined with Bulb’s one wire. Now thw remaining 2nd wire of the bulb is connected to Relay.(NC)

    Note:
    I am not sure what NC, NO, and COM are in relay but, i tried all possible combinations of all these 3 with the above left out wires but the bulb is not turning ON or OFF. But using mobile app i can turn ON or OFF the small bulb given on both Arduino UNO and Relay IN4.

    Please help me what am i missing.

    May 28, 2019 at 12:55 PM
    • Sharath

      Relay Connections

      NC is Normally Closed, It means in default/no power it is contacted together with COM wire. If relay is ON then it will disconnected from COM & Latches towards NO.
      Similarly the NO – Normally Open (means normally disconnected from COM). Only if relay ON it will get contact with COM (also remove contact on NC. (Like a plate seesaw plate)).

      COM is called as COMMON. The wire that gives Supply. It wont change in any states.

      May 28, 2019 at 1:17 PM
      • jayakrishna

        hey Sharath, thanks for quick turn around. But as i dont understand this phase line and neutral line. I shall explain my understanding fropm above lines :
        One wire of light bulb should be connected to “NO in relay”
        The other wire of the bulb to the One of the cut wires of male and female plug combination ?
        It would be great if you can share any ref diagram for connecting bulb ?

        May 28, 2019 at 4:55 PM
        • Sharath

          Phase and Neutral (AC) are somehow similar to Positive and Negative in DC Supply. But AC Devices doesn’t care about the Terminals. The Light will work in any combinations.

          For safety reasons, the Switches are connected to Phase Terminals on our switchboards to avoid the risk of electric shock while repairing. The relay here actually works like a switch only.

          In DC, for example, if you want to glow an LED you should have to give +ve to +ve and -ve to -ve Terminal of LED. Otherwise, it won’t work.

          May 29, 2019 at 9:24 AM
  • om kumar yadav

    sir,can i control my room appliances by usnig this?

    May 28, 2019 at 3:22 PM
    • Sharath

      Yes, of course, Using Relay you can control your AC Appliances. You also need to check the relay specifications that can handle the load. TV, Tubelights, Fan, Printers consume less Watts of power, so you can use it. But devices that consume high watts you need to check the relay specifications.

      May 29, 2019 at 9:32 AM
  • saranya

    Dear sir, I got this error while creating IFTTT app “couldn’t verify with Google Assistant”……. please tell me what should I do

    June 5, 2019 at 12:31 PM
    • Sharath

      You should have allowed access for IFTTT with google account. It would have asked when creating the service for first time.

      June 5, 2019 at 2:36 PM
  • abdo

    i have error say your server returned a 500

    July 16, 2019 at 11:12 PM
  • STAR

    Applcatons of this please …??

    July 26, 2019 at 1:12 AM
    • Sharath

      Can control any home appliances like TV, Lights, Music Systems, Doors, etc with voice commands or with Google Home.

      July 26, 2019 at 4:06 PM
  • Bright Adinkrah

    Sir please I want to ON two or more device with 1 voice command so how do I go about it in ifttt

    August 3, 2019 at 8:58 PM
    • Sharath

      That is not supported in this URL Method probably. A work around will be, If both devices are runs in same voltage (Eg. 220V AC for Fan, Tubelights,etc) then you can connect the output wire from relay with both devices (It may either Phase or Neutral depending on your wiring).

      (Caution: Do not short Phase and Neutral together, it may cause fire, burn,etc. Always suggested to get help from local professionals while working with AC Devices).

      August 29, 2019 at 10:25 AM
  • anuttela

    hello sharath. i want ask you something about voice controlled home and ive done this project using microcontroller NodeMCU (esp8266) with Blynk apps and it is work very well. the thing that i want to ask is i want to do this project but with microcontroller NodeMCU (esp32). ived try NodeMCU (esp32) with the same way the programming that ive done with NodeMCU (esp8266) and the Blynk apps is work while google assistant wont work. now the question is can i use other NodeMCU to do this project? i hope you can help me and reply me as soon as possibe. thank you. cheers

    August 29, 2019 at 9:33 AM
    • Sharath

      Hi, it will be easier if you differentiate them as NodeMCU and ESP32 Dev Board (as shown in Arduino IDE Boards).

      As I understood, you want to implement the same with ESP3 Dev board right?

      Yes you can use the same. But you need to consider the PinOut will be different for both boards. There is no official pin details available in the datasheets. But you can get it from some other resources. In ESP32 you can directly use the printed pin number in the URL.

      (Not sure, But in assumption only. Try and reply back if it works)
      For Pin 23:
      https://188.166.206.43/YourBlynkAuthToken/update/D23

      or try this
      https://188.166.206.43/YourBlynkAuthToken/update/23

      August 29, 2019 at 11:26 AM
      • anuttela

        hello sharath. i tried pin 23 but it still wont work. i still dont know how? was it the pin number is wrong? i hope you reply back. cheers

        September 4, 2019 at 8:28 AM
        • Sharath

          Did you tried both the URLs? Also make sure the ‘AuthToken’ is correct in the URL & the blynkk code also.

          September 4, 2019 at 4:53 PM
          • anuttela

            URL & blynk code correct. i tried control with APP Blynk its work but google assistant is not work. i don’t know how to make it work..hope you can help me

            September 9, 2019 at 9:31 AM
        • Sharath

          https://188.166.206.43//update/23

          Note that the URL Contains ‘Blynk AuthToken’. The token in the Blynk Code

          char auth[] = “YourAuthToken”; //In the code, should same in the URL

          and in the URL Should be same. This is the unique key to control your device specifically.

          It should be like this after replacing,
          Eg:
          https://188.166.206.43/aa28aswf5dfd565ihbij415156/update/23

          September 9, 2019 at 11:03 AM
          • anuttela

            okay, thank you for responded

            September 16, 2019 at 6:58 PM
  • anuttela

    hello sharath. i want to ask something about current sensor. i don’t know how to use “ac 220v 8 channel optocoupler isolation voltage test board mcu ttl for plc” with microcontroller esp32. i hope reply cheers

    September 16, 2019 at 7:09 PM
    • Sharath

      Do you want to measure the current in PLC or ESP32?

      September 16, 2019 at 7:41 PM
      • anuttela

        ESP 32. I use this optocoupler to detect current on project circuit. i hope you reply me as soon as possible. cheers

        September 19, 2019 at 12:45 PM
        • Sharath

          I have looked about the module you are telling about, but I’m unable to find a datasheet (if available send me a link.

          As I observed there are two VCC Pins in that, so thinking of which one will be for voltage reference & the other one for powering the module. If we have datasheet they mentioned in it.

          Also thank you for introducing me to this new module, I was also looking for similar kind of this module for one of my solution. But unfortunately it is not available in India & also seems bit costly. Which country are you from?

          September 19, 2019 at 1:07 PM
          • anuttela

            i do search the datasheet from the internet and i unable find it too. i bought it from online shopping and they didnt have datasheet for this component. (ACS715 Current Sensor Carrier 0 to 30A) This current sensor is a carrier board or breakout board for Allegro’s ACS715LLCTR-30A-T Hall effect-based linear current sensor which is a little bit similar. by the way im from Malaysia.

            September 23, 2019 at 12:29 PM
          • anuttela

            hellooo….i do search the datasheet from the internet and i unable find it too. i bought it from online shopping and they didnt have datasheet for this component. (ACS715 Current Sensor Carrier 0 to 30A) This current sensor is a carrier board or breakout board for Allegro’s ACS715LLCTR-30A-T Hall effect-based linear current sensor which is a little bit similar. by the way im from Malaysia.

            October 3, 2019 at 8:55 AM
        • Sharath

          If it has Power LEDs, Then connect VCC one by one with 5V. So you can know which one is Boards supply. Then test the other supply with the mentioned voltage.

          October 4, 2019 at 7:59 PM
        • Anyim Okechukwu

          Sir, the blynk is working very well with the nude MCU but the ifttt is not… Do I need to install and configure the google assistant app on my android device?

          December 5, 2019 at 9:14 PM
          • Sharath

            When IFTTT asks for permission with Google, You could have not allowed. Hence it won’t able to work with IFTTT.

            December 7, 2019 at 1:26 PM
  • radhakrishnan p

    sir
    i am running a local server(blynk local server) on my raspberry pi in lan
    in url space what should i type, is it my raspi ip with port 8080
    do i need a port forward to use google assistant ifttt
    plz help me

    September 20, 2019 at 7:35 PM
    • Sharath

      I didn’t worked with Local Server yet. You have to check the official blynk documentation. Because it should have the correct path to trigger the app.

      But it is necessary to forward the port as it needs to get requests from outside you LAN (i.e from Internet).

      September 26, 2019 at 11:47 PM
  • Prathyusha

    Hello sir..!
    Can we use ifttt to get sensor (temperature,humidity,moisture percentage ,ph) data from thingspeak…only to get and read out the data(not chamging any of it)…in real time when asked. We are using nodemcu and are posting the data im thimgspeak all the sensors runs well and data is being posted to thingspeak( thanks!!! to your previous post 🙂 )
    Wanted to add on a little bit…would be very glad if you reply..thanks..

    September 26, 2019 at 10:57 PM
    • Sharath

      Yes you can, The ThingSpeak.writefield() used to write the data to ThingSpeak. It also has ThingSpeak.Read() (Not sure about the function, check it once). You can take Read Example from the Thingspeak library and customize it to work. It should have a ReadAPI Key that needs to be used for Tingspeak.read function. Documentation link here – https://in.mathworks.com/help/thingspeak/thingspeakread.html

      September 26, 2019 at 11:53 PM
      • Prathyusha

        Thanks for the reply… But how to call this function( thingspeak.read() )read in IFTTT.com…I want google assistant to tell me the latest value..can’t figure out how to do that..would be glad if you could help sir…

        September 27, 2019 at 8:42 AM
  • SATENDRA

    I AM FROM UTTARAKHND,AND I GOT WEBHOOK ERROR 404

    November 5, 2019 at 7:03 PM
    • Sharath

      Does your URL Has the correct Blynk Authentication token in it?

      November 5, 2019 at 7:07 PM
  • mallika golla

    Good morning sir,we want to implement a project using node MCU and google assistant . For ON and OFF we need to implement this. Can we operate multiple devices at one?

    January 26, 2020 at 12:27 PM
  • mallika golla

    sir,can we use any other application other than IFTTT? Coz it is not working for voice contol. But it is working for on and off control in the dashboard.

    January 26, 2020 at 4:51 PM

Leave a Reply

Back to Blog