loading

Now we can control full home with smart Phone

Step 1: Hardware Required

for home automation you can add different things i choose switching or relay

In this project you will control switcher by mobile .if mobile is not present you can also operate with keypad

I also add lcd in the project to see the the present status of switches.

hardware required in this project

Android Mobile

jumper cables

16 * 2 LCD display

HC-06 Bluetooth Module

Arduino uno or MEGA

Bread Board

10k ohm varible for LCD

Relay Module

For making own relay Module

Relay

Transister

Resisters

PCB board

Step 2: Software Required

https://play.google.com/store/apps/details?id=com....

Download this app for home automation it can control 8 relay at a time

Its also have a timer.

To program on arduino use Arduino IDE which is available on

https://www.arduino.cc/en/Main/Software

Step 3: Programming for Bluetooth Module and Relay Module

this is the wiring sequence of relay module and relay module

This program is only for bluetooth and relay module

<p>#include <SoftwareSerial,h></p><p></p><p>SoftwareSerial mySerial(1, 0); // 1-RX, 0-TX - </p><p>int ch1 =  A0;
int ch2 =  A1;
int ch3 =  A2;
int ch4 =  A3;</p><p> void setup()
 {
 mySerial.begin(9600);</p><p> 
 pinMode(ch1, OUTPUT);
 pinMode(ch2, OUTPUT);
 pinMode(ch3, OUTPUT);
 pinMode(ch4, OUTPUT);</p><p> }</p><p> void loop()
{</p><p> char caracter = mySerial.read();</p><p> //--------------------------------ch1---------------------
 if(caracter == 'A')
{
 digitalWrite(ch1,HIGH);
 </p><p>}</p><p>if(caracter == 'a')
{
 digitalWrite(ch1,LOW);
 
}
//---------------------------------ch1----------------------
//---------------------------------ch2---------------------
 if(caracter == 'B')
{
 digitalWrite(ch2,HIGH);</p><p>}</p><p>if(caracter == 'b')
{
 digitalWrite(ch2,LOW);
 
}
//---------------------------------ch2----------------------
//---------------------------------ch3---------------------
 if(caracter == 'C')
{
 digitalWrite(ch3,HIGH);</p><p>}</p><p>if(caracter == 'c')
{
 digitalWrite(ch3,LOW);
  
}
//---------------------------------ch3----------------------
//---------------------------------ch4---------------------
 if(caracter == 'D')
{
 digitalWrite(ch4,HIGH);
 
}</p><p>if(caracter == 'd')
{
 digitalWrite(ch4,LOW);
  
}
//---------------------------------ch4----------------------</p><p> delay(10);
}</p>

Step 4: Now Adding LCD With Arduino

* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11

* LCD D4 pin to digital pin 5

* LCD D5 pin to digital pin 4

* LCD D6 pin to digital pin 3

* LCD D7 pin to digital pin 2

* LCD R/W pin to ground

* 10K resistor:

* ends to +5V and ground

* wiper to LCD VO pin (pin 3)

#include <SoftwareSerial.h>
SoftwareSerial mySerial(1, 0); // 1-RX, 0-TX - #include <LiquidCrystal.h> int ch1 = A0; int ch2 = A1; int ch3 = A2; int ch4 = A3; LiquidCrystal lcd(12, 11, 5, 4, 3, 2);;//(rs, enable, d4, d5, d6, d7)

void setup() { mySerial.begin(9600);

pinMode(ch1, OUTPUT); pinMode(ch2, OUTPUT); pinMode(ch3, OUTPUT); pinMode(ch4, OUTPUT);

lcd.begin(16, 2);

}

void loop() {

char caracter = mySerial.read();

//--------------------------------ch1--------------------- if(caracter == 'A') { digitalWrite(ch1,HIGH); lcd.setCursor(0, 0); lcd.print("r1 ON");

}

if(caracter == 'a') { digitalWrite(ch1,LOW); lcd.setCursor(0, 0); lcd.print("r1 OFF"); } //---------------------------------ch1---------------------- //---------------------------------ch2--------------------- if(caracter == 'B') { digitalWrite(ch2,HIGH); lcd.setCursor(8, 0); lcd.print("r2 ON"); }

if(caracter == 'b') { digitalWrite(ch2,LOW); lcd.setCursor(8, 0); lcd.print("r2 OFF"); } //---------------------------------ch2---------------------- //---------------------------------ch3--------------------- if(caracter == 'C') { digitalWrite(ch3,HIGH); lcd.setCursor(0, 1); lcd.print("r3 ON"); }

