Imagine you are on your bed which is far away from switch board.As you know people now a days became so lazy...Haha...Just kidding.They want the work to be done quickly and it to be simple.So instead of getting down from the bed and switching off the light what if you switch off the lights with the help of your voice...Sounds pretty cool right. Controlling home appliances with your mobile is cool and simple.With the help of this voice controlled system you can control your home appliances from anywhere around the world..So What next let's look at the procedure of building this voice controlled system.
Working Video of Voice Controlled System:
Step 1:Setting up the Hardware
As you know Led(Light Emitting Diode) has two legs.It's a particular type of diode which converts electrical energy into light.Since they are more energy efficient they won't get heated.One is longer and other is shorter leg.The longer leg of LED is +ve and shorter leg is -ve.
Take one leg of resistor and wrap it around the longer leg of LED i.e, positive leg.Insert the negative leg of LED into ground pin of Bolt. Insert other leg of resistor in digital pin 0 of Bolt.
With the help of USB cable connect wifi module to laptop or plug board.
step 2:Collecting Bolt API Key and Device_ ID
Login to your bolt cloud account. You can find your DEVICE_ID on Dashboard. For collecting API Key switch to API tab on the cloud.Now it will look like this.
Click on the clipboard button to copy the API_KEY. Store the API_KEY and DEVICE_ID values for further use.
Step 3:GPIO Control Command
Led is an output device.It shows the output in the form of light.
The structure of the command is:
Using this command we can either switch on/off the light.
Repalce API_KEY with api_key value in bolt cloud.Replace PIN_NUMBER by number to which digital pin you have connected the end of resistor.If you want the device to be On then keep the state of the device as HIGH in the command else set it to LOW.Replace the DEVICE_ID with the device_id available on your Bolt cloud.
Step 4:Using IFTTT creating an Applet that combines Google Assistant and WebHooks
Go to IFTTT on web and login via Gmail or Facebook or Create a new account.
Click on new Applet button to create a new applet.
Click on +This to create a trigger.
Choose Google Assistant->Say a Simple Phrase
After filling the details then click on Trigger button.
Now click on +that button to trigger
After that select Webhooks and make a web request
Enter the command that is mentioned in step 3.Method will be GET.Content type will be Application/json.
Click on create action button present below.
Finally click on the finish button present in the last step.
Similarly create a new applet to make the light off.The process is almost similar to that. Here you will change the state to LOW i.e. state=LOW in your code.Also, add a suitable phrase to switch off the LED.
That's it...Now you have done.You can see two applets on ITFFF.
Now wake your Android phone by saying "OK Google" and say the phrase you had set while creating the trigger to see the magic happen.