Introduction

Home automation using Arduino, relay, and a Bluetooth module is a popular project that allows you to control various electrical devices in your home wirelessly from a smartphone or any Bluetooth-enabled device. In this setup, the Arduino board acts as the main controller, the relay modules are used to switch the devices on and off, and the Bluetooth module provides the wireless communication interface.

Full Project on:

https://electronicsworkshops.com/2023/05/18/home-automation-using-arduino-relay-and-bluetooth-module/

Bill Of Materials

Edit

SNCOMPONENTS NAMEDESCRIPTIONQUANTITY
1Arduino BoardArduino UNO R3 Development Board1https://amzn.to/3UBnwTO
2Connecting wiresjumper wiresomehttps://amzn.to/3fMoSw7
3BreadboardNormal1https://amzn.to/3FUQlXe
4Bluetooth ModuleHC051https://amzn.to/3ocCncV
5Relay Module4 Channel1https://amzn.to/42XWPgK

Circuit Diagram

The circuit diagram of Home Automation using Arduino, Relay and Bluetooth Module is shown in the figure below. Arduino is our main controller here where we have interfaced Relay and Bluetooth Module.

Fig : circuit diagram of Home Automation using Arduino, Relay and Bluetooth Module

Interfacing with HC-05 Bluetooth Module


It is a small portable device that is used to be connected in the Arduino board so that it can communicate with mobile or smartphone.It has 6 pins, among which we are concerned with only 4 pins.

Pin of HC-05 Bluetooth Module
  • PIN 2  (RXD for receiving information from smartphone through Bluetooth medium)
  • PIN 3  (TXD for transmitting information from smartphone through Bluetooth medium)
  • PIN 4  (GND for grounding or zero potential point)
  • PIN 5  (VCC for supply of 5 Volt in order to power up HC-05)

The TXD pin of Arduino is connected to RXD pin HC-05 and the RXD pin of Arduino is connected to TXD pin of HC-05.
Here, TXD = 1 in Arduino  means transmission of information from Arduino to HC-05.And, RXD=0 in HC-05 means receiving information from from Arduino to HC-05.
Also, TXD = 1 in HC-05 means transmission of information from HC-05 to Arduino.And, RXD=0 in Arduino means receiving information from from HC05 to Arduino.

Interfacing with Relay Module

Relay module for Arduino is one of the most powerful application for Arduino as it can be used to control both AC and DC devices by simply controlling the relay by giving 5V. A relay is basically a switch which is operated electrically by electromagnet.

  • Logic GND: This will be connected to GND on your Arduino.
  • Input 1 (IN 1): This will be connected to digital pin(2) on your Arduino, or leave it unconnected if you do not want to use this channel.
  • Input 2 (IN 2): This will be connected to the digital pin(3) on your Arduino, or leave it unconnected if you do not want to use this channel.
  • Input 3 (IN 3): This will be connected to the digital pin(4) on your Arduino, or leave it unconnected if you do not want to use this channel.
  • Input 4 (IN 4): This will be connected to the digital pin(5) on your Arduino, or leave it unconnected if you do not want to use this channel.
  • Logic VCC : This will be connected to the 5v pin of the Arduino o power the 4 relay module.

Source Code / Programming

long int ac=2;
long int bulb=3;
long int heater=4;
long int fan=5;
char x;
void setup()
{
pinMode(ac,OUTPUT);
pinMode(bulb,OUTPUT);
pinMode(heater,OUTPUT);
pinMode(fan,OUTPUT);
digitalWrite(ac,LOW);
digitalWrite(bulb,LOW);
digitalWrite(heater,LOW);
digitalWrite(fan,LOW);
Serial.begin(9600); 
}
void loop()
{
  if(Serial.available()>0)
  {
  x=Serial.read();
  }
  if(x=='a')
  digitalWrite(ac,HIGH);
  if (x=='b')
  digitalWrite(ac,LOW);
  if (x=='c')
  digitalWrite(bulb,HIGH);
  if(x=='d')
  digitalWrite(bulb,LOW);
  if(x=='e')
  digitalWrite(heater,HIGH);
  if(x=='f')
  digitalWrite(heater,LOW);
  if(x=='g')
  digitalWrite(fan,HIGH);
  if(x=='h')
  digitalWrite(fan,LOW);
}

Application Installation

From the given below link install the app from google play store to your smartphone and connect it...

Read more »