if(caracter == 'c') { digitalWrite(ch3,LOW); lcd.setCursor(0, 1); lcd.print("r3 OFF"); } //---------------------------------ch3---------------------- //---------------------------------ch4--------------------- if(caracter == 'D') { digitalWrite(ch4,HIGH); lcd.setCursor(8, 1); lcd.print("r4 ON"); }

if(caracter == 'd') { digitalWrite(ch4,LOW); lcd.setCursor(8, 1); lcd.print("r4 OFF"); } //---------------------------------ch4----------------------

delay(10); }

Step 5: Adding Push Button in the Project

Now we are adding Buttons

i use four button you can use it according to requirement

#include <SoftwareSerial.h> //

SoftwareSerial mySerial(1, 0); // 1-RX, 0-TX - #include <LiquidCrystal.h>

int ch1 = A0; int ch2 = A1; int ch3 = A2; int ch4 = A3; LiquidCrystal lcd(12, 11, 5, 4, 3, 2);;//(rs, enable, d4, d5, d6, d7) int switchPin[] = {6,7,8,9}; void setup() { mySerial.begin(9600);

pinMode(ch1, OUTPUT); pinMode(ch2, OUTPUT); pinMode(ch3, OUTPUT); pinMode(ch4, OUTPUT);

lcd.begin(16, 2);

pinMode(switchPin[0], INPUT); digitalWrite(switchPin[0], HIGH); pinMode(switchPin[1], INPUT); digitalWrite(switchPin[1], HIGH); pinMode(switchPin[2], INPUT); digitalWrite(switchPin[2], HIGH); pinMode(switchPin[3], INPUT); digitalWrite(switchPin[3], HIGH); pinMode(switchPin[4], INPUT); digitalWrite(switchPin[4], HIGH); }

void loop() {

char caracter = mySerial.read();

//--------------------------------ch1--------------------- if(caracter == 'A') { digitalWrite(ch1,HIGH); lcd.setCursor(0, 0); lcd.print("r1 ON");

}

if(caracter == 'a') { digitalWrite(ch1,LOW); lcd.setCursor(0, 0); lcd.print("r1 OFF"); } //---------------------------------ch1---------------------- //---------------------------------ch2--------------------- if(caracter == 'B') { digitalWrite(ch2,HIGH); lcd.setCursor(8, 0); lcd.print("r2 ON"); }

if(caracter == 'b') { digitalWrite(ch2,LOW); lcd.setCursor(8, 0); lcd.print("r2 OFF"); } //---------------------------------ch2---------------------- //---------------------------------ch3--------------------- if(caracter == 'C') { digitalWrite(ch3,HIGH); lcd.setCursor(0, 1); lcd.print("r3 ON"); }

if(caracter == 'c') { digitalWrite(ch3,LOW); lcd.setCursor(0, 1); lcd.print("r3 OFF"); } //---------------------------------ch3---------------------- //---------------------------------ch4--------------------- if(caracter == 'D') { digitalWrite(ch4,HIGH); lcd.setCursor(8, 1); lcd.print("r4 ON"); }

if(caracter == 'd') { digitalWrite(ch4,LOW); lcd.setCursor(8, 1); lcd.print("r4 OFF"); } //---------------------------------ch4---------------------- if (digitalRead(switchPin[0]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, HIGH) ; lcd.setCursor(0, 0); lcd.print("r1 ON"); } if (digitalRead(switchPin[0]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, LOW) ; lcd.setCursor(0, 0); lcd.print("r1 OFF"); } if (digitalRead(switchPin[1]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, HIGH) ; lcd.setCursor(8, 0); lcd.print("r2 ON"); } if (digitalRead(switchPin[1]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, LOW) ; lcd.setCursor(8, 0); lcd.print("r2 OFF"); } if (digitalRead(switchPin[2]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, HIGH) ; lcd.setCursor(0, 1); lcd.print("r3 ON"); } if (digitalRead(switchPin[2]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, LOW) ; lcd.setCursor(0, 1); lcd.print("r3 OFF"); } if (digitalRead(switchPin[3]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, HIGH) ; lcd.setCursor(8, 1); lcd.print("r4 ON");// toggle running variable } if (digitalRead(switchPin[3]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, LOW) ; lcd.setCursor(8, 1); lcd.print("r4 OFF"); }

delay(0); }

Step 6: Now We Are Using EEPROM to Save Last Status of Switches

Using EEPROM

I am adding internal EEPROM to save the last status

If the device go out of power and again connected

it load the last status of switches

those switches which are on before power off now they are still on

#include <SoftwareSerial.h> //

SoftwareSerial mySerial(1, 0); // 1-RX, 0-TX - #include <LiquidCrystal.h>

