Arduino Nano based Bluetooth & Manual Control Homeautomation System  Using Android App.

Arduino Nano based Bluetooth & Manual Control Homeautomation System Using Android App.

In this post, we are going to make a Android app and Manual control homeautomation system using Arduino nano and HC-05 Bluetooth module.

In this Homeautomation System, we are able to control our homeappliances by an android app through our smartphone and also we can control our devices through switches buttons, that we regularly use in our houses.

Best part of this project  is that this homeautomation system dosn’t need internet connection or hotspot ,router bridge.

Components Required

Ordering the PCBs at PCBWay

This project is sponsored by PCBWay. PCBWay is a full feature Printed Circuit Board manufacturing service.

Turn your DIY breadboard circuits into professional PCBs – get 10 boards for approximately $5 + shipping (which will vary depending on your country).

Once you have your Gerber files, you can order the PCB. Follow the next steps.

1. Download the Gerber files – click here to download the .zip file.

2. Go to PCBWay website and open the PCB Instant Quote page. 

3. PCBWay can grab all the PCB details and automatically fills them for you. Use the “Quick-order PCB (Autofill parameters)”.

4. Press the “+ Add Gerber file” button to upload the provided Gerber files.


And that’s it. You can also use the OnlineGerberViewer to check if your PCB is looking as it should.

Now select the shipping method , the one you prefer and has cost efficient.


You can increase your PCB order quantity and change the solder mask color. I’ve ordered the Green color.

PCBWay has lots of other staggering solder mask, Now they can produce pink, orange, grey, even the transparent solder mask. 

Apart from this they also provide Black core PCB.

Once you’re ready, you can order the PCBs by clicking “Save to Cart” and complete your order.

After approximately one week using the DHL shipping method, I received the PCBs at my place.

As usual, everything comes well packed, and the PCBs are really high-quality. The letters on the silkscreen are really well-printed and easy to read. Additionally, the solder sticks easily to the pads.

Connect all the Switches & Bulb as in Schematics below.

Android Application.

Code.

Download below code and open in your Arduino ide, modify the code according to your need.


// define the GPIO connected with Relays and switches
#define Relay1 2  
#define Relay2 3
#define Relay3 9 
#define Relay4 10

#define switch1 5
#define switch2 6
#define switch3 7
#define switch4 8

int switch_ON_Flag1_previous_I = 0;
int switch_ON_Flag2_previous_I = 0;
int switch_ON_Flag3_previous_I = 0;
int switch_ON_Flag4_previous_I = 0;
    
char bt_data; // variable for storing bluetooth data 


void all_Switch_ON(){
  digitalWrite(Relay1, LOW);  delay(100);
  digitalWrite(Relay2, LOW);  delay(100);
  digitalWrite(Relay3, LOW);  delay(100);
  digitalWrite(Relay4, LOW);  delay(100);


}

void all_Switch_OFF(){
  digitalWrite(Relay1, HIGH); delay(100);
  digitalWrite(Relay2, HIGH); delay(100);
  digitalWrite(Relay3, HIGH); delay(100);
  digitalWrite(Relay4, HIGH); delay(100);


}

void Bluetooth_handle()
{
  bt_data = Serial.read();
//  Serial.println(bt_data);
  delay(20);

  switch(bt_data)
      {
        case 'W': digitalWrite(Relay1, LOW);   break; // if 'A' received Turn on Relay1
        case 'w': digitalWrite(Relay1, HIGH);  break; // if 'a' received Turn off Relay1
        case 'X': digitalWrite(Relay2, LOW);   break; // if 'B' received Turn on Relay2
        case 'x': digitalWrite(Relay2, HIGH);  break; // if 'b' received Turn off Relay2
        case 'Y': digitalWrite(Relay3, LOW);   break; // if 'C' received Turn on Relay3
        case 'y': digitalWrite(Relay3, HIGH);  break; // if 'c' received Turn off Relay3
        case 'Z': digitalWrite(Relay4, LOW);   break; // if 'D' received Turn on Relay4
        case 'z': digitalWrite(Relay4, HIGH);  break; // if 'd' received Turn off Relay4
        case 'A': all_Switch_ON(); break;  // if 'Z' received Turn on all Relays
        case 'a': all_Switch_OFF(); break; // if 'z' received Turn off all Relays
        default : break;
      }
}

void setup()
{
  Serial.begin(9600);
  Serial.println("The device started, now you can pair it with bluetooth!");
  delay(5000);

  pinMode(Relay1, OUTPUT);
  pinMode(Relay2, OUTPUT);
  pinMode(Relay3, OUTPUT);
  pinMode(Relay4, OUTPUT);

  pinMode(switch1, INPUT);
  pinMode(switch2, INPUT);
  pinMode(switch3, INPUT);
  pinMode(switch4, INPUT);

//During Starting all Relays should TURN OFF
  digitalWrite(Relay1, LOW);
  digitalWrite(Relay2, LOW);
  digitalWrite(Relay3, LOW);
  digitalWrite(Relay4, LOW);
 
  delay(200);
}

void loop()
{  
  if (Serial.available()){
    delay(10); 
   Bluetooth_handle();
 }

 //Manual control
       
 if (digitalRead(switch1) == LOW)
  {
    if (switch_ON_Flag1_previous_I == 0 )
    {
      digitalWrite(Relay1, LOW);
      switch_ON_Flag1_previous_I = 1;
    }
    

  }
  if (digitalRead(switch1) == HIGH )
  {
    if (switch_ON_Flag1_previous_I == 1)
    {
      digitalWrite(Relay1, HIGH);
      switch_ON_Flag1_previous_I = 0;
    }
   
  }
 if (digitalRead(switch2) == LOW)
  {
    if (switch_ON_Flag2_previous_I == 0 )
    {
      digitalWrite(Relay2, LOW);
      switch_ON_Flag2_previous_I = 1;
    }
    }
  if (digitalRead(switch2) == HIGH)
  {
    if (switch_ON_Flag2_previous_I == 1)
    {
      digitalWrite(Relay2, HIGH);
     switch_ON_Flag2_previous_I = 0;
    }
   
  }
   if (digitalRead(switch3) == LOW)
  {
    if (switch_ON_Flag3_previous_I == 0 )
    {
      digitalWrite(Relay3, LOW);
      switch_ON_Flag3_previous_I = 1;
    }
    

  }
  if (digitalRead(switch3) == HIGH )
  {
    if (switch_ON_Flag3_previous_I == 1)
    {
      digitalWrite(Relay3, HIGH);
      switch_ON_Flag3_previous_I = 0;
    }
   
  }
 if (digitalRead(switch4) == LOW)
  {
    if (switch_ON_Flag4_previous_I == 0 )
    {
      digitalWrite(Relay4, LOW);
      switch_ON_Flag4_previous_I = 1;
    }
    

  }
  if (digitalRead(switch4) == HIGH )
  {
    if (switch_ON_Flag4_previous_I == 1)
    {
      digitalWrite(Relay4, HIGH);
      switch_ON_Flag4_previous_I = 0;
    }}

}

Upload this code to your Arduino nano board after selecting right board & COM Port.

One thought on “Arduino Nano based Bluetooth & Manual Control Homeautomation System Using Android App.

Leave a Reply to Gal Jerman Cancel reply

Your email address will not be published. Required fields are marked *