Home automation consists of integrating technology in the construction of a home so that many of the systems (lights, heating, air conditioning, etc) are automated. In this Home automation project, we are going to control electrical appliances using an Android App and Arduino. We are going to use the HC-05 Bluetooth module for communication and a Relay Module to control AC appliances using DC voltages.

1. CONCEPTS

Arduino Microcontroller

Arduino is an open-source board, that is, with a free license, used to build robotics, electronics and automation projects. It is a programmable board with a microcontroller and comprising a software part, or IDE, which, executed on a computer, is used to write and load computer code (in “C” language) into the board itself. The Arduino project was created to allow creative artists, designers and planners to prototype and project their ideas without having to have a lot of technical knowledge. Arduino is based on the idea of making the creation of electronic projects faster and easier but above all easy and within everyone’s reach.

Arduino Uno R3 board vector image
Figure 1: Arduino Uno Board

Bluetooth Module, HC-05

The HC-05 Bluetooth module is one of the most popular and inexpensive modules used for RF communications and it is easy to implement in your projects. The module has a range of 10 meters, and can be easily set using AT commands and can be programmed both as master and a slave. The module allows to transform a UART \ USART port more commonly known as serial into a Bluetooth port, generally with SPP (Serial Port Profile) profile, thus becoming a serial over Bluetooth. Normally this device is used when you want to communicate a microcontroller like Arduino with the outside world, where the outside world can be a SmartPhone, a Personal Computer, or other device equipped with a Bluetooth connection.

Bluetooth Module HC-05
Figure 2: Bluetooth Module HC-05
Instructions to change ID and Password of the Bluetooth Module

By default the Bluetooth name is HC-05 and the password is 1234. To change this you can follow the steps below.

Step 1: Upload Blank Sketch (Bare Minimum Program) to the Arduino Board.

Step 2: Now connect your Bluetooth module with Arduino as shown in Figure 2. Make sure to press and hold the push button on the Bluetooth Module and then connect Ground pins at the Last.

Figure AT Mode Bluetooth Mini Connections
Figure 2: AT Mode Bluetooth Connections (Click Image to see full Circuit)

Step 3: Upload Blank Sketch (Bare Minimum Program) to the Arduino Board.

Step 4: After connecting Ground pins you can release the push button.

Step 5: After following the above 4 steps correctly, the LED on the Bluetooth Module will start blinking slowly. This means you can now configure your Bluetooth Module using AT commands.

Step 6: Make sure Arduino is connected to your system and the right device and port are selected. Open Serial monitor on your system (Ctrl+Shift+M) and select the options as shown in Figure 3 (Baud Rate = 38400, Both NL&CR). Type “AT” and press send, you should see “OK”.

AT commands Bluetooth Serial Monitor Arduino
Figure 3: Arduino Serial Monitor. Select “Both NL&CR” and “38400 baud”.

Step 7: To change the Name of the Bluetooth Module send “AT+NAME=<New Name> as shown in Figure 4.

AT command to change name of HC-05 Bluetooth Module
Figure 4: AT command to change the name of HC-05 Bluetooth Module

Step 8: To change the Name of the Bluetooth Module send “AT+PSWD=<New Password> as shown in Figure 5.

Figure 5: AT command to change the password of HC-05 Bluetooth Module

Tip: To know the address of your device you can send “AT+ADDR” on the serial monitor. The address will help you to further identify your module as sometimes in your mobile you can only see the address of the Bluetooth Module for the first time. I don’t know why this happens but if you have the device address you can identify it easily.

Home Automation App

You need an app (download here) to control the Home appliances using Bluetooth. After downloading follow these steps to add a Room and components.

Step 1: Open Bluetooth settings of mobile and pair the HC-05 Module. Kindly note that only paired devices will appear in the Android App.

Step 2: Open the app and click on the Bluetooth icon to connect with the Bluetooth device.

