HOME AUTOMATION USING ARDUINO AND BLUETOOTH

In this blog, we will show you how to get started with a simple home automationΒ projectΒ wherein you will be able to control your home appliances with the help of your smartphone using Bluetooth.

We will be using the Arduino UNO development board as the microcontroller in this tutorial, however, it can be easily swapped for a micro-controller of your choice ( Note that though if you use a controller outside the Arduino family, the code will have to be appropriately modified).

To addΒ Bluetooth functionality, we will use the HC-05Β Bluetooth module. This will help us to communicate with otherΒ Bluetooth devices such as your smartphone and exchange messages between your smartphone and the Arduino UNO development board.

Since we are controlling AC appliances, we will require a Relay module as well because AC appliances work on a much higher voltage and cannot be directly controlled by the Arduino UNO development board (or any other embedded device). Ensure that the maximum voltage and current ratings of the appliance being controlled are wellΒ within the range of the rated voltage and current of the relay module.

Components Required

  1. Arduino UNO
  2. Relay
  3. HC-05 Bluetooth Module

Β 

Circuit Diagram

robocraze home automation blog image
  1. Connect the TX pin of the HC-05 module to pin number 10 on the Arduino UNO
  2. Connect the RX pin of the HC-05 module to pin number 11 on the Arduino UNO
  3. Connect one of the relays signalΒ pins to pin number 5 and the other relays signal pin to pin number 6 on the Arduino UnoΒ 
  4. Connect the Vcc pins of theΒ Bluetooth module and relays to the Vcc of the Arduino UNO
  5. Connect the GND pins of theΒ Bluetooth module and relays to the GN pin of the Arduino UNOΒ 

Code


#include <softwareserial.h> //Software Serial Library
SoftwareSerial EEBlue(10, 11); // RX | TX
int relayPin1 = 5;
int relayPin2 = 6;
String command;
Β 
void setup()
{
Β  Serial.begin(9600);
Β  EEBlue.begin(9600); Β //Default Baud for comm, it may be different for your Module.
Β  Serial.println("The bluetooth gates are open.\n Connect to HC-05 from any other bluetooth device with 1234 as pairing key!.");
Β  pinMode(relayPin1, OUTPUT);
Β  pinMode(relayPin2, OUTPUT);
Β  digitalWrite(relayPin1, HIGH); Β //Relay Pins are active LOW
Β  digitalWrite(relayPin2, HIGH);
}
Β 
void loop()
{
Β 
Β  // Feed any data from bluetooth to Terminal.
Β  if (EEBlue.available()){
Β  Β  
Β  Β  String command = EEBlue.readStringUntil("\r\n");
Β  Β  Serial.println(command);
Β  Β  
Β  Β  if (command.indexOf("ON1") >= 0) { 
Β  Β  Β  digitalWrite(relayPin1, LOW);
Β  Β  Β  Serial.println("Turning ON Relay 1");
Β  Β  }
Β  Β  
Β  Β  if (command.indexOf("OFF1") >= 0) {
Β  Β  Β  digitalWrite(relayPin1, HIGH);
Β  Β  Β  Serial.println("Turning OFF Relay 1");
Β  Β  }
Β  Β  
Β  Β  if (command.indexOf("OFF2") >= 0) {
Β  Β  Β  digitalWrite(relayPin2, HIGH);
Β  Β  Β  Serial.println("Turning OFF Relay 2");
Β  Β  }
Β  Β  
Β  Β  if (command.indexOf("ON2") >= 0) {
Β  Β  Β  digitalWrite(relayPin2, LOW);
Β  Β  Β  Serial.println("Turning ON Relay 2");
Β  Β  }
Β  }
Β  // Feed all data from terminal to bluetooth
Β  if (Serial.available())
Β  Β  EEBlue.write(Serial.read());
}

Video

Product Showcase

See more

1 comment

  • Good projects

    Selvaraj

Leave a comment

Please note, comments must be approved before they are published