Engineer Jagat

IT & Engineering Stuff

Home Automation using Bluetooth: Complete Arduino Automation Project

July 29, 2020
Home Automation using Bluetooth: Complete Arduino Automation Project

Arduino is an awesome platform for learning how an embedded system works. Arduino could integrate with different sensors that means you could use a number of sensors and develop a project with them.

In this project, we are going to describe the Bluetooth Module  (HC-05) and Arduino Uno. How it works and develop a project like voice control appliances. Where you could turn ON and OFF your appliances through your voice commands.

Let’s hands dirty with some jumper wire. To develop this project you should need some components which are:

  • Arduino Uno
  • Bluetooth Module (HC-05)
  • Mobile Phone(App installed AMR_VOICE)
  • LED’s
  • Jumper Wire
  • Breadboard

Step-by-Step

Step 1: Setup

This is the first step if you have not set up Arduino IDE then install and setup. Follow the link to set up.

Step 2: Code

// Home Automation using Bluetooth 
String voice;
// Pin for Bedroom
int
bedroomLight = 2,
bedroomFan = 3,
bedroomAC = 4;

// Pin for Kitchen
int 
kitchenLight = 5;


// Pin for Storeroom
int 
storeroomLight = 6,
storeroomCamera = 7;

// Pin for Garden
int 
gardenWaterPump = 8,
gardenCamera = 9;

void allon(){
     digitalWrite(bedroomLight, HIGH);
     digitalWrite(bedroomFan, HIGH);
     digitalWrite(bedroomAC, HIGH);
     digitalWrite(kitchenLight, HIGH);
     digitalWrite(storeroomLight, HIGH);
     digitalWrite(storeroomCamera, HIGH);
     digitalWrite(gardenWaterPump, HIGH);
     digitalWrite(gardenCamera, HIGH);
     }
void alloff(){
     digitalWrite(bedroomLight, LOW);
     digitalWrite(bedroomFan, LOW);
     digitalWrite(bedroomAC, LOW);
     digitalWrite(kitchenLight, LOW);
     digitalWrite(storeroomLight, LOW);
     digitalWrite(storeroomCamera, LOW);
     digitalWrite(gardenWaterPump, LOW);
     digitalWrite(gardenCamera, LOW);
}
//-----------------------------------------------------------------------//
 void setup() {
  Serial.begin(9600);
  pinMode(bedroomLight, OUTPUT);
  pinMode(bedroomFan, OUTPUT);
  pinMode(bedroomAC, OUTPUT);
  pinMode(kitchenLight, OUTPUT);
  pinMode(storeroomLight, OUTPUT);
  pinMode(storeroomCamera, OUTPUT);
  pinMode(gardenWaterPump, OUTPUT);
  pinMode(gardenCamera, OUTPUT);
}

 void loop() {
  while (Serial.available()){
  delay(10); 
  char c = Serial.read();
  if (c == '#') {break;}
  voice += c; 
  }
  if (voice.length() > 0) {
    Serial.println(voice);
  
  if(voice == "*everything on")
  {
    allon();
  }
  else if(voice == "*everything off")
    {
      alloff();
    }
  
  else if(voice == "*bedroom light on")
    {
      digitalWrite(bedroomLight, HIGH);
    }
  else if(voice == "*bedroom fan on")
    {
      digitalWrite(bedroomFan, HIGH);
    }
  else if(voice == "*bedroom ac on")
  {
    digitalWrite(bedroomAC, HIGH);
  }
  else if(voice == "*kitchen light on")
  {
    digitalWrite(kitchenLight, HIGH);
  }
  else if(voice == "*storeroom light on")
  {
    digitalWrite(storeroomLight, HIGH);
  }
  else if(voice == "*storeroom camera on")
  {
    digitalWrite(storeroomCamera, HIGH);
  }
  else if(voice == "*water pump on")
  {
    digitalWrite(gardenWaterPump, HIGH);
  }
  else if(voice == "*garden camera on")
  {
    digitalWrite(gardenCamera, HIGH);
  }
 
// Off state
else if(voice == "*bedroom light off")
    {
      digitalWrite(bedroomLight, LOW);
    }
  else if(voice == "*bedroom fan off")
    {
      digitalWrite(bedroomFan, LOW);
    }
  else if(voice == "*bedroom ac off")
  {
    digitalWrite(bedroomAC, LOW);
  }
  else if(voice == "*kitchen light off")
  {
    digitalWrite(kitchenLight, LOW);
  }
  else if(voice == "*storeroom light off")
  {
    digitalWrite(storeroomLight, LOW);
  }
  else if(voice == "*storeroom camera off")
  {
    digitalWrite(storeroomCamera, LOW);
  }
  else if(voice == "*water pump off")
  {
    digitalWrite(gardenWaterPump, LOW);
  }
  else if(voice == "*garden camera off")
  {
    digitalWrite(gardenCamera, LOW);
  }

voice="";}} 

Step 3: Wiring

Arduino Bluetooth Module Circuit
Share with Friends
Copyright © 2020-2021 Engineer Jagat All rights reserved. Developed by Ravindra Rana