#include <EEPROM.h>

int ch1 = A0; int ch2 = A1; int ch3 = A2; int ch4 = A3; LiquidCrystal lcd(12, 11, 5, 4, 3, 2);;//(rs, enable, d4, d5, d6, d7) int switchPin[] = {6,7,8,9}; void setup() { mySerial.begin(9600);

pinMode(ch1, OUTPUT); pinMode(ch2, OUTPUT); pinMode(ch3, OUTPUT); pinMode(ch4, OUTPUT);

lcd.begin(16, 2);

pinMode(switchPin[0], INPUT); digitalWrite(switchPin[0], HIGH); pinMode(switchPin[1], INPUT); digitalWrite(switchPin[1], HIGH); pinMode(switchPin[2], INPUT); digitalWrite(switchPin[2], HIGH); pinMode(switchPin[3], INPUT); digitalWrite(switchPin[3], HIGH); pinMode(switchPin[4], INPUT); digitalWrite(switchPin[4], HIGH);

if (EEPROM.read(0) == 1) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, HIGH) ; lcd.setCursor(0, 0); lcd.print("r1 ON"); // toggle running variable // indicate via LED } if (EEPROM.read(0) == 0) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, LOW) ; lcd.setCursor(0, 0); lcd.print("r1 OFF"); // toggle running variable // indicate via LED } if (EEPROM.read(1) == 1) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, HIGH) ; lcd.setCursor(8, 0); lcd.print("r2 ON"); // toggle running variable // indicate via LED } if (EEPROM.read(1) == 0) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, LOW) ; lcd.setCursor(8, 0); lcd.print("r2 OFF"); // toggle running variable // indicate via LED } if (EEPROM.read(2) == 1) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, HIGH) ; lcd.setCursor(0, 1); lcd.print("r3 ON"); // toggle running variable // indicate via LED } if (EEPROM.read(2) == 0) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, LOW) ; lcd.setCursor(0, 1); lcd.print("r3 OFF"); // toggle running variable // indicate via LED } if (EEPROM.read(3) == 1) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, HIGH) ; lcd.setCursor(8, 1); lcd.print("r4 ON"); // toggle running variable // indicate via LED } if (EEPROM.read(3) == 0) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, LOW) ; lcd.setCursor(8, 1); lcd.print("r3 OFF"); // toggle running variable // indicate via LED } }

void loop() {

char caracter = mySerial.read();

//--------------------------------ch1--------------------- if(caracter == 'A') { digitalWrite(ch1,HIGH); lcd.setCursor(0, 0); lcd.print("r1 ON"); EEPROM.write(0, 1); }

if(caracter == 'a') { digitalWrite(ch1,LOW); lcd.setCursor(0, 0); lcd.print("r1 OFF"); EEPROM.write(0, 0); } //---------------------------------ch1---------------------- //---------------------------------ch2--------------------- if(caracter == 'B') { digitalWrite(ch2,HIGH); lcd.setCursor(8, 0); lcd.print("r2 ON"); EEPROM.write(1, 1); }

if(caracter == 'b') { digitalWrite(ch2,LOW); lcd.setCursor(8, 0); lcd.print("r2 OFF"); EEPROM.write(1, 0); } //---------------------------------ch2---------------------- //---------------------------------ch3--------------------- if(caracter == 'C') { digitalWrite(ch3,HIGH); lcd.setCursor(0, 1); lcd.print("r3 ON"); EEPROM.write(2, 1); }

if(caracter == 'c') { digitalWrite(ch3,LOW); lcd.setCursor(0, 1); lcd.print("r3 OFF"); EEPROM.write(2, 0); } //---------------------------------ch3---------------------- //---------------------------------ch4--------------------- if(caracter == 'D') { digitalWrite(ch4,HIGH); lcd.setCursor(8, 1); lcd.print("r4 ON"); EEPROM.write(3, 1); }

if(caracter == 'd') { digitalWrite(ch4,LOW); lcd.setCursor(8, 1); lcd.print("r4 OFF"); EEPROM.write(3, 0); } //---------------------------------ch4---------------------- if (digitalRead(switchPin[0]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, HIGH) ; lcd.setCursor(0, 0); lcd.print("r1 ON"); EEPROM.write(0, 1); } if (digitalRead(switchPin[0]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch1, LOW) ; lcd.setCursor(0, 0); lcd.print("r1 OFF"); EEPROM.write(0, 0); } if (digitalRead(switchPin[1]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, HIGH) ; lcd.setCursor(8, 0); lcd.print("r2 ON"); EEPROM.write(1, 1); } if (digitalRead(switchPin[1]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch2, LOW) ; lcd.setCursor(8, 0); lcd.print("r2 OFF"); EEPROM.write(1, 0); } if (digitalRead(switchPin[2]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, HIGH) ; lcd.setCursor(0, 1); lcd.print("r3 ON"); EEPROM.write(2, 1); } if (digitalRead(switchPin[2]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch3, LOW) ; lcd.setCursor(0, 1); lcd.print("r3 OFF"); EEPROM.write(2, 0); } if (digitalRead(switchPin[3]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, HIGH) ; lcd.setCursor(8, 1); lcd.print("r4 ON");// toggle running variable EEPROM.write(3, 1); } if (digitalRead(switchPin[3]) == LOW) { // switch is pressed - pullup keeps pin high normally digitalWrite(ch4, LOW) ; lcd.setCursor(8, 1); lcd.print("r4 OFF"); EEPROM.write(3, 0); }

delay(0); }

