Bluetooth Based Home Automation project using Arduino

Bluetooth Based Home Automation using Arduino: This project is the part of my Home Automation series. Before this, I posted Home Automation using PC and IR-based home automation system. I hope you will learn something from this series of projects. In future, I will also post it with using GSM module based home automation system. In this project, Bluetooth is used to communicate with Arduino using an Android Application know as S2 Terminal. There are also other apps but this is free and easy to use. We use HC-05 Bluetooth module. I have also posted a project on a voice controlled home automation using Android appBluetooth based home automation system

Block Diagram of Bluetooth Based Home Automation using ArduinoBlock diagram of Bluetooth based home automation system

Components Required for Bluetooth Based Home Automation using Arduino

  • Arduino Uno: We use Arduino due to its simplicity and it also provides a much digital pin to interface with LCD and relay module at the same time. It is very useful when you prototyping a project.
  • HC-05 Bluetooth Module: Bluetooth is very easy to interface with Arduino. If you are not familiar with it search it on our website.
  • 4 Channel Relay Modules: The module we use in this project is HL-54S. It switches on and off using 5v logical signal from Arduino. It can bear up to 250VAC and 10A. These modules have 4 channels so we can control 4 AC devices at a time.
  • 16×2 LCD: LCD is used to display project name, a list of commands which can be entered then it asks to give any command and show the status of the command which is entered. We use 16×2 LCD because it is easy to interface with Arduino and very cheap in price. 10k potentiometer is used to control the contrast of display
  • AC bulbs with holders: AC bulbs are used to represent devices and appliances. Because it is easy to handle and very useful when you are prototyping any AC project. In final product just replace with AC socket to control.
  • AC wire with plug: I advise you to use good quality wire when working with higher voltages. It is always good to use electrical tape to protect connections.
  • External 5 volt supply: 5-volt dc supply is required to switch a relay on and off. Otherwise, it did not work. Also do not supply 5v from Arduino.

Circuit Diagram of Bluetooth Based Home Automation using Arduinocircuit diagram of Bluetooth based home automation system

Connections:

Bluetooth Module HC-05

  • HC-05 Rx to Arduino Tx.
  • HC-05 Tx to Arduino Rx.
  • Vcc to 5v
  • Ground to ground.

16×2 LCD:

  • VSS to a ground.
  • VDD to supply voltage.
  • VO to adjust pin of 10k potentiometer.
  • RS to Pin 8.
  • RW to a ground.
  • Enable to Pin 9.
  • LCD D4 to Pin 10.
  • LCD D5 to Pin 11.
  • LCD D6 to Pin 12.
  • LCD D7 to Pin 13.
  • Ground one end of a potentiometer.
  • 5v to other ends of a potentiometer.

4 Channel Relay modules:

  • External 5 volts to JD-VCC.
  • Ground to ground.
  • Ini1 to Pin 3.
  • Ini2 to Pin 4.
  • Ini3 to Pin5.
  • Vcc to Arduino 5v.
  • Connect one end of all bulbs to normally open terminal of relays.
  • One end of 220VAC to all common terminals of a relay and another end with another terminal of bulbs.

Working of Bluetooth Based Home Automation using Arduino

First of all download S2 Terminal app from Google play store. Open the application connects to the Bluetooth module. Write the specified commands and send it. Bluetooth module receives it and Arduino performs the describe operation, display status and send a message to mobile.

Commands:

Command sent by mobile Message receives by mobile
all on All ON
all off All OFF
white on White ON
white off White OFF
blue on Blue ON
blue off Blue OFF
green on Green ON
green off

Green OFF

Code for Bluetooth based home automation system

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
#define white 3
#define blue 4
#define green 5
int tx=1;
int rx=0;
char inSerial[15];


void setup(){
Serial.begin(9600);
pinMode(white, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(green, OUTPUT);
pinMode(tx, OUTPUT);
pinMode(rx, INPUT);
digitalWrite(white, HIGH);
digitalWrite(blue, HIGH);
digitalWrite(green, HIGH);
lcd.begin(16, 2);
lcd.clear();
lcd.print("MICROCONTROLLERS ");
lcd.setCursor(0,1); 
lcd.print(" LAB ");
delay(2000);
lcd.clear();
lcd.print("HOME AUTOMATION ");
lcd.setCursor(0,1);
lcd.print("USING BLUETOOTH");
delay(2000);
lcd.clear();
lcd.print("1. Bulb 1 WHITE");
lcd.setCursor(0,1);
lcd.print("2. Bulb 2 BLUE");
delay(2000);
lcd.clear();
lcd.print("3. Bulb 3 GREEN");
delay(2000);
lcd.clear();
lcd.print("Bulb 1 2 3 ");
lcd.setCursor(0,1);
lcd.print(" OFF OFF OFF");

}

void loop(){
int i=0;
int m=0;
delay(500); 
if (Serial.available() > 0) { 
while (Serial.available() > 0) {
inSerial[i]=Serial.read(); 
i++; 
}
inSerial[i]='\0';
Check_Protocol(inSerial);
}} 



void Check_Protocol(char inStr[]){ 
int i=0;
int m=0;
Serial.println(inStr);

if(!strcmp(inStr,"all on")){ 
digitalWrite(white, LOW);
digitalWrite(blue, LOW);
digitalWrite(green, LOW);
Serial.println("ALL ON");
lcd.setCursor(4,1); 
lcd.print("ON ");
lcd.setCursor(8,1); 
lcd.print("ON "); 
lcd.setCursor(12,1); 
lcd.print("ON "); 
for(m=0;m<11;m++){
inStr[m]=0;}
i=0;}

if(!strcmp(inStr,"all off")){ 
digitalWrite(white, HIGH);
digitalWrite(blue, HIGH);
digitalWrite(green, HIGH);
Serial.println("ALL OFF");
lcd.setCursor(4,1); 
lcd.print("OFF ");
lcd.setCursor(8,1); 
lcd.print("OFF "); 
lcd.setCursor(12,1); 
lcd.print("OFF "); 
for(m=0;m<11;m++){
inStr[m]=0;}
i=0;}

if(!strcmp(inStr,"white on")){ 
digitalWrite(white, LOW);
Serial.println("White ON");
lcd.setCursor(4,1); 
lcd.print("ON ");
for(m=0;m<11;m++){
inStr[m]=0;}
i=0;}

if(!strcmp(inStr,"white off")){ 
digitalWrite(white, HIGH);
Serial.println("White OFF");
lcd.setCursor(4,1); 
lcd.print("OFF ");
for(m=0;m<11;m++){
inStr[m]=0;}
i=0;} 

if(!strcmp(inStr,"blue on")){ 

digitalWrite(blue, LOW);
Serial.println("Blue ON");
lcd.setCursor(8,1); 
lcd.print("ON "); 
for(m=0;m<11;m++){
inStr[m]=0;}
i=0;}

if(!strcmp(inStr,"blue off")){ 

digitalWrite(blue, HIGH);
Serial.println("Blue OFF");
lcd.setCursor(8,1); 
lcd.print("OFF "); 
for(m=0;m<11;m++){
inStr[m]=0;}
i=0;}
if(!strcmp(inStr,"green on")){ 

digitalWrite(green, LOW);
Serial.println("Green ON");
lcd.setCursor(12,1); 
lcd.print("ON ");
for(m=0;m<11;m++){
inStr[m]=0;}
i=0;}

if(!strcmp(inStr,"green off")){ 

digitalWrite(green, HIGH);
Serial.println("Green OFF");
lcd.setCursor(12,1); 
lcd.print("OFF ");
for(m=0;m<11;m++){
inStr[m]=0;}
i=0;}

else{
for(m=0;m<11;m++){
inStr[m]=0;
}
i=0;

}}

4 thoughts on “Bluetooth Based Home Automation project using Arduino”

Leave a Comment

shares