Take your Android smartwatch to the next level by connecting it to a 5V relay with an Arduino over Bluetooth.
Do you want to use your smartwatch to control things around you? This can be done very easily within a few hours! In this tutorial, I will show you how to control your home appliances with an Android Wear watch. I’ll be using the Moto360 watch, but you can install the app in any Wear OS (formerly Android Wear) watch. At the end of this project, you will be able to control any electrical device with the flick of your wrist.
Hardware Requirements
Any Wear OS watch (I'll be using my Moto360 watch for this tutorial)
Hardware Assembly
Connect the hardware as shown in the schematics below.
Connect your Arduino UNO to the HC-06 Bluetooth module.
Please be careful with this step! Remove the electric supply first. This will work as a switch, so remove the physical switch and connect to relay pin NC and COM and tighten the screw.
Install Arduino Software
You can install Arduino IDE by on Arduino's website.
Once installed, open Arduino IDE and connect your Arduino UNO with a USB cable.
Upload the Source Code
This code uses Arduino’s serial communication protocol with the Bluetooth module. The RX and TX pins of the Arduino connect to the TX and RX pins of the HC-06 Bluetooth module, respectively.
The Bluetooth module receives data from the paired Android smartwatch and triggers the relay based on the received data.
The code behind this is pretty simple. If the received data is the character "1", the relay will be triggered and turned on, and if the received data is the character "0", the relay will be turned off.
//--------BT app control---------//
//Program for four switches but in our case we are using pin 11
int switch1=11;
int switch2=12;
int switch3=8;
int switch4=7;
int Received=0;
int switch1_state =0;
int switch2_state =0;
int switch3_state = 0;
int switch4_state = 0;
void setup(){
Serial.begin(9600);
pinMode(switch1,OUTPUT);
pinMode(switch2,OUTPUT);
pinMode(switch3,OUTPUT);
pinMode(switch4,OUTPUT);
}
void loop(){
if(Serial.available()>0)
{
Received = Serial.read();
}
////////////////switch1/////////////////////
if (switch1_state == 0 && Received == '1')
{
digitalWrite(switch1,HIGH);
switch1_state=1;
Received=0;
}
if (switch1_state ==1 && Received == '1')
{
digitalWrite(switch1,LOW);
switch1_state=0;
Received=0;
}
////////////////switch2/////////////////////
if (switch2_state == 0 && Received == '2')
{
digitalWrite(switch2,HIGH);
switch2_state=1;
Received=0;
}
if (switch2_state ==1 && Received == '2')
{
digitalWrite(switch2,LOW);
switch2_state=0;
Received=0;
}
///////////////////////////////////////////
////////////////switch3/////////////////////
if (switch3_state == 0 && Received == '3')
{
digitalWrite(switch3,HIGH);
switch3_state=1;
Received=0;
}
if (switch3_state ==1 && Received == '3')
{
digitalWrite(switch3,LOW);
switch3_state=0;
Received=0;
}
///////////////////////////////////////////
////////////////switch4/////////////////////
if (switch4_state == 0 && Received == '4')
{
digitalWrite(switch4,HIGH);
switch4_state=1;
Received=0;
}
if (switch4_state ==1 && Received == '4')
{
digitalWrite(switch4,LOW);
switch4_state=0;
Received=0;
}
}
Install apk in Wear OS
Download the apk file for the smartwatch app.
Using ADB over Wi-Fi, follow these steps to install the app on your smartwatch:
- Go to dev setting on your watch, and turn ON ADB and Bluetooth ADB.
- Go to Bluetooth setting in Android Wear app on your phone, and Turn the ADB over the Bluetooth.
- Get basic adb on your computer: https://www.xda-developers.com/google-releases-separate-adb-and-fastboot-binary-downloads/
- Connect your phone with the computer and turn on the ADB USB option in Developer
- After this setup In your computer, open the console in the folder that contains the ADB files and apk.
- Perform the command: adb Devices, adb forward tcp:6666, localabstract:/adb-hub, adb connect localhost:6666
- After establishing a connection with the watch choose "adb -e install apkname.apk".
- Replace apkname with BluetoothWatch-debug.apk with the right path if you are outside the directory containing the file.
The menu you need to access in the second step listed above.
How the commands will look after proper installation of the app.
How to Pair Your Bluetooth Device
After installation, connect your smartwatch to the HC-06 module.
You need to pair the HC-06 Bluetooth module with your Android smartwatch before you can use it in the app.
You should see the HC-06 device available on your smartwatch.
Now follow these steps:
- Open your device's Bluetooth settings and search for new devices, make sure the LED on the HC-06 module is blinking continuously (Pairing Mode).
- Select HC-06 (or you'll see an address ending with "C" as shown in the pictures).
- Enter the PIN "1234" and press OK.
- Open the "Wear OS” app and click the Bluetooth button on the top of the screen.
- Select "HC-06" from the list.
- Use the switch with the icon of a lightbulb or shake the watch to turn the relay ON/OFF. Make sure your Arduino is already uploaded with the code above.
- Click the settings icon if you want to adjust the shaking calibration.
And that's it! Your smartwatch is now connected. You can now control the 5V relay through your watch via Bluetooth.
To watch the project take shape from start to finish, watch the video below.