HOME AUTOMATION SYSTEM using BLUETOOTH

BLUETOOTH MODULE

Vikrant Singh

7/29/20241 min read

Project Overview

In this project, we will create a home automation system using bluetooth module (HC-04). A home automation system that allows users to control home appliances (such as lights and fans) using a smartphone via Bluetooth communication.

Components

1. Arduino Uno

2. Bluetooth Module (HC-04)

3. Relay

4. Jumper Wires

5. Breadboard

Circuit Diagram :

Steps to Build the Project :

Connect the Bluetooth HC-04 Module to Arduino:
  • VCC to 5V

  • GND to GND

  • TXD to RX (digital pin 0) on the Arduino

  • RXD to TX (digital pin 1) on the Arduino

Connect the Relay to Arduino:
  • VCC to 5V

  • GND to GND

  • IN to digital pin 8 on the Arduino

Arduino Code :

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX, TX

int relay1 = 8;

int relay2 = 9;

int relay3 = 10;

int relay4 = 11;

void setup() {

pinMode(relay1, OUTPUT);

pinMode(relay2, OUTPUT);

pinMode(relay3, OUTPUT);

pinMode(relay4, OUTPUT);

BTSerial.begin(9600);

Serial.begin(9600);

digitalWrite(relay1, HIGH);

digitalWrite(relay2, HIGH);

digitalWrite(relay3, HIGH);

digitalWrite(relay4, HIGH);

}

void loop() {

if (BTSerial.available()) {

char data = BTSerial.read();

Serial.println(data);

switch (data) {

case '1':

digitalWrite(relay1, LOW); // Turn ON Relay 1

break;

case '2':

digitalWrite(relay1, HIGH); // Turn OFF Relay 1

break;

case '3':

digitalWrite(relay2, LOW); // Turn ON Relay 2

break;

case '4':

digitalWrite(relay2, HIGH); // Turn OFF Relay 2

break;

case '5':

digitalWrite(relay3, LOW); // Turn ON Relay 3

break;

case '6':

digitalWrite(relay3, HIGH); // Turn OFF Relay 3

break;

case '7':

digitalWrite(relay4, LOW); // Turn ON Relay 4

break;

case '8':

digitalWrite(relay4, HIGH); // Turn OFF Relay 4

break;

default:

break;

}

}

}

Code File

Testing the System :
  • Connect the HC-05 Bluetooth module, relay module, and LED as per the circuit diagram.

  • Upload the code to the Arduino using the Arduino IDE.

  • Pair your smartphone with the HC-05 Bluetooth module (default password is usually "1234" or "0000").

  • Open the Bluetooth terminal app on your smartphone and connect to the HC-05 module.

***Happy Tinkering***