Step 7: Adding Sensers in the Project

If you want to add senser i think Arduino MEGA is Better because it has more pins than uno

if you want to use Arduino UNO Than use Shields

<p>Interesting, thanks!</p>
Thanks for feedback
<p>Lcd can not show any character ,if upload the code . what i do ?</p>
Add step 4,5 or 6 code. <br><br>Or<br>Contact me on whatsapp <br>+923065090466
<p>I was able to do it with HC-05 Bluetooth. Renaming the Default Name of bluetooth would have helped in this (which i did ...research)..Thanks</p>
<p>yes you can use it hc-05 in slave mode</p>
<p>G.T</p>
<p>Great man</p>
O Great bro thanks really amazing it is I will insha Allah try it after my test for nust
Good work bro ! Keep it up (Y)
Let's plan it on a large scale
Well done good job
Thanks man
<p>Thanks</p>
<p>I do not believe the first one works because the &lt;p&gt;&lt;/p&gt; does not register with the arduino. </p>
See down .ino file is available go and download from there<br><br>When i paste program from pc <br>Then this will appear
<p>In all of your schematics (except the first one in step 3), you have the Vcc of the bluetooth module connected to ground!! I take it that is a mistake??</p>
Haha <br>Thanks for telling
<p>can this be set up so no 2 switches can be turned on at the same time? IE: if you activate one the previously active one switches off. Im looking for something like this (modified) to prevent my GF from using 2 appliances at once such as the toaster and AC because it trips the breaker and the super is about ready to put up a &quot;NO Air Conditioner&quot; policy if she keeps popping the breaker.</p>
If you want to make contact me personally
Yes possible <br><br>When you on the toster Ac become off at that time. When you off the toster ac become on again
<p>Do it really works, those buttons.. Because your code says:</p><p>if (digitalRead(switchPin[0]) == LOW)</p><p> { // switch is pressed - pullup keeps pin high normally</p><p> digitalWrite(ch1, HIGH) ; </p><p> lcd.setCursor(0, 0);</p><p> lcd.print(&quot;r1 ON&quot;);</p><p> EEPROM.write(0, 1); </p><p> }</p><p> if (digitalRead(switchPin[0]) == LOW)</p><p> { // switch is pressed - pullup keeps pin high normally</p><p> digitalWrite(ch1, LOW) ;</p><p> lcd.setCursor(0, 0);</p><p> lcd.print(&quot;r1 OFF&quot;);</p><p> EEPROM.write(0, 0); </p><p> }</p><p>If I press button 1, first 'if' catch it.. Ok.. After that if {...} button is still down and second 'if' is true too.. So, first we set relay to ON and right after we turn it OFF..</p><p>You should have something like:</p><p>if (digitalRead(switchPin[0]) == LOW &amp;&amp; pin0 == false) { pin0=true};</p><p>if (digitalRead(switchPin[0]) == HIGH &amp;&amp; pin0 == true) </p><p>{ </p><p>pin0=false; </p><p>pin0status=pin0status==HIGH?LOW:HIGH; </p><p>digitalWrite(ch1,pin0status); </p><p>// do rest of stuff...</p><p>} </p>
Yes its work i check it first. Then i upload <br><br>Load this on arduino then see the result<br>
<p>Is there an IOs version of this software, for the iPhone?</p>

About This Instructable

32,262views

519favorites

Bio: I love electronics .Arduino automation
More by awaiskhawar:Write any thing on LCD with One button with Arduino its a game Automatic garden watering system BY arduino, LCD,  Buttons, EEPROM, solenoid valve, Motor and underground sprinkler  Automatic generater starter 
Add instructable to: