Home Automation using Arduino and Bluetooth HC-05 Module

Share This

Hello friends! Welcome back to ElectroDuino. This blog is based on Home Automation using Arduino and Bluetooth HC-05 Module. Here we will discuss Introduction to Bluetooth Controlled Home Automation System, Project Concept, Block Diagram, components required, circuit diagram, working principle, and Arduino code.

Introduction

In the modern day’s everyone uses smartphones and the internet. Therefore, Every smartphone has Bluetooth System. In this project, we will design a simple Arduino Bluetooth Control Home Automation using the HC-05 Bluetooth module, which is used to switch ON or OFF different electrical appliances remotely. Home Automation systems can make our life easy and secure. Here we will control 4 different home appliances using Smartphone App through Bluetooth communication.

Project Concept of Home Automation using Arduino and Bluetooth HC-05 Module

The key components of the project are Arduino, HC-05 Bluetooth module, 4 Channel Relay Module, 16×2 LCD display, and “Bluetooth Controller” app. Where Arduino is the main microcontroller of the project that’s controlled all other components. The HC-05 Bluetooth module is used to receive data from a smartphone. The relay module is used to control AC devices. The 16×2 LCD module is used to display the status (turn ON or turn OFF) of the home appliances. Also, we need to download and install the Bluetooth Controller App on our Smartphone, Which is sending data to the HC-05 Bluetooth Module.

Here we will send data from the smartphone using the Bluetooth controller App, then the Bluetooth module receives this data and pass this data to the Arduino. Now, Arduino is decoding this data, and sending commands to the relay module to control the devices. At the same time, we can see the status (turn ON or turn OFF) of the home appliances on the display.

Block Diagram

 
Arduino Bluetooth Control Home Automation Block Diagram
Arduino Bluetooth Control Home Automation Block Diagram

Components Required

Components NameQuantity
Arduino UNO1
HC-05 Bluetooth Module1
4 Channel Relay Module1
AC Bulb with Holder and Wire4
PCB Prototyping board1
9V 1 Amp AdapterExternal DC Power supply for operating Arduino.
220V AC Power supply 
Connecting wiresAs required in the circuit diagram
Smart Phone (Bluetooth supported)1
Bluetooth Controller App 

HC-05 Bluetooth module

The HC-05 Bluetooth module can communicate two-way wireless. so, it is used to communicate with any device like a Phone or Laptop with Bluetooth functionality. The module communicates with the help of UART at 9600 baud rate and it has a range up to <100m. It works on 3.3V and it has an onboard 5V to 3.3V regulator. The HC-05 has two operating modes, these are, Data mode and AT Command mode. The Data mode can send and receive data from other Bluetooth devices. The AT Command mode can be changed to the default device settings of HC-05.

This is a 6 pin module, but in this project, we will use only 4 pins, these are VCC, GND, TX, and RX. Where the VCC pin is connected to the 5V of the microcontroller, the GND pin is connected to the ground of the microcontroller, the RX pin is connected to the TX of the microcontroller and the TX pin is connected to the RX of the microcontroller.

HC-05 Bluetooth Module Pin Diagram
HC-05 Bluetooth Module Pin Diagram

Circuit Diagram of Home Automation using Arduino and Bluetooth Module HC-05

Arduino Bluetooth Control Home Automation circuit diagram
Arduino Bluetooth Control Home Automation Circuit Diagram

Circuit Wiring

Components PinArduino pin

HC-05 Bluetooth module Vcc, Relay module Vcc, LCD  Display (Vdd, LED +) Pins

Arduino 5V Pin, but LCD  Display LED + Pins connected to Arduino 5V Pin through 220ohm resistor.

HC-05 Bluetooth module GND, Relay module GND, LCD  Display (Vss, Rw, and LED -) Pins 

GND (ground) Pin
HC-05 Bluetooth module TXDigital Pin “D0 / RX”
HC-05 Bluetooth module RXDigital Pin “D1 / TX”
4 Channel Relay Modules IN1, IN2, IN3, IN4Respectively  Digital Pin “D6”, “D5”, “D4”, “D3”, 
LCD  Display RS, E, D4, D5, D6, D7Respectively  Digital Pin “D12”, “D11”, “D10”, “D9”, “D8”, “D7”
LCD  Display V0 pin 10k Potentiometer Signal pin, Potentiometer one pin is connected to 5V and another pin is connected to GND(ground)

Bluetooth App configure