Step 3: Click on + icon at the bottom right of screen to Add a Room. If Bluetooth is connected the Bluetooth icon will turn blue in color.

CANCEL OPEN Read the full documentation on how to use the app using Arduino. Documentation Home My Room No active device 07:45 PM

Step 4: Here you can change Room name, picture and add new devices. Click + to add a new device and swipe right to delete.

Step 5: After saving you can send data to the connected Bluetooth Device. Make sure to Pair your Bluetooth device before using the App

Relay Module

The relay is an electromechanical device consisting of a winding and one or more mechanical contacts, it is used for interrupting and switching AC circuits using very low DC voltage. Which means we can control Electrical appliances in our house using Arduino or any other Microcontroller.

Relay Module one Channel
Figure 6: Relay Module

The relay consists of three pins on the right side as shown in Figure 6; By default, a movable armature connects COM (common) pin with NC (Normally closed) pin. As soon as Relay receives HIGH voltage on IN (Input) pin it charges the coil inside relay which attracts the Movable armature and connect COM (Common) pin with NO (Normally Closed) pin. In this way, it works as a switch to control AC appliances which can be controlled using minute DC voltage.

2. COMPONENTS

3. CONNECTIONS

Figure Home Automation with Bluetooth and Arduino
Figure Home Automation with Bluetooth and Arduino

Figure 7: Connections of Bluetooth and Relay with Arduino

4. PROGRAM

Home automation project; Turn light bulb ON and OFF via Bluetooth using a Mobile App.

/*UNCIA ROBOTICS | www.unciarobotics.com
  PROJECT: Home Automation

  Connections:
  Arduino     Bluetooth   |    Arduino   Relay
  RX(0)       TX          |    2         IN
  TX(1)       RX          |    VCC       VCC
  5V          5V/3.3V     |    GND       GND
  GND         GND         |
*/

const int relay = 2;      //pin where Relay is connected
char data;                //variable to store data
void setup() {
  Serial.begin(9600);     //Begin serial communication
  pinMode(relay, OUTPUT); //make relay pin as output
}

void loop() {
  if (Serial.available() > 0) //if there is data on RX
  {
    data = Serial.read();     //save it inside variable
    if (data == 'a')
    { digitalWrite(relay, HIGH);  //Turn ON the Light
      Serial.println("Light ON");
    }
    if (data == 'b')
    { digitalWrite(relay, LOW);   //Turn OFF the Light
      Serial.println("Light OFF");
    }
  }
}

5. FUNCTIONS & LIBRARIES USED IN HOME AUTOMATION PROJECT



home automation project

  • Post published:June 21, 2020
  • Post category:Projects

This Post Has 10 Comments

  1. Devansh

    What’s the connection is I want to use both Bluetooth and switch as well?

    1. ashish

      you can connect other power supply source parallel to the neutral wire. so if anyone of them is ON your device will be ON. or You can implement OR gate on 220V supply (search online) For more understanding, you can study different types of gates.

  2. Anomymous

    Is there a way to display input status? Thank you for your good work.

    1. ashish

      No, this is one way only. You can read the signals using Arduino but Arduino cannot transmit data to the app. For two way communication check the this section again for an upcoming project based on WiFi.

  3. Tanmay

    What will be the change in program if I connect more device to the relay board? And can this whole project run on dc power source?

    1. ashish

      You just have to add these lines to the code
      if (data == ‘[custom character]’)
      { digitalWrite(relay, HIGH);
      Serial.println(“device on”);
      }
      Yes, this whole project can run on DC power. Instead of using Light bulb you can also use a normal LED with DC power supply at both ends of the relay.

    2. kabir

      do arduino store the program what i have uploaded in arduino after cutt off the power supply to arduino?

  4. Varun

    Bro this is good one
    But i need two or more phones to connect is that possible ?

    1. ashish

      Hi, that won’t be possible for now. Soon we will upgrade this app to work with wifi after that it will possible.

Leave a Reply