Home Automation System Using a Simple Android App

By Karthik Rajasekaran

- Advertisement -
 

efy testedNowadays, people have smartphones with them all the time. So it makes sense to use these to control home appliances.

Presented here is a home automation project using a simple Android app, which you can use to control electrical appliances with clicks or voice commands. Commands are sent via Bluetooth to Arduino Uno. So you need not get up to switch on or switch off the device while watching a movie or doing some work.

Home automation: circuit and working

The home automation circuit is built around an Arduino Uno board, Bluetooth module HC-05 and a 3-channel relay board. The number of channels depends on the number of appliances you wish to control. Arduino Uno is powered with a 12V DC adaptor/power source. The relay module and Bluetooth module can be, in turn, powered using a board power supply of Arduino Uno. Author’s prototype is shown in Fig. 1. Connection details for each appliance are shown in Fig. 2.

home automation using android
Fig. 1: Author’s prototype
Fig. 2: Connections for the appliances
Fig. 2: Connections for the appliances

Bluetooth module

- Advertisement -

Bluetooth module used in this project is HC-05 (Fig. 4), which supports master and slave mode serial communication (9600-115200 bps) SPP and UART interface. Using these features it can communicate with other Bluetooth-enabled devices like mobile phones, tablets and laptops. The module runs on 3.3V to 5V power supply.

Fig. 3: Control panel on Android smartphone
Fig. 3: Control panel on Android smartphone

Relay module

A relay allows you to turn on or turn off a circuit using voltage and/or current much higher than what Arduino could handle. Relay provides complete isolation between the low-voltage circuit on Arduino side and the high-voltage side controlling the load. It gets activated using 5V from Arduino, which, in turn, controls electrical appliances like fans, lights and air-conditioners. An 8-channel relay module is shown in Fig. 5.

Arduino Uno board

Arduino is an open source electronics prototyping platform based on flexible, easy-to-use hardware and software. It is intended for artists, designers, hobbyists and anyone interested in creating interactive objects or environments.

Arduino Uno is based on ATmega328 microcontroller (MCU). It consists of 14 digital input/output pins, six analogue inputs, a USB connection for programming the onboard MCU, a power jack, an ICSP header and a reset button. It is operated with a 16MHz crystal oscillator and contains everything needed to support the MCU. It is very easy to use as you simply need to connect it to a computer using a USB cable, or power it with an AC-to-DC adapter or battery to get started. The MCU onboard is programmed in Arduino programming language using Arduino IDE.

Fig. 4: Bluetooth module
Fig. 4: Bluetooth module

In this home automation project circuit, Pins 10 and 11 of Arduino are connected to pins TXD and RXD of the Bluetooth module, respectively, as shown in Fig. 6.

Pins Gnd and Vcc of the Bluetooth module are connected to Gnd and +3.3V of Arduino board respectively. Pins 2, 3 and 4 are connected to the three relays (RL1, RL2 and RL3) of the relay board. Pins Vin and Gnd of the relay board are connected to pins Vin and Gnd of Arduino board, respectively.

Note. Vin is usually used to give input power, but since we are supplying 12V to Arduino using an adaptor, we can use Vin pin on Arduino to power the 12V relay module.

Fig. 5: An 8-channel relay module
Fig. 5: An 8-channel relay module
Fig. 6: Relay module connection
Fig. 6: Relay module connection

Software

The software program for the home automation project(homeautomation.ino) is written in Arduino programming language called Processing. Arduino Uno is programmed using Arduino IDE software that you can download from arduino.cc. MIT App Inventor software was used to create the Android app (.apk) for this project.

The app on your smartphone sends data when you click on buttons or feed voice commands via Bluetooth in the mobile to Bluetooth module HC-05 connected with Arduino board. Received data pin TXD of the HC-05 is connected to Arduino. Arduino Uno processes the received data and controls the relay board accordingly.

Procedure for installing the Android app (.apk) is as follows:
1. Download the app (homeautomation.apk).
2. Run .apk file. It will prompt you to complete the action. Click Package Installer and then Install.
3. You will also need a voice-recognition app on your Android smartphone. Most smartphones have this app preinstalled. If you do not have it, download one from Google Play Store.

Download source folder: click here

Construction and testing

Assemble the circuit as shown in the circuit diagram. Open Arduino IDE and compile the program (sketch). Upload the sketch (homeautomation.ino) to Arduino board. Switch on the power supply to Arduino by connecting it to 12V power source. Pair Bluetooth module with your Android phone. Type password ‘1234’ (default password) of Bluetooth module.

Click Bluetooth Image on the app to connect it with the Bluetooth module. It automatically connects and displays as Connected in the app.

