"Back in 2019, the home automation project was a labor of love and a significant learning experience for me."


Introduction

A fastest-growing technology in 21st century, Enabling everything to be done with just one click. And a very popular and beginner friendly or a super-cost effective IOT project. Home Automation or Smart Home Automation allows you to control various devices and appliances.

As every smartphone has a 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.


Why I choose this Project

As a beginner, this is the one of the best Arduino projects for newbies. However, it just need a basic skills (- basic of programming with C/C++, Electronics and Microcontroller, and some basic knowledge of schematic) to get started.

It was my last year, when I got to know about, 

"What IOT does in a real world- from monitoring with a single click, to making homes to smart homes, to collecting all factory data in our smart-phone, to saving time and the work-loads, to enabling connectivity and communication between devices, sensors, and the cloud, to making our life easy and secure."

IOT is all in ONE - Networking & Security|Sensors & Actuators|Cloud Computing|Data Analytics and AI|User Interfaces and many more...

So, now you know why I choose this project. Lets, move towards building the project with my some research. Here we will control 2 different home appliances using Smartphone App through Bluetooth communication.


Concept of the Project

This project is one of the important Arduino Projects. The key components of the project are Arduino, HC-05 Bluetooth module, 4 Channel Relay Module, and “Bluetooth Electronics” app.

Arduino based home automation using Bluetooth, this project helps the user to control any electronic device using Device Control app on their Android Smartphone. The android app sends commands to the controller —Arduino, through wireless communication, namely, Bluetooth. The Arduino is connected to the main PCB which has 4 channel relays as shown in the block diagram. These relays can be connected to different electronic devices (fan, light). This project of home automation using Bluetooth and Arduino can be used for controlling any AC or DC devices.

Block Diagram


Components Required 

  Hardware Components                                   
  • Arduino UNO 
  • 5V 4 Channel Relay Module              
  • HC-05 Bluetooth Module  
  • 9v Battery 
  • Jumper wires male to female 
  • Adapter (AC 220v/120v loads) 
  • AC Bulb and Holder with wire (3)
  • DC cooling fan (1)
  • android phone 
  • laptop/pc
 Software Components
  • Arduino IDE - a software application where we write code in C language.
  • Android OS

 


Why did I choose HC-05 Bluetooth & 4-Channel Relay Modules.


By keeping in mind some several advantages and their limitations.
  • Wireless Control - They both enables wireless communication. HC-O5 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup.
  • Easy Integration - They both are designed to be beginner-friendly and easy to use.
  • Low Cost - Making them affordable for hobbyists and DIY enthusiasts.
  • Versatility - The 4-channel relay module allows you to control multiple electrical devices independently using just a few GPIO pins from a microcontroller like Arduino.
  • Expandability - The Relay module can easily be combined with other sensors and modules to expand your home automation system.
  • Offline Control - Unlike other cloud-based systems, the HC-05 and Relay module work offline.This means you don't need an internet connection to control your devices, providing an additional layer of privacy and security.
  • Learning Experience - Great learning experience for beginners and enthusiasts who want to explore electronics, programming, and smart home technology.
It's essential to consider their limitations as well, such as limited range for Bluetooth communication or the need for additional safety precautions when dealing with high-voltage devices. However, with proper planning and safety measures, these modules can be a fantastic


Connections Table

Arduino UNOHC-05 Bluetooth
(+3.3V) VCC VCC
GND ( Ground )GND ( Ground )
TX PinRX Pin
RX PinTX Pin
Arduino UNORelay Module
( +5V ) VCCVCC
GND ( Ground )GND
Digital Pins ~9,8,7,~6IN1, IN2, IN3, IN4 Pins
PhaseTerminal 1,2 and Terminal 3,4NO (normally open)
AC/DC
(home appliances)
Terminal 1,2 and Terminal 3,4Common
NeutralAC/DC
(home appliances)

  • Do all connections carefully.
  • Switch off the power supply when connecting.
  • Cross-check all the connections at the end always.


 Circuit Diagram




Configuring Android App

The app on your smartphone sends data when you click on buttons or feed voice commands via Bluetooth in the mobile to Bluetooth module HC-05 connected with Arduino board. Received data pin TXD of the HC-05 is connected to Arduino. Arduino Uno processes the received data and controls the relay board accordingly. 
I have used an Android Application named "Bluetooth Electronics" Google Play Store Link: 

Steps for setting up the app as follows:
  • First of all, install the “Bluetooth Electronics” editable app from the above link or from the play store.
  • After installing, open the app & click on ‘empty panel' and click on 'edit' button
  • I have edited this panel by adding “Text” and “Switches”.
  • Now, click on edit option of Bulb1, Bulb2, Bulb3 and Fan & then “enter the text to send over the Bluetooth serial link when the switches are turned on or off “
  • After editing, now click on “Connect” button for connecting it to the Bluetooth module (HC-05).
  • Select Bluetooth Classic and click on next.
  • Click on HC-05 device and connect. Then click on Done
  • The Bluetooth Device is Connected. 
  • Now click on the Run button.The HomeController app is successfully created.           

Final Output




Source Code


String voice;
#define relay1 9    //Connect relay1 to pin 9
#define relay2 8    //Connect relay2 to pin 8
#define relay3 7   //Connect relay1 to pin 7
#define relay4 6    //Connect relay2 to pin 6
void setup()
{
  Serial.begin(9600);            //Set rate for communicating with phone
  pinMode(relay1, OUTPUT);       //Set relay1 as an output
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);      //Set relay2 as an output
  pinMode(relay4, OUTPUT);

  digitalWrite(relay1, LOW);     //Switch relay1 off
  digitalWrite(relay2, LOW);     //Swtich relay2 off
  digitalWrite(relay3, LOW);     //Switch relay1 off
  digitalWrite(relay4, LOW);     //Swtich relay2 off
}
void loop()
{
  while(Serial.available())    //Check if there are available bytes to read
  {
    delay(10);                 //Delay to make it stable
    char c = Serial.read();    //Conduct a serial read
    if (c == '#'){
      break;                   //Stop the loop once # is detected after a word
    }
    voice += c;                //Means voice = voice + c
  }
    if (voice.length() >0)
    {
      Serial.println(voice);
      if(voice == "*switch on"){
        switchon();
      }               
      else if(voice == "*switch off"){
        switchoff();
      }             
      else if(voice == "*bulb1 on"){   
        digitalWrite(relay1, LOW);
      }
      else if(voice == "*bulb1 off"){
        digitalWrite(relay1, HIGH);
      }
       else if(voice == "*bulb2 on"){   
        digitalWrite(relay2, LOW);
      }
      else if(voice == "*bulb2 off"){
        digitalWrite(relay2, HIGH);
      }
       else if(voice == "*bulb3 on"){   
        digitalWrite(relay3, LOW);
      }
      else if(voice == "*bulb3 off"){
        digitalWrite(relay3, HIGH);
      }
      else if(voice == "*fan1 on"){
        digitalWrite(relay4, LOW);
      }
      else if(voice == "*fan1 off"){
        digitalWrite(relay4, HIGH);
      }
      voice="";
    }
}
void switchon()               //Function for turning on relays
{
  digitalWrite(relay1, LOW);
  digitalWrite(relay2, LOW);
  digitalWrite(relay3, LOW);
  digitalWrite(relay4, LOW);
}
void switchoff()              //Function for turning on relays
{
  digitalWrite(relay1, HIGH);
  digitalWrite(relay2, HIGH);
  digitalWrite(relay3, HIGH);
  digitalWrite(relay4, HIGH);
}



Thank You!!