Praveen BabuMohan Kumar
Published © CC BY-NC-SA

Bluetooth Based Home Automation

The communication between the cell phone and the Arduino BT board is wireless. Additional devices can be connected into the system.

IntermediateFull instructions provided3 hours17,423
Bluetooth Based Home Automation

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Relay Module (Generic)
×1
Bluetooth Low Energy (BLE) Module (Generic)
×1
blub
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Block diagram

Code

code

Arduino
#include <SoftwareSerial.h>
SoftwareSerial BT(0, 1); //TX, RX  pins of arduino respetively
String command;
void setup()
{
 BT.begin(9600);
 Serial.begin(9600);
  pinMode(2, OUTPUT);
  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
  command += c; //build the string.
  }
  if (command.length() > 0) {
    Serial.println(command);
  if(command == "light on") //this command will be given as an input to switch on light1
  {
    digitalWrite(2, HIGH);
  }
  else if(command == "light off") //this command will be given as an input to switch off light1 simillarly other commands work
  {
    digitalWrite(2, LOW);
  }
  else if (command == "lamp on")
  {
    digitalWrite (3, HIGH);
  }
  else if ( command == "lamp off")
 {
   digitalWrite (3, LOW);
 }
  else if (command == "fan on")
 {
   digitalWrite (4, HIGH);
 }
  else if (command == "fan off")
 {
   digitalWrite (4, LOW);
            }
    else if (command == "open")
 {
   digitalWrite (4, HIGH);
 }
  else if (command == "lock")
 {
   digitalWrite (4, LOW);
 }
  else if (command == "all on") //using this command you can switch on all devices
 {
   digitalWrite (2, HIGH);
   digitalWrite (3, HIGH);
   digitalWrite (4, HIGH);
 }
  else if (command == "off")//using this command you can switch off all devices
 {
   digitalWrite (2, LOW);
   digitalWrite (3, LOW);
   digitalWrite (4, LOW);      
 }

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

Credits

Praveen Babu

Praveen Babu

6 projects • 35 followers
Electronics and communication Engineer Student at KCT,Coimbatore
Mohan Kumar

Mohan Kumar

6 projects • 39 followers

Comments