You are now ready to control the appliances using the app. You can either use on/off buttons or voice commands to control the appliances. You can control more electrical appliances by increasing the number of channels in the relay. For instance, using an 8-channel relay, you can control up to eight devices. For this, you need to alter the source code by adding input commands and voice commands to control the devices.


Karthik Rajasekaran is a third-year ECE student at Info Institute of Engineering, Coimbatore

More projects are available at: Electronics Projects

This article was first published on 16 August 2018 and was recently updated on 10 December 2018.

210 COMMENTS

    • No. In this project, the relay board used here requires 12V power supply. So an external 12V DC adaptor for the Arduino board is used instead of USB cable. Therefore, 12V is reflected at Vin pin of the Arduino board, which is used to power the relay board.

  1. sir…can we use arduino nano or arduino mini insted of arduino uno? n can we add more relay and on/off button in apk after using another digital pin of arduino n programing as acording to pin?……..thank you for your answer……

  2. Hi Sir, Could you send me the source code of the application? I am also creating the same kind of application for my TY project but there are errors. So could you please help me out and send the source code for the application just for reference ?

    • Upload this code into your Arduino board. Make sure you pair the Android Bluetooth with the Bluetooth connected in the circuit. Next, turn on or off ‘Light1’ button on your Android. If the light is still not turning on/off, check the corresponding relay connection.

  3. It’s not working properly,can you help me.
    connectionsm are ok, but it is not responding and when responding its like get confuse and execute any command whatever its wants to..
    Iam using 3 individual relay and relay driver …

  4. As per your instructions I connected the circuit, uploaded the program, paired Bluetooth module with my android mobile & ur app and used a 12volt dc adapter to power the Arduino, still it is not working. Can u define where is the problem?

  5. Hi Thanx for this tutorial
    I have one question that if we are connected switch board with relay that is fine but how about actual Switch board work
    if i have no phone with me then can i start switch manually ?

  6. hi
    i installed your .apk app in my mobile and is connected with hc05, but when i pressed any button on .apk app ,on serial monitor getting different string (different characters are displaying) so the if condition in program is not matching .plz rectify my problem.

  7. Hi
    I have made this and implemented in my bedroom with light and fan.
    Its working really great.

    But i observed 2 issues. Please help me resolve it.
    1. Appliance are depending on only on Arduino, how to make manual connection as well.

    2. If appliance are running and suddenlypower goes off. Appliance does on automatically everything need to switch on again from mobile phone.

    Please help to overcome these issues.
    Thanks

  8. Hi
    I have made this and implemented in my bedroom with light and fan.
    Its working really great.

    But i observed 2 issues. Please help me resolve it.
    1. Appliance are depending on only on Arduino, how to make manual connection as well.

    2. If appliance are running and suddenlypower goes off. Appliance does on automatically everything need to switch on again from mobile phone.

    Please help to overcome these issues.
    Thanks

  9. I have made all the proper connection and uploaded program to Arduino Uno and connect relay module and bluetooth hc-05 to Arduino and my mobile.but i’m facing a problem as i turn ON 12v power supply relays automaticaly turn ON and i can’t OFF it.i’m using optocoupler based 8 relay module which operates on 12v dc supply but its not working,should i use 5v relay module? Plz reply.

  10. Sir this is a wonderful project and i liked it vary much. i am thinking of making this project but i need help to create the app according to my requirement. can u plz tell me details about how to make the app u use here.
    thanks.

  11. Arduino: 1.8.5 (Mac OS X), Board: “Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck, Disabled, None”

    Archiving built core (caching) in: /var/folders/xk/9wqzb4p15fnb9z49ncdflsl40000gn/T/arduino_cache_32786/core/core_esp8266_esp8266_generic_CpuFrequency_80,FlashFreq_40,FlashMode_dio,UploadSpeed_115200,FlashSize_512K64,ResetMethod_ck,Debug_Disabled,DebugLevel_None_____aaea6d57e9c1493124cadab90bd5ad9f.a
    Sketch uses 224069 bytes (51%) of program storage space. Maximum is 434160 bytes.
    Global variables use 32004 bytes (39%) of dynamic memory, leaving 49916 bytes for local variables. Maximum is 81920 bytes.
    warning: espcomm_sync failed
    error: espcomm_open failed
    error: espcomm_upload_mem failed
    error: espcomm_upload_mem failed

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

  12. Hi EFY Team,
    Excellent Project.
    i have connected all the components and as per the diagrams shown. but it is not working as desired..
    i confirm, Arduino program has been uploaded, HC-05 is been connected in mobile, indicator for relay module are ok.
    Kindly help.

SHARE YOUR THOUGHTS & COMMENTS

 
 

What's New @ Electronicsforu.com

Most Popular DIYs

Electronics Components

Truly Innovative Tech