First of all, open the Play Store of your Android Smartphone and search for “Bluetooth Control for Arduino”. Then you will get this App. Now install this app.

Arduino Bluetooth Controller APP Setup 4, HC-05 Bluetooth Control Home Automation
Arduino Bluetooth Controller APP Setup 1

After completing the installation process, open the app and make sure the circuit is connected to the power supply and the Bluetooth module is on. Also, make sure the Bluetooth module pair with your smartphone. You can pair your phone with the HC-05 Bluetooth Module like we normally pair the phone with Bluetooth earphones or speakers. If your smartphone pair with the HC-05 Bluetooth module, then you can see the “HC-05 Bluetooth” name on the top side of the App and select it. 

Arduino Bluetooth Controller APP Setup 2, HC-05 Bluetooth Control Home Automation
Arduino Bluetooth Controller APP Setup 2

Now click on the  “Connection” Button. When the App successfully connects to the Bluetooth Module, Then you can see the blue light on the “Connection button“. At the same time, you can also see the LED on the Bluetooth Module is blinking with some delay. It means your Bluetooth is successfully connected.

Arduino Bluetooth Controller APP Setup 3, HC-05 Bluetooth Control Home Automation
Arduino Bluetooth Controller APP Setup 3

Working Principle of Home Automation using Arduino and Bluetooth HC-05 Module

After complete the App setup/configuration, now we need to identify the load values of the App button. The app transmits Different load values when different buttons are pressed. When we will press a button on the app, the app sends a particular Load value to the Arduino through the Bluetooth module. These Lode Values are used in Arduino code to control a particular device by a particular app button. The Load values of the App buttons and their use is described in the below list.

App ButtonsLoad ValuesDevice statusControl Relay (Relay Pin)
Button 1

1Device1 OnRelay-1 (IN1)
ADevice1 Off
Button 2

2Device2 OnRelay-2 (IN2)
BDevice2 Off
Button 3

3Device3 OnRelay-3 (IN3)
CDevice3 Off
Button 4

4Device4 OnRelay-4 (IN4)
DDevice4 Off
on All9All Devices (1, 2, 3 & 4) OnRelay-1, Relay-2 Relay-3, Relay-4 (IN1, IN2, IN3, IN4)
off AllI All Devices (1, 2, 3 & 4) Off

When we pressed any button of the App, the App sends a unique load value according to the button. The HC-05 Bluetooth Module received this unique load value and send it to the Arduino. Then, the Arduino compares the value with the predefined value of the button. If this value is matching then Arduino sends operating voltage to the relay module. also, we can see the Device status (on or off) on the 16×2 LCD Display.

For example, when we Press the App “Button 1“, then the app sends Load value “1” to the Bluetooth module. Then the Arduino gets this value through the Bluetooth module. Then the Arduino sends Low(0) input voltage to the Input-1 (IN1) pin of the relay module. Now the relay is in On mode. So the Device1 will also turn on, which is connected to the relay-1 of the relay module. At the same time, the “D1 (Device 1) is ON” status print on the 16×2 LCD Display Module.

when we again Press the App “Button 1“, but this time the app sends Load value “A” to the Bluetooth module. Again the Arduino gets this value through the Bluetooth module. But this time the Arduino sends a High(5v) input voltage to the Input-1 (IN1) pin of the relay module. Now the relay is in Off mode. So the Device1 will also turn off, which is connected to the relay-1 of the relay module. At the same time, the “D1 (Device 1) is Off” status print on the 16×2 LCD Display Module.

In this way, we can control all relays of the 4 channel Relay module through the voice command

Arduino Bluetooth Control Home Automation Code

/*
Arduino Bluetooth Control Home Automation
http://www.electroduino.com
*/
//libraries for LCD Display
#include <LiquidCrystal.h>
// Define LCD display pins
LiquidCrystal lcd(12,11,10,9,8,7);

const int Device1 = 6; // Relay pin 1 (IN1)
const int Device2 = 5; // Relay pin 2 (IN2)
const int Device3 = 4; // Relay pin 3 (IN3)
const int Device4 = 3; // Relay pin 4 (IN4)

void setup() 
 {
  Serial.begin(9600); //Sets the baud for serial data transmission
  // Set Relay pins as OUTPUT  
  pinMode(Device1, OUTPUT);
  pinMode(Device2, OUTPUT);
  pinMode(Device3, OUTPUT);
  pinMode(Device4, OUTPUT);
  // Print massage on LCD Display 
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("  Bluetooth  ");
  lcd.setCursor(0,1);
  lcd.print("Home Automation");
  delay(2000);
  // Print massage All devics are Off when system is on 
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(" D1  D2  D3  D4 ");
  lcd.setCursor(0,1);
  lcd.print("OFF OFF  OFF OFF");
 }

