Google assistant fascinated me from the time when it was only available on latest smartphones. When I discovered that an IoT project can be created using google assistant I decided to go ahead with it. Also giving voice commands to a machine is a quite effective and time saving technology.
Hardware Setup- Put positive leg that is the longer end of LED into pin 0.
- Put negative leg that is the shorter end of LED in the ground pin.
- Connect Bolt WiFi module to a power source. Make sure its connected to the internet.
- Login to "cloud.boltiot.com".
- Go to devices tab on the left corner and find your Device ID. It looks like BOLTXXXXXXXX.
- Go to API tab listed on the left corner. Select on enable and copy this key for further use.
GPIO stands for general purpose input output. Bolt has 5 digital GPIOs namely, 0, 1, 2, 3, & 4. They are used for connecting input and output devices to the board. These pins operate at a voltage of 3.3V on bolt.
For controlling our LED we need to set up a URL that will use our API key, device ID, and GPIO pin to connect to the bolt cloud.
Digital Write function is used here, as LED is an output device. digitalWrite function contains two parameters that are pin and state. It is used to write a HIGH or a LOW value to a digital pin.
The default structure of the command will look like:
https://cloud.boltiot.com/remote/API_KEY/digitalWrite?pin=PIN_NUMBER&state=HIGH/LOW&deviceName=DEVICE_ID
The parameters that we will replace in our actual command are:
- API_KEY: We enabled and copied it in previous section.
- PIN_NUMBER: GPIO pin we connected our LED to that is, '0'.
- HIGH/LOW: We need to put either 'HIGH' or 'LOW' in this command. HIGH will turn on the light and LOW will switch it off.
- DEVICE_ID: The ID of our module which we noted in previous section i.e. BOLTXXXXXXXX.
For turning ON the lights, I will type HIGH inside 'state'.
The command (i.e. the URL) will look like-
For turning OFF the lights, I will type LOW inside 'state'.
The command (i.e. the URL) will look like-
A software called IFTTT is used. It stands for 'If this, then that'. This software helps in connecting different apps and devices.
- Go to 'ifttt.com' and click on create. Login using your Gmail account.
- Click on 'if this add'.
- Search 'Google Assistant' and select it.
- Click on 'Say a simple phrase'.
- Define the statements you want to use while triggering the command. It asks for three sentences. For turning on the lights, I used 'Turn on the lights', 'Please turn the lights on', and 'Lights on'.
- Enter the assistant's response. In this case 'Switching ON the lights'.
- Click on 'create trigger'.
- Click on 'Then That add'.
- Choose 'Webhooks'.
- Enter GPIO control command (URL).
- Select GET method. GET is a common HTTP method used to request data from a specified resource.
- In content type choose 'application/json'.
- Click on 'create action' at the bottom of this page.
- Then click on 'continue' and 'finish'.
- For turning off the lights, I used 'Switch off the lights', 'Lights off', and 'Please turn off the lights'.
- Enter the assistant's response. In this case 'Switching OFF the lights'.
- Click on 'create trigger'.
- Click on 'Then That add'.
- Choose 'Webhooks'.
- Enter GPIO control command (URL).
- Select GET method. GET is a common HTTP method used to request data from a specified resource.
- In content type choose 'application/json'
- Click on 'create action' at the bottom of this page.
- Then click on 'continue' and 'finish'.
This project used voice to turn on the lights. Using voice as a command can be very efficient and convenient for individuals. Voice controlling feature reduces those inconvenient moments required for switching on and off the appliance. Using software and applications like IFTTT, google assistant, and webhooks reduced code complexity. Giving voice commands to a machine is a time-saver in this fast running world.









Comments