Home Automation Using Arduino UNO and Bluetooth

Spread the love

You must have got this desire to switch OFF or ON your electronic device through your voice or mobile phone. Apparently, we have made it possible for you. In this article, we’ll instruct you to make your own “Home Automation System”.

Requirements for Home Automation

Hardware

Name Quantity
Arduino UNO1
HC-05 Bluetooth Modules1
Relay Board (4 Channel)1
Jumper WiresAs Per Requirement
Smart Phone1
5v Power supply1

Software

NameLink
Arduino IDEclick Here
Application

HC-05 Bluetooth Module

Hc-05

Introduction

HC-05 Bluetooth module is a powerful wireless SPP (Serial Port Protocol) based communication module.

Pinout

HC-05 have 5 pins VCC, GND, TX, RX, and Key.

PinDescription
VCC+5v
GNDGnd
TXUART_TX
Bluetooth Serial Sending Pin
RXUART_RX
Bluetooth Serial Receiving pin
KeyModule switch input

If you want to know more about Bluetooth module HC-05, check out the article Connect your Phone to Arduino using Bluetooth.

Relay Module

For this project, I am using 2 channel relay module. If you want to know more about the relay module, you can check this article “Arduino relay Code, connection and control“.

Connection Diagram for Home Automation using Arduino UNO and Bluetooth

Arduino connection with Relay

Arduino Relay
Pin no. – 8in. – 1
Pin no. – 9in. – 2
Pin no. – 10in. – 3

Arduino connection with HC-05 Bluetooth

ArduinoHC-05
RXTX
TXRX
GNDGND
VCC5v
Home automation using Arduino UNO and Bluetooth

Code

Copy the code and paste in the Arduino IDE or simply click on the download button.

const int pin1 = 5;
const int pin2 = 6;
const int pin3 = 7; 

void setup() {
  Serial.begin(9600);
 //pin define 
  pinMode(pin1, OUTPUT); 
  pinMode(pin2, OUTPUT);
  pinMode(pin3, OUTPUT);
}

void loop() {
  String rcvString = "";
 
 while ( Serial.available() )
 
 {    // While there is data in the buffer
 
   char c = (char)Serial.read();

    //Serial.println(c);
 
   rcvString += c;     
      
 delay(3);
    
 }

if ( rcvString.length() >0 ) {
    //Serial.println( rcvString );
 
   Serial.flush();

    if( rcvString == "LightOn") {
      digitalWrite(pin1, HIGH);
      delay(100);
      //Serial.println("Light On");
    }
    else if( rcvString == "LightOff") {
      digitalWrite(pin1, LOW);
      delay(100);
      //Serial.println("Light Off");
    }

   
 else if( rcvString == "FanOn") {
      digitalWrite(pin2, HIGH); 
      delay(100);
      //Serial.println("Fan On");
    }
 else if( rcvString == "FanOff") {
      digitalWrite(pin2, LOW); 
      delay(100);
      //Serial.println("Fan Off");
    }

else if( rcvString == "AlarmOn") {
      digitalWrite(pin3, HIGH);
      //Serial.println("Alarm On"); 
      delay(100);
    }
 else if( rcvString == "AlarmOff") {
      digitalWrite(pin3, LOW); 
      delay(100);
      //Serial.println("Alarm off");
    }

  
  }

}

Application

Download the file and unzip it. Upload the code in Arduino UNO and install the application on your mobile phone.

Steps to Pair with Application:-

  • Go to settings, turn on the Bluetooth.
  • You will find a new device name HC-05, now pair with it.
  • The default password of HC-05 is “0000” or “1234”, enter it.
  • Open Application and go to Bluetooth and select HC-05
  • You are ready to use it.

Feel free to ask any questions, and put your comments below if you find this article helpful.

Add a Comment

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