We all have heard of home automation. This is a very basic project of home automation. This project is all about voice-controlled lighting system with the help of Bolt IoT module. Here, I am using Google Assistant to control the multiple LEDs and buzzer. This gives me the freedom to control home appliances from anywhere in the world, using my voice. So let's start.......
Follow the below steps:
Step 1: Hardware ConfigurationPlug the longer end of the LED 1 in the Pin 0 of Bolt WiFi module and shorter end to the ground pin (GND), similarly, plug the longer end of the LED 2 in the Pin 1 of Bolt WiFi module and shorter end to the ground pin and plug the longer end of the BUZZER in the Pin 2 of Bolt WiFi module and shorter end to the ground pin, and power ON the Bolt WiFi module.
Step 2: Getting the Bolt API Key and Device IDLogin to cloud.boltiot.com and note the ID of your Bolt WiFi Module.
Now click on the API Tab and under the section for Generate Key, click on Enable.
Now click on the copy button to copy your API key.
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 LEDs.
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 1 ON connected to device having ID BOLT15328975 to PIN 0 is:
https://cloud.boltiot.com/remote/f1f965e9-d9c2-4e6b-aed0-b2sb843f65dk/digitalWrite?pin=0&state=HIGH&deviceName=BOLT13819450
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.
Similarly, connect LEDZ 2 to Pin 1 and buzzer to Pin 2 of the Bolt IoT module.
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 '+This' to create the trigger.
Choose Google Assistant -> Say Specific 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) Switch ON the first light
b) First light ON
c) Glow the first Led
Click on 'Create Trigger'
Click on '+That'
Select Webhooks and then 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.
API URL will be similar to this:
https://cloud.boltiot.com/remote/f1f965e9-d9c2-4e6b-aed0-b2sb843f65dk/digitalWrite?pin=0&state=HIGH&deviceName=BOLT13819450
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.'
Steps to Turn OFF the LED1Now do the same process for a command to switch of the LED 1. 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.
https://cloud.boltiot.com/remote/f1f965e9-d9c2-4e6b-aed0-b2sb843f65dk/digitalWrite?pin=0&state=LOW&deviceName=BOLT13819450
Now do the same process for Led 2 at Pin 1 and buzzer at Pin 2.
That's all. You are done.
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.
Comments