Have you ever felt like controlling your home appliances such as fan, light, geyser, etc. working on wall mounted switches remotely? Well, you could always use the relay module to control them but what if you want to use this device on a different switchboard? It will be quite difficult to disconnect the relay module each time to control switches in different rooms of house. So I came up with this project using a servo motor which toggles the wall mounted switches ON and OFF in 3 different remote control ways i.e Google assistant, Android app and Hand gestures. A simple arrangement using one more motor helps to move the servo motor from one switch to another. In this project I have demonstrated control of 2 switches.
2. WORKING3. BUILDING THE PROJECTLet us now see step by step guide to building the project.
Step 1:Getting the Bolt API Key and Device ID
Login 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.
Next click on the copy button to copy your API key. Your API key will may look something like this: f1f918e9-d9c2-4e5b-aed0-b7cb743f74cf
Step2:Creating the UART Control Command
Since we are using Arduino Uno in this project to perform the functions, we need to send a string to the Arduino board from Bolt Wifi module. This can be done by using serial Write command under UART commands.
Click here Bolt Cloud go to Docs Tab -> API Documentation -> UART Commands API -> Send Serial Data Output, to understand how to create a API command link to send a string to Bolt.
The structure of the command is:
https://cloud.boltiot.com/remote/API_KEY/serialWrite?data=STRING&deviceName=DEVICE_ID
The parameters that you need to replace are:API_KEY: You can get it from API tab on cloud dashboard.STRING: This is the string that we will send to Arduino through Bolt. We will decide which strings to send, later while writing the code for Arduino. DEVICE_ID: The id of your device. You can get it from cloud dashboard.
The sample command to send a string "f" over the TX line of device having ID BOLT13819450 is:
https://cloud.boltiot.com/remote/f1f918e9-d9c2-4e5b-aed0-b7cb743f74cf/serialWrite?data=f&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.
Since we will use three methods i.e Google assistant, Android app and Hand gesture for controlling the switches let us see how to setup each method.
Step3:IFTTT integration via Google Assistant and Webhooks
Go 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) turn on the light
b) put on the light
c) put the light on
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.
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'
So whenever we want to turn on the lights, we send a string "f" to the TX line of Bolt.
Now you have to follow same procedure to send strings "d", "s", "a" to turn off the lights, turn on the fan and turn off the fan respectively. Use suitable phrases.
The sample code for turning off the light would be:
That's it. You are done.
Now wake your Android phone by saying "OK Google" and say the phrase you had set while creating the trigger to use your appliances remotely.
Step 4 :Creatingan Android application using MIT App Inventor2
Go to MIT App Inventor by clicking here. Create a free account and click on Create Apps! Then click on Start new project.
Below is the design of the app I created. You can view the components I added on the right side.
After the design is complete, click on the Blocks tab besides Designer tab. And add the blocks to get the following sketch on Screen1.
Create four more Screens with names LightsON, LightsOFF, FanON and FanOFF.
Below is the image of Screen LightsON.
Create similar blocks for rest of the three screens.
Remember to change the URL highlighted in red color with the commands we created before that is:
https://cloud.boltiot.com/remote/API_KEY/serialWrite?data=STRING&deviceName=DEVICE_ID
The parameters that you need to replace are:API_KEY: You can get it from API tab on cloud dashboard.STRING: This is the string that we will send to Arduino through Bolt. ( "f", "d", "s", "a")DEVICE_ID: The ID of your device. You can get it from cloud dashboard.
Get the.apk file from BUILD tab and your android app is ready!
Step5:Hardware connections
The connections are as follows:
Arduinopin2 ---> Input pin Servo.
pin 3, 4 --> Input 1, 2 of L293D motor driver.
pin 7 ---> LED
pin 11 ---> Echo pin Ultrasonic sensor
pin 12 ---> Trig pin Ultrasonic sensor
pin A1 ---> Output pin of LM35 temperature sensor
pin TX ---> pin RX of BOLT wifi module
pin RX ---> pin TX of BOLT wifi module
Give 3.3v, 5v and Gnd for necessary components as shown in schematic diagram.
Step 6:Upload code to the Arduino board
Upload the below given code into the Arduino.
NOTE: WHILE UPLOADING THE CODE TO THE ARDUINO BOARD DISCONNECT THE TX AND RX PINS TO THE BOLT MODULE.
4. CONCLUSIONThat's it! Now you can make a similar hardware arrangement as I made as per the need of your switchboard.
Use the google assistant or android app or even hand gestures using ultrasonic sensor to toggle on and off the switch positions you have programmed.
Comments