I have always wanted to control my house appliances with my voice. I have spent lots of time trying to figure this out. Finally I saw something on Youtube which helped me to build this project.
The only difference being that I have used Google Assistant in the place of Amazon Alexa. This gives me the freedom to control home appliances from anywhere in the world, using my voice. The only things that I need is my phone and a good internet connection.
Step 1: Hardware SetupInsert the longer end of the LED in the Pin 0(or any input pin) of Bolt WiFi module and the shorter end to the ground pin (GND), and power on the Bolt WiFi module.
Step 2: Getting the Bolt API Key and Device IDLogin to cloud.boltiot.com and note the DEVICE ID of your Bolt WiFi Module.
Now click on the API Tab and click on Enable. Copy the API KEY.
Your API KEY will look something like this:
0bXbXXXX-XXXX-49b7-a3d6-307b019dXXXX
It will be combination of both alphabets and numbers.
Step 3: Creating the GPIO Control CommandSince LED is a digital output device, we will need to get a Digital Write command that can be sent to Bolt over the Internet to switch on the LED.
Click here Bolt Cloud go to Docs Tab -> API Documentation -> GPIO Commands API -> Write Digital Output, to understand how to create a API command link to turn on or turn off a pin of the Bolt.
The structure of the command is:
https://cloud.boltiot.com/remote/API_KEY/digitalWrite?pin=PIN_NUMBER&state=HIGH/LOW&deviceName=DEVICE_ID
The parameters that you need to replace are:API_KEY: You can get it from API tab on cloud dashboard.PIN_NUMBER: Pin to which you have connected the LED. Values can be either 0, 1, 2, 3 or 4HIGH/LOW: This value indicates if you want to turn on/off the LED. HIGH will turn it on, LOW will turn it off.DEVICE_ID: The id of your device. You can get it from cloud dashboard.
The sample command to turn the led ON connected to device having ID BOLT13819450 to PIN 0 is:
https://cloud.boltiot.com/remote/0b5bXXXX-XXXX-XXb7-a3d6-XXXb019dXXXXf/digitalWrite?pin=0&state=HIGH&deviceName=BOLTXXXXXX
Make sure that you change the API Key to your own API Key and device ID which you got in the previous step.If you have connected the LED to any other pin other then Pin 0 then make a suitable change in the pin no in your code.
Step 4: IFTTT integration via Google Assistant and WebhooksGo to IFTTT to create a new applet by clicking here.
Login using your Gmail account. Make sure you use same account which you'll be using on your mobile to interact with Google Assistant.
click on(
) to create the trigger.
Choose google assistant as service.
choose say a simple phrase
Type the phrase you want to trigger the action. Make sure to specify the trigger command in different ways for example I used
a) Turn the lights on
b) Turn on the lights
c) Lights on
Create trigger.
Click on
Select Webhooks and make a web request
Enter the API URL you got in the previous Step. Make sure that you change the API Key and device name.
Method will be GET
Content type will be Application/json
Here is how your screen will look like
Click on 'Create Action' and then Click on 'Finish'
Stepsto turn OFF the LED
Now do the same process for a command to switch OFF the LED. Here you will change the state to LOW i.e. state=LOW in your code. Here is a sample of the code. Also, add a suitable phrase to switch off the LED.
That's it. You are done.Now Turn ON your Android phone by saying "OK Google" or "HeyGoogle" and say the phrase you had set while creating the trigger to see the magic happen.
Comments
Please log in or sign up to comment.