Home Automation With Arduino

Hello guys, in this post I will be telling you how to control electrical appliance from your android phone via bluetooth.I will be using an arduino board for building this project.

Arduino is a developmental board which can be programmed and use to build projects according to our needs if you want to know more click here.

 MATERIALS REQUIRED

 LET'S Begin With The Code

To upload the code we will need a software called arduino IDE.To download it click here.
Copy paste the code given below and upload it to arduino UNO board.Keep in mind that you have selected correct board and port before uploading the code.To know more about programming click here.

 
int state=0;
void setup() {
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    Serial.begin(9600);
}

void loop() {
  if (Serial.available()){
        state=Serial.read();
        if (state==0){
          digitalWrite(5, HIGH);
        }
        else if (state==1){
          digitalWrite(5, LOW);
        }
        else if (state==2){
          digitalWrite(6, HIGH);
        }
        else if (state==3){
          digitalWrite(6, LOW);
        }
         else if (state==4){
          digitalWrite(7, HIGH);
        }
         else if (state==5){
          digitalWrite(7, LOW);
        }
         else if (state==6){
          digitalWrite(8, HIGH);
        }
         else if (state==7){
          digitalWrite(8, LOW);
        }
     }
}


Connections

Arduino Projects
      
Connect the relay ground to the ground of arduino UNO board (the board has three ground pin, connect with any one of them) and connect vcc to 3v power supply. Connect relay's in1, in2, in3 and in4 pin to digital pin 5,6,7 and 8 on the arduino board respectively.

Now connect blutooth module's tx pin to rx on the board and rx pin of module to tx pin on board.Connect 5v of bluetooth to 5v  on UNO board and ground pin to any ground on the arduino.
(Note:-before connecting all the components don't forget to upload the code to the board to avoid any errors)
The way you connect wires in the switch similarly connect the wires in the left and center outlet of relay called as normally closed and common respectively.Here we are replacing our normal switch with relay which will serve us the purpose of switch.
 
Android App

First of all power your arduino board and pair your phone with bluetooth module(named:-HC-05).If it asks for password the default password is '1234'.
Download the android app from here. 
Open the app and wait for the main screen to be displayed.Now select the bluetooth from list of all paired devices by clicking on 'Select Bluetooth'.
Now you can individually control all the relay by pressing ON and OFF button. 
Oldest