home automation using arduino and bluetooth
Arduino Arduino Basic to Advance Automation ECE engineering projects Microcontroller based projects

Home automation using Arduino and Bluetooth | Control devices with Smartphone

Hello Engineers, when it comes to getting up and turning that light of your room ON or Off, it feels lazy. In this Tutorial, we’re going to discuss home automation using Arduino and Bluetooth. We’ll be controlling home appliances with our phone Bluetooth. To achieve complete home automation using Arduino and Bluetooth on our mobile device, we are going to use Arduino and HC-05 Bluetooth Module.

We need something that can help us create wireless communication between our mobile’ Bluetooth and Arduino. For that, we using the HC-05 Bluetooth module here. Let’s discuss in brief Implementing home automation using Arduino and Bluetooth with detailed Circuits, Arduino Code, and Video.

So, let’s start with our today’s tutorial on Bluetooth home automation systems.

What is Bluetooth Module HC-05?

HC05 is a Serial Port Protocol Bluetooth Module. HC-05 Bluetooth module is a UART serial Converter module that can help wireless data transmission between two microcontrollers or a microcontroller and a device like a mobile or laptop via the use of wireless Bluetooth.

HC-05 Bluetooth module Pinouts

  • EN – It is Enable PIN. When this PIN is HIGH(1) then the module is set to AT command mode otherwise it is in the DATA mode by default.
  • RxD – It is the Rx(Receiver)PIN, Used to receive serial data from a microcontroller or any other hardware device.eg sensor.
  • TxD – Transmitter PIN, Used to Transfer the received data over Bluetooth to a connected device that supports Bluetooth.
  • GND – Ground PIN(-ve).
  • VCC – Input Power Supply pin +4v – +6V DC.
  • State – Used to check or notify the target device that the blue-tooth device is connected wirelessly to another device and working properly.

HC-05 Bluetooth Module Basic features and parameters:-

  • Operating Voltage 4V-6V
  • Operating Current: 30mA
  • Max Range: <100 (Typically 50-60m)
  • Baud Rates: 9600, 19200, 38400, 57600, 115200, 230400, 460800.
  • Serial Data BT module for microcontrollers like Arduino, AVR, etc.
  • Easy to interface/ pair with computers, and smartphones via Bluetooth.

Material and Components

  • Arduino UNO
  • HC-05 Bluetooth Module
  • Relay Module
  • LEDs (Optional)
  • Wires

Software Required:-

Circuit Diagram to Control home appliances using Bluetooth

home automation using arduino and bluetooth

Arduino Home Automation app configuration

Repeat the steps shown and then pair and connect the Hc-05 with the smartphone (default pairing code- 1234).

ON_State = ‘A’, OFF_State = ‘a’ the app will send these values when we will click the On/off via Bluetooth to the Arduino, and Arduino will change its output state- D2.

According to the code made by using these ON_State and OFF_State values.

Arduino Code for Bluetooth Home Automation

//arduino code for bluetooth home automation
//code by electroinvention and electrovilla

#define OUT 2 //setting pin2 as "OUT" variabe

char val; //declaring additional variable to read data received via bluetooth 

//declaring PIN2 as pinmode output
//PIN2 is connected to "OUT" variable

void setup() {
  pinMode(OUT, OUTPUT);

  Serial.begin(9600);
}

//begin the main loop here 

void loop() {
  if (Serial.available() == 1) {  //using boolean operator to check if data is being received 1(true)
    val = Serial.read(); // store the received bits to "val"
  }
//reading the data from "val" 
  if (val == 'A') {        //if received val=='A', then 'OUT=HIGH'
    Serial.println("LED_ON");
    digitalWrite(OUT, HIGH);
  } else if (val == 'a') {  //if val ='a', then 'OUT=LOW'
    Serial.println("LED_OFF");
    digitalWrite(OUT, LOW);
  }
}

Connection explanation & Working of Circuit

The RX of Arduino UNO is Connected to the TX of the HC-05 blue-tooth module So that Arduino Can receive the serial data from the HC-05.

The TX of Arduino is Connected with the RX of the HC-05 blue-tooth module So that HC-05 can receive the serial data from Arduino UNO and broadcast it over Bluetooth devices.

In this configuration, the HC-05 and Arduino UNO can Communicate with each other with the Serial USART Communication protocol. And Arduino will be able to read the received data from Bluetooth that we are going to send through our smartphone to control the devices connected at the output of the relay module.

VCC of HC-05 will be connected to the 5V pin of Arduino UNO, And GND with GND (Ground). To power the HC-05 blue-tooth Module.

There is no use of EN (Enable) and STATE pin of HC-05 Bluetooth Module in this circuit so these two pins are not connected anywhere.

The VCC pin and GND pin of the relay module is connected to the 5V & GND pin of Arduino UNO to Power the relay module.

The input signal pin of the relay module is connected with the Digital pin-2(D2) of the Arduino UNO.

At the Switching side, the Input Phase/live (P or L) wire is connected to the COM(Common terminal_ of the relay and the Phase Input wire or one wire of the bulb is connected to the NO(Normally Open) terminal, the Neutral(N) wire directly connects from mains supply to the load/bulb.

When the Arduino receives Val == ‘A’, Then Arduino prints the “LED_ON” string every time in the next line and the state of the D2 pin gets HIGH, Hence the relay turns ON and the COM(Common) terminal connects to the NO(Normally Open) terminal and hence current starts flowing to our appliance and Appliance – Bulb connected to NO(Normally open turns ON).

And when the Arduino receives val == ‘a’, Then Arduino prints the “LED_OFF” string every time in the next line, and the state of the D2 pin gets LOW, the Relay turns OFF and the Appliance – Bulb connected to it also turns back OFF.

This process repeats whenever Arduino receives val == ‘A’ or ‘a’ via blue-tooth from the app configured before.

To see the project working and more details, please follow the video below.

Working for Bluetooth Home Automation

We hope our content is helpful to you guys. If our content helps you in any way then please share it with your friends. Comment Below if you have any other requests or queries.

For more such articles and Circuits, please subscribe to our newsletter. It’s Free!:)

Content Protection by DMCA.com
Avatar
Gaurav
Hello Everyone, this is Gaurav Pant and I'm an Electronics/Electrical enthusiast, Science lover, and YouTuber. I love to make cool and unique DIY science projects.

2 Replies to “Home automation using Arduino and Bluetooth | Control devices with Smartphone

    1. Yes configure the app you have installed on your pc same as android app shown here or change the values in the code accoridng to your app configuration

Leave a Reply

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