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.
Step3: Click the ‘+’ Sign to create a new applet.
Step 4: In the next screen click the ‘This’ text to create a 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.
Step 6: Choose the ‘Say a simple phrase’ option.
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.
Step 8: Now let’s create the Action to our trigger. Choose the ‘That’ option on the screen.
Step 9: Search for the ‘WebHooks’ action service. And tap on it.
Step 10: Now choose the ‘make a web request’ option.
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.
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.
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.
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.
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.
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
Comments (70)
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?
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.
Where should I receive url?
How do I find the ip address I used in url?
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.
Let me ask why I want to say turn off fan but the D0 leg not interrupting
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
Its the same code with your ‘Blynk Auth Token’ and ‘Wi-Fi credentials’ of the previous tutorial. That auth token only you need to use in the URL in Step 11 and Step 14. Link for previous tutorial- https://www.factoryforward.com/iot-home-automation-using-blynk-nodemcu/
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
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.
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
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?
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……
You have to check the ‘url’ in IFTTT part. Copy paste it in some browser & test it.
Unable to make web request. Your server returned a 400
voici mon erreur via IFTTT ????
Check the URL and Authentication token properly.
Lorsque je fais un test via mon navigateur j’ai le message suivant ” Invalid token.”
j’ai déjà vérifier URL et le jeton tous est OK, via Blynk fonctionne correctement.
C’est l’URL non? à la place de ‘YourBlynkAuthToken’, vous devez remplacer le jeton que vous avez reçu.
https://188.166.206.43/YourBlynkAuthToken/update/D16
Assurez-vous de ne pas avoir d’espace.
Voici mon ligne URL , https://188.166.206.43/2da2f1e96e2c492bb401a925b2b47d64/update/D0
cela ne fonctionne pas
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.
voici la réponse ” Invalid token.”
Je ne comprend pas ??
Test avec nec token même défaut….
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.
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
Applet is running well but there is no response from blynk to node mcu,the web hook is not working well
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.
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
Check Step 11, and properly update your Auth token in the URL. The auth token you got in Email.
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
also relay 4 is turning off by giving the voice command but its not turning on
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.
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.
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.
well thanks for the circuit diagram , now relays are working properly.
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.
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.
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 ?
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.
sir,can i control my room appliances by usnig this?
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.
Dear sir, I got this error while creating IFTTT app “couldn’t verify with Google Assistant”……. please tell me what should I do
You should have allowed access for IFTTT with google account. It would have asked when creating the service for first time.
i have error say your server returned a 500
Applcatons of this please …??
Can control any home appliances like TV, Lights, Music Systems, Doors, etc with voice commands or with Google Home.
Sir please I want to ON two or more device with 1 voice command so how do I go about it in ifttt
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).
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
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
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
Did you tried both the URLs? Also make sure the ‘AuthToken’ is correct in the URL & the blynkk code also.
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
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
okay, thank you for responded
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
Do you want to measure the current in PLC or ESP32?
ESP 32. I use this optocoupler to detect current on project circuit. i hope you reply me as soon as possible. cheers
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?
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.
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.
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.
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?
When IFTTT asks for permission with Google, You could have not allowed. Hence it won’t able to work with IFTTT.
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
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).
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..
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
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…
I AM FROM UTTARAKHND,AND I GOT WEBHOOK ERROR 404
Does your URL Has the correct Blynk Authentication token in it?
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?
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.