|Software apps and online services:|
The project originated from hesitation to get up in middle of the night to turn fan/heater on off. One should be able to do it by pulling out phone from under the pillow.
Using an Android/Windows phone, a person will be able to find paired Bluetooth device, connect to the desired device and be able to turn fan/heater on/off from it. It can also be used to turn coffee machine on when you wake up.
The phone communicates with JY-MCU Bluetooth shield that is connected to Arduino. Arduino listens to the on/off commands and activates its GPIO accordingly. This effectively turns the power relay on/off. You can connect any appliance such as fan/heater/coffee machine to it.
It requires assembly of the hardware and an app. The App can be downloaded for Android or for Windows Phone. For those want to build it themselves, the source is on GitHub (https://github.com/sameerkapps/smart-switch)
Building Arduino Hardware:
Step 1: Connect Bluetooth
Connect TX pin of Bluetooth to Digital pin 11 of Arduino
Connect RX pin of Bluetooth to Digital pin 10 of Arduino
Step 2: Connect LED
Connect LED and resistor to digital pin 7 of Arduino
Step 3: Connect the relay
Take a power cord and cut one of its wires to connect to relay. Connect one end to the common terminal of the relay and other to the NO (Normally Open) terminal of the relay. Be careful that the strands do not touch any other parts. Connect relay to Arduino as per schematics. Ensure that Relay is on non-conductive surface and preferably in non-conductive enclosure. This is important because the bottom part of the RELAY exposes HIGH VOLTAGE FROM the main electrical line. DO NOT Connect cord to main yet.
Connect Pin In1 of Relay to Digital Pin 6 of Arduino.
Step 4: Upload code to Arduino
The code is provided in https://github.com/sameerkapps/smart-switch
Upload it to Arduino.
In the Setup, it configures Arduino pins and starts the serial port via Bluetooth.
In the loop, it will listen to the commands from Bluetooth and turn LED and Relay on/off accordingly.
Pairing up the Phone
The app connects to one of the paired Bluetooth devices. So it is important to pair up the phone with the device.
(From Android/Windows Phone):
- Go to Settings,
- Turn on the Bluetooth. Look for device. Its name would be similar to HC-06.
- Tap on Pair.
- You may have to enter manufacturer’s password.
You can either download the app or build it yourself.
Windows Phone Store - http://windowsphone.com/s?appid=dd4b173f-4179-413d-b9af-7bd2c753d55d
This app is not there on the Apple store.
If you choose to download it, you can go to How to use App.
Building the App
The App requires Xamarin Studio (for Android App) and Visual studio 2013 for Window Phone App.
This step may require related licenses for the software and for developing apps.
The code can be downloaded from
It also requires open source Nuget package MvvmCross.
Details of the software are on my blog.
Running the App
It is important that the Arduino is paired with the phone prior to using the App. The app works only with the paired devices.
Start the App
Select the desired device. (It will be something like HC-XX if you use JY-MCU)
Wait for it to display “Connected Successfullly”.
Toggle Off to turn the device on. This will change text on button to On.
This should turn LED on. It should also turn on light on the relay. Once
Toggle the button to turn it off.
This should turn LED and relay light off
Now make sure that relay is not touching any conductive surface and connect its power cable to electrical outlet and the fan/heater. Have fun turning the device on/off from your phone.
Source code for the App
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!