This is an easy way to get commands from Google Assistant to an ESP8266-based device under NodeMCU firmware (WiFi Kit 8).
The project uses the IFTTT platform where Google Assistant and Webhooks Service can be assigned to work together.
Using this functionality we can set our device to wait for specific commands to arrive and then get decisions according to the voice command.
So we can say Ok Google command "turn on room lights or turn off room lights" and use this voice command to turn on or off switch lights. To achieve this, we need the help of an applet and should be created on IFTTT and Heroku.
On WiFi Kit 8 programming side we need to update and flash your WiFi Kit 8 with ESP8266 Web Socket Clientand set it wait respose "json string" from IFTTT throuh Heroku after ask Google Assistant and fetch values from respose.
By the way a lot of commercial devices already exist in the market for such application but, I wanted to have my own simple and low cost device and its always good to learn new things.
NOTE: This project uses AC electricity, which could harm you or start a fire-- don't leave this project connected to power unattended, and if you don't know what you're doing, work under the supervision of someone who does.IFTTT.Create your own applet. Please follow step by step instruction below:
click If this.
1- if this choose a service "google assistant" choose trigger say a simple phrase.
2-Complete trigger fields.
3- Then That.
4- Choose action service webhooks.
5- Complete action fields.
6- save.
Open Weather Map.For the forecaster side we need to use the Open Weather Map API, it’s necessary to sign up on their platform and obtain an API key before writing the code so we can perform a GET request using the API URL with the appropriate parameters and then parse the response string using the ArduinoJson library.
OpenWeatherMap’s free plan provides everything you need for thins example. To use the API you need an API key, known as the APIID. To get an APIID:
- Open a browser and go to OpenWeatherMap
- Press the Sign up button and create a free account
- Once your account is created, you’ll be presented with a dashboard that contains several tabs (see figure below)
- Select the API Keys tab and copy your unique Key
This is a unique key you need to pull information from the site. Copy and paste this key somewhere, you’ll need it in a moment.
To pull information on weather in your chosen location, enter the following URL with the sections in curly brackets replaced with your chosen location information and your unique API key:
http://api.openweathermap.org/data/2.5/forecast?q={your city},{your country code}&APPID={your API Key}&mode=json&units=metric&cnt=2
Replace {your city} with the city you want data for, {your country code} with the country code for that city, and {your API key} with your unique API key we found previously. For example, our API URL for the town of Porto in Portugal, after replacing with the details, would be:
http://api.openweathermap.org/data/2.5/forecast?q=Porto,PT&APPID=801d2603e9f2e1c70e042e4------&mode=json&units=metric&cnt=2
Comments