Introduction: Talk to All Your Devices. Google Now Integration With Arduino (Smartphone/Smartwatch)
“Take control”, this is the watchword of the contest in which I participate with this my first INSTRUCTABLES.
Just take control, it is the purpose of this project. Taking control of our home, of our office, of the electronic devices or also of the home appliances. But take control means having the command, and have command means to giving orders, and what better way to give an order, of a direct and instant voice command?
Voice commands, because of their immediacy and simplicity, are becoming more common and integrated, but how can we exploit it?
An ARDUINO is enough! Just harness the microphone and the speech synthesizer of a common smartphone / tablet Android to control an Arduino with our voice, letting him do the rest.
Here are the macro steps that will follow:
-1 COMMAND AND CODE
First of all we decide what to do with Arduino, to the event of our particular command. To facilitate the planning, we make a list of commands, which correspond to a code that Android will send to Arduino (through the Bluetooth) every time that the commands are spoken.
-2 SEND THE COMMAND
For sending this code, we will use a famous Android App created for automate in a practical and easy way. The App is TASKER, and offer an infinity of combination and personalized automation, that are increased with its plugins, with which it interacts and it integrates.
Therefore we will create some “task” that will send the codes associated with the command we have spoken, to the Arduino. For doing this we will use the Plug-ins “AUTO VOICE” that allows the recognition of the voice command, and the integration with google now, “AUTO APP for ARDUINO” to create a dialogue with Android and Arduino, and “AUTO WEAR” if we want extend this functionality to a smartwatch with Android Wear OS.
-3 RECEIVE THE COMMAND
To prepare Arduino to the reception of the codes, we will put in “listening” on the Bluetooth communication, and will program it to start a different operation for each received code.
We make the necessary connections and we are ready to “Take Control”, with only our voice!.
- Arduino board
- Bluetooth module for Arduino (HC-05)
- Relay module
- Electric socket x2
- Light bulb (with his socket)
- Smartphone/Tablet with Android OS
- *Smartwatch with Android Wear OS*
- Tasker app and his Plug-In Auto Voice, Auto app for Arduino and *Auto Wear*.
*Only if you want to use voice command with your smartwatch well as on the smartphone.
Step 1: List of Command
In our example we command a light bulb and two electrical sockets (black and white). Having the following command, we correspond a code for each one.
“Turn on the light” ______________________________________LON
“Turn off the light” ______________________________________LOFF
“Switch on the white socket” ____________________________SWON
“Switch off the white socket” ____________________________SWOFF
“Switch on the black socket” ____________________________SBON
“Switch off the black socket” ____________________________SBOFF
“Switch on” __________________________________________AON
“Switch off” __________________________________________AOFF
Step 2: Play Store
Download and install the app needed:
TASKER and the plug-in AUTO VOICE , AUTO APP FOR ARDUINO, AUTO WEAR.
I recommend paying all software for greater usability. Alternatively you can activate the trial version of 7 days.
Step 3: Auto-Voice Settings
We have to enable the integration of voice commands with “Google Now”
Follow the images.
Step 4: Auto App for Arduino Settings and BT Connection
We have to connect our Arduino to our Smartphone. To do it turn it on to also turn on your Bluetooth module (if you do not know how to, follow the wiring diagram on the last step).
Afterwards we have to do the paired between our device and the bluetooth of Arduino, and configure the plug-in Auto App for Arduino ( as in the images).
Step 5: Smartwatch Configuration
To enable the functionality also on a smartwatch, once installed the plug-in “AUTO WEAR” you have to configure it directly from the watch.
The “shake event” it allows you to enable the function of vocal command with a gesture of your wirst , and not only with the phrase “Ok Google”.
NB: There are a little differences between Android Wear 2.0 and the previous versions. On 2.0 version we have the play store on our wearable device and we must to download AutoWear from it, then install it; On the previous versions we have already on the watch if we have it on the smartphone. On the previous versions of Androi Wear the voice research of Google was integrated with the command of Tasker ( of Auto Voice) as the smartphone do; On 2.0 version we have another window of voice research (because Google don’t react to our command) and we have to confirm our spoken command with a tap every time.
Step 6: Recognize Command and Sending to Arduino
To teach to Arduino the command that we want, we have to launch
TASKER > PROFILE > + > EVENT > PLUG-IN > AUTO VOICE > RECOGNIZED
And in the configuration “Command Filter” set the first command to which Arduino will react (for example “turn on the light”). Whit the command “speak filter” we can also speak the command directly.
Then we have to link an activity for that particular command
NEW ACTIVITY > “Name of activity” > + > PLUG-IN > AUTO ARDUINO > WRITE PINS
And in the configuration we have to choose “Direct Command” and write the code of command previously insert (for example “LON”).
Repeat the procedure for every command that you want to make.
for the first connection, after the paired, we have to create an activity that allows the dialog between the BT of Arduino and the BT of our Android device. For starting this activity we can create another vocal command. The activity for the connection must be this:
TASKER > ACTIVITY > + > “Name of activity” > + > PLUG-IN > AUTO ARDUINO > CONNECTION > CONFIGURATION > ARDUINO and select the name of your BT module in Arduino. This activity must be connect with a profile, that recognize the command “connection” for example.
Step 7: Programming Arduino
Now we have to configure the Arduino, taking into account the pins that we will use, in this case the following:
2,3______________RX,TX of the BT module
8 _______________Light Bulb
10 ______________Black Socket
The following commented sketch , to compile in the IDE of Arduino, allows you to read the state of the Bluetooth signal, and we will develop the code for execute the action that we want, depending of the command that the Arduino receive.
In our example we will take to an high state (5v) the pins when the Arduino receive the command “xxON” and to a low state (0v) when receive the command “xxOFF”.
This sketch allows you also to read the command that Arduino receive, thanks to the Serial Monitor.
Step 8: Installation
Follow this wiring diagram for the installation.
If you liked this project, vote me for the “MICROCONTROLLER” contest of INSRUCTABLES.COM
Thanks for watching!
We have a be nice policy.
Please be positive and constructive.