void loop() 
 {
  lcd.setCursor(0,0);
  lcd.print(" D1  D2  D3  D4 ");
  // Read data from Bluetooth Module
  if (Serial.available() > 0)
  { 
    char Val = Serial.read();
    // Print Bluetooth Module data on serial monitor
    Serial.print("VAL: ");
    Serial.println(Val);
    //  When Bluetooth Module data "1" then Relay1 ON
   if (Val == '1')
     {
      digitalWrite(Device1,LOW);
      lcd.setCursor(0,1);
      lcd.print("ON ");
      delay(200);
     }
    //  When Bluetooth Module data "A" then Relay1 OFF
   else if (Val=='A')
     {
      digitalWrite(Device1,HIGH);
      lcd.setCursor(0,1);
      lcd.print("OFF");
      delay(200);
     }
    //  When Bluetooth Module data "2" then Relay2 ON
   else if (Val=='2')
     {
     digitalWrite(Device2,LOW);
     lcd.setCursor(4,1);
     lcd.print("ON ");
     delay(200);
     }
    //  When Bluetooth Module data "B" then Relay2 OFF
   else if (Val=='B')
     {
     digitalWrite(Device2,HIGH);
     lcd.setCursor(4,1);
     lcd.print("OFF");
     delay(200);
     }
    //  When Bluetooth Module data "3" then Relay3 ON 
    else if (Val=='3')
      {
      digitalWrite(Device3,LOW);
      lcd.setCursor(9,1);
      lcd.print("ON");
      delay(200);
      }
    //  When Bluetooth Module data "C" then Relay3 OFF    
    else if (Val=='C')
     {
     digitalWrite(Device3,HIGH);
     lcd.setCursor(9,1);
     lcd.print("OFF");
     delay(200);
     }
   //  When Bluetooth Module data "4" then Relay4 ON   
   else if (Val=='4')
     {
     digitalWrite(Device4,LOW);
     lcd.setCursor(13,1);
     lcd.print("ON    ");
     delay(200);
     }
   //  When Bluetooth Module data "D" then Relay4 OFF   
   else if (Val=='D')
     {
     digitalWrite(Device4,HIGH);
     lcd.setCursor(13,1);
     lcd.print("OFF");
     delay(200);
     }    
   //  When Bluetooth Module data "9" then All Relay ON 
   else if (Val=='9')
     { 
      digitalWrite(Device1, LOW);
      digitalWrite(Device2, LOW);
      digitalWrite(Device3, LOW);
      digitalWrite(Device4, LOW);
      digitalWrite(Device1, HIGH);
      digitalWrite(Device2, HIGH);
      digitalWrite(Device3, HIGH);
      digitalWrite(Device4, HIGH);
      lcd.setCursor(0,1);
      lcd.print("ON  ON   ON  ON ");
      delay(200);
     }
   //  When Bluetooth Module data "9" then All Relay ON  
   else if (Val=='I')
     {
      digitalWrite(Device1, HIGH);
      digitalWrite(Device2, HIGH);
      digitalWrite(Device3, HIGH);
      digitalWrite(Device4, HIGH);
      lcd.setCursor(0,1);
      lcd.print("OFF OFF  OFF OFF");
      delay(200);
     }    
  }
}
 

 

Share This

4 thoughts on “Home Automation using Arduino and Bluetooth HC-05 Module

  • 9 August 2020 at 3:48 pm
    Permalink

    This article presents clear idea in support of the new visitors
    of blogging, that in fact how to do running a blog.

    Reply
  • 9 August 2020 at 9:19 pm
    Permalink

    I’m impressed, I have to admit. Seldom do I come across a blog
    that’s both educative and amusing, and let me tell you, you have hit
    the nail on the head. The issue is something which too few men and women are speaking intelligently about.

    I am very happy that I stumbled across this during my search for
    something concerning this.

    Reply
  • 10 August 2020 at 1:23 pm
    Permalink

    Hi there to every single one, it’s in fact a good for me to
    pay a visit this website, it consists of priceless Information.

    Reply
  • 16 August 2020 at 4:17 pm
    Permalink

    Incredible points. Great arguments. Keep up the good work.

    Reply

Leave a Reply

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