Use an Arduino, an Android smartphone, and our free app to connect your devices and automate your home.
DIY SmartHome application
Are you interested in automating your home? Would you like to control the lights, fan, and other appliances from your smartphone? Our DIY Android Home Automation project will show you how to start connecting your devices and automating your home using an Android smartphone. This requires no experience with Android programming at all, and a free application is included for you to develop. Using this Android application, you will be able to control your lights, air conditioning, and door locks, all from your smartphone. This system uses Bluetooth to connect with your device and control the various appliances in your home. Have fun with this home automation tutorial!
How Does Android Home Automation Work?
The DIY Android Home Automation project comes with a free application called "DIY SmartHome". This application controls the various appliances connected to your Arduino and relays. When the toggle buttons on the application are pressed, corresponding Bluetooth signals are sent from your Android phone to the Bluetooth module you have hooked up to your Arduino. The Arduino finds out which signal was sent and compares it to the predefined signals assigned for each appliance. When it identifies that signal, the Arduino activates the relay hooked up to its digital pin by passing 5V through it. Thus the relay is switched on and the corresponding appliance connected to the relay is turned on as well. To switch it off, Arduino passes a 0V or logic low to its digital pin.
Setting Up the Connections for the DIY Android Home Automation Project
DIY Android Home Automation Wiring Diagram
The connection diagram for Arduino is as shown. For setting up this system, wiring connections have to be made between the Arduino and Bluetooth module, and also with the relays. Here, the Bluetooth Module's Tx is connected to Arduino Rx (digital pin 0) and the module's Rx to Arduino Tx (digital pin 1). The module's 5V and GND are connected to the Arduino's 5V and GND.
The relay you're using is SPDT, and it has 5 pins on the underside. As shown above, here pins 1 and 3 are the coil pins. Pin 1 is connected to the Arduino digital pin, and 3 is connected to Arduino GND. Pin 2 is the common contact in the relay to which you have to connect the power for your appliance (AC 230V), and 4 is the pin to which you have to connect your appliance wire.
Connecting Your Appliance to the Relay
In a normal SPDT relay, whose pin out is shown in the above step, pins 2 and 4 act identically to the two terminals of a switch. When a digital HIGH voltage is applied from the Arduino to the relay, the switch turns on, and when the voltage is withdrawn, it turns off. You can attach this system you made to a normal switchboard by extending the wires from behind the switches in the board to your relay. As seen in the connection diagram in the above step, you have to connect a power AC line to the common terminal of all the relays. Then, you have to extend the wires from behind the switchboard of the corresponding lights/lamps you wish to control. Each of these wires is connected to the "NO"(Normally Open) terminal of the relays (pin no. 4 in step no 1's relay pin-out diagram).
NOTE: If you wish to control door locks, you may use door lock solenoids, which can be purchased and connected to your system and turned ON/OFF the same way. The picture below shows how you can attach the system to your switchboard (keep in mind, this is just to show you the arrangement, it is not the original system being described here):
Creating a Custom PCB for the DIY Android Home Automation Project
If you wish to create your own custom PCB, please use the above schematic. You just have to insert an Arduino bootload ATmega 168/328 chip in the socket to get it working. All the supporting circuitry for the Arduino is included.
Loading the Arduino Software
Arduino DIY Android home automation code
If you are new to Arduino, download the Arduino IDE (Integrated Development Environment) from Arduino. The tutorials for beginners can be seen in this Arduino tutorial. The Arduino code for the following project is here: DIY_SmartHome. The code is really simple. It checks the incoming Bluetooth signal via the Bluetooth module and then compares (ASCII values) using an "if" statement with previously defined values. If it matches the value, the relay is activated using the "digitalWrite(pin,HIGH)" command, which passes 5V to the Arduino digital pin.
PLEASE NOTE: SINCE THE BLUETOOTH MODULE IS CONNECTED TO THE RX AND TX PINS OF THE ARDUINO, THE MODULE SHOULD BE REMOVED WHILE UPLOADING THE CODE FROM PC TO THE ARDUINO. THE MODULE SHOULD BE CONNECTED ONCE THE UPLOAD IS COMPLETE.
Upload the code to your Arduino board, then follow step 5.
Downloading the Android Application and Setting Up Bluetooth
Discovering new Bluetooth devices
To download the Android application to your phone, copy this .apk file to your phone from the PC and then click on it from the phone to install it: DIY SmartHome. For those who wish to modify the application, I am attaching the project file here: DIY SmartHome project. Be sure to check “Allow installation of non-Market apps” in the Security tab under settings. Once you have installed the application, before opening it you need to pair and connect it with your Bluetooth module. For this, you need to power the Arduino and Bluetooth module and then turn on the Bluetooth of your phone and make it visible to other devices. After that, search for new devices in Bluetooth, select your Bluetooth module from the list, and enter the pairing code when prompted (it is usually 1234 or 0000).
Note the name of your device—in this case, it is “HC-06″. After pairing with the system, go to the “DIY SmartHome” application and enter the name of your Bluetooth module you noted earlier (case-sensitive) and click “OK”. After that, the phone will get connected to your system, and by clicking the respective buttons, the appliances turn ON/OFF. Have fun with your new DIY Android home automation system!