Friday, April 29, 2016

How to control Electrical appliances from android mobile

Hi , do you want to control all your electrical devices at your home controlled from your android mobile, do you want to create your own app to achieve this task, This post explains step by step procedure to create android app for controlling electrical appliances using MIT app inventor. you don't need to rely on 3rd party to control your home devices. This simply act as a Home automation where you can control everything from your phone. all you need is an android phone , an arduino , bluetooth module ( I've used HC-05) and a Relay.

You don't need to use particularly arduino to make this project, you can use any micrcontroller to make this project. I've controlled only 3 devices for this project, it can be extended to many devices. all you need to do is create extra buttons in the app and have more I/O's in the microcontroller side. I used Arduino because there are many shields available for this particular controller in the market and more tutorial and community to help you out. 



check the link for transfer of android apps to your phone here



Arduino Program
____________________________________________________________________________________

#include <SoftwareSerial.h>

SoftwareSerial BT(10, 11); //TX, RX respetively
String device;

void setup() {
 BT.begin(9600);
 Serial.begin(9600);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);


}
//-----------------------------------------------------------------------// 
void loop() {
  while (BT.available()){  //Check if there is an available byte to read
  delay(10); //Delay added to make thing stable
  char c = BT.read(); //Conduct a serial read
  device += c; //build the string.
  } 
  if (device.length() > 0) {
    Serial.println(device);

  if(device == "doneon")
  {
    digitalWrite(3, HIGH);
  }

  else if(device == "doneoff")
  {
    digitalWrite(3, LOW);
  }

  else if (device == "dtwoon")
  {
    digitalWrite (4,HIGH);
  }

 else if ( device == "dtwooff")
 {
   digitalWrite (4, LOW);
 }

 else if (device == "dthreeon")
 {
   digitalWrite (5, HIGH);

 }

 else if (device == "dthreeoff")
 {digitalWrite (5, LOW);}

device="";}} //Reset the variable

No comments:

Post a Comment