Smart Home Automation System Project using Arduino
Smart Home Automation System Project using Arduino
Automation (such as home automation and industrial automation etc) has become important in today’s world as it helps to complete a task with lesser human assistance and in a smarter way. Houses are becoming smarter and developed these days with the help of automation devices.
Home electrical appliances are using remote-controlled switches rather than conventional switches. In today’s world, most of the people have access to smartphones and its use have become very popular and essential in our lives.
We can use smartphones to control the household appliances with just one click or one message. With the help of controllers and communication devices home appliances can be remotely controlled. In this project, we will use the Arduino UNO board for the development of Smart Home Automation project with the HC-05 Bluetooth module which is remotely controlled by a smartphone.
It can be really helpful for the paralyzed people who cannot do their work on their own and such devices can become a great help for these people.
Components Required
Arduino UNO
HC-05 Bluetooth Module
Relays
Jumper wires
Light Bulbs
Bluetooth Terminal HC-05 App (Download from play store)
Arduino UNO
Arduino is an open-source platform which is used to develop electronics projects. It can be easily programmed, erased and reprogrammed at any instant of the time. There are many Arduino boards available in the market like Arduino UNO, Arduino Nano, Arduino Mega, Arduino lilypad, etc with having different specification according to their use.
In this project, we are going to use Arduino UNO to control home appliances automatically. It has ATmega328 microcontroller IC on it which runs on 16MHz clock speed. It is a powerful which can work on USART, I2C and SPI communication protocols. This board is usually programmed using software Arduino IDE using a micro USB cable.
ATmega328 comes with preprogrammed onboard boot loader which makes it easier to upload the code without the help on external hardware. It has vast application in making electronics projects or products. The C and C++ language is used to program the board which is very easy to learn and use. Arduino IDE makes it much easier to program. It separates the code in two parts i.e. void setup() and void loop().
The function void setup() runs only one time and used for mainly initiating some process whereas void loop() consists the part of the code which should be executed continuously.
This model consists of 6 analog input pins and 14 digital GPIO pins which can be used as input-output, 6 of which provides PWM output and analog using pinMode(), digitalWrite(), digitalRead() and analogRead() functions.
6 analog input channels are from pins A0 to A5 and provide 10-bit resolution. The board can be powered either from using a USB cable which operates at 5 volts or by DC jack which operates between 7 to 20 volts. There is an onboard voltage regulator to generate 3.3 volts for operating low powered devices.
Since the ATmega328 work on USART, SPI and I2C communication protocol, has 0 (Rx) and 1(Tx) pins for USART communication, SDA (A4) and SCL (A5) pin for I2C and SS (10), MOSI (11), MISO (12) and SCK (13) pins for SPI communication protocol. These specifications make Arduino Uno board perfect for Home Automation project.
HC-05 Bluetooth Module
It works on the USART (Universal Synchronous Asynchronous Receiver Transmitter) protocol to communicate with other devices. It can work both in master and slave mode with supported baud rates 9600, 19200, 38400, 57600, 115200, 230400 and 460800. By default, it works on slave mode and master mode can be configured using AT commands.
It can be used to transfer data both ways from a microcontroller to any device and device to a microcontroller. HC-05 Bluetooth module works in command mode and data mode. Command mode is used to access the configuration setting of HC-05 using some AT commands and Data mode is used to send the data serially. Command mode can be accessed by grounding the “key” pin and using AT commands we can change its setting.
There are AT commands which can be used to change the name, password, baud rate, etc. of the module. Here are few AT commands:
AT – for checking if the module is communicating or not
AT+NAME = hc-05 – for changing the name of the device to “hc-05”
AT+PSWD = 1234 – for changing the password to 1234
AT+UART = 9600, 1, 0 – for changing the baud rate to 9600, stop bit to 1 and parity bit to 0.
Pin Out of HC-05:
EN/Key pin: This pin is used to set Bluetooth module in either command mode or data mode. Command mode can be accessed by setting this pin high and data mode can be accessed setting it low. By default, it is set as low in data mode.
VCC: This is the power supply pin which is connected to either 5V or 3.3V.
Ground: This is the ground pin of the Bluetooth module.
TXD: This pin used for serial transmission of the data.
Pin on RELAY Description
VCC 5V
GND Ground
Data pin “1” or “0” from microcontroller
NC For Normally Closed Circuit
COM Common
NO For Normally Open Circuit
Applications of the relay:
Relay is used to provide safety-critical logic.
They are used to control a high voltage circuit with a small voltage signal.
Relays are also used for protection purpose.
Relays are used in substation and grids when supplying electricity from one point to another.
Related Project: Automatic Street Light Control System using LDR
Circuit Diagram
The circuit is designed using Arduino, Bluetooth, relay, and LEDs. We have connected the Bluetooth serially with the Arduino. The Relay is used to operate the home appliances. We have used four relays for four appliances. You can change the numbers of the relay to operate various home appliances accordingly. While moving to the hardware, the LEDs will be replaced by Bulbs.
The command for controlling the home appliances will be sent through a “Bluetooth terminal HC-05 app” from your smartphone to the Bluetooth, connected to the Arduino. Then Arduino read the data coming serially to the Bluetooth. Hence, actions are performed according to the command coming from the Bluetooth to the Arduino.
Working of Arduino based Home Automation
Make the connection for Home Automation project as given in the circuit diagram. First of all, we connect the bulb with AC powered sources and with relays as given in the circuit diagram. Then the relays are given DC power from the Arduino Uno board.
Data pins of the relays are connected at pins 8, 9, 10 and 11 to the Arduino which are the output pins of Arduino. Then connect the HC-05 module with the Arduino Board as shown in the diagram and power the Adruino Board. Upload the code given at the end of the project using Arduino IDE.
Turn on the Bluetooth in your smartphone and connect the HC-05 module by entering the password. By default, the password is “0000” or “1234”. After successfully connecting your smartphone with the HC-05, Open “Bluetooth terminal HC-05 app in your smartphone” and it will show your device connected to HC-05. Now send the data “Bulb1 turn on” or “Bulb2 to turn off” to turn on or off any bulb. This is how you can control the lights in your home remotely.
Project Code
#include
int bulb1 = 8;
int bulb2 = 9;
int bulb3 = 10;
int bulb4 = 11;
SoftwareSerial bt(0,1); /* (Rx,Tx) */
String str;
void setup() {
bt.begin(9600);
Serial.begin(9600);
pinMode(bulb1,OUTPUT);
pinMode(bulb2,OUTPUT);
pinMode(bulb3,OUTPUT);
pinMode(bulb4,OUTPUT);
}
void loop() {
if (bt.available())
{
str = bt.read();
Serial.println(str);
//bulb1
if(str=="bulb1 on")
{
digitalWrite(bulb1,HIGH);
Serial.println("BUlB 1 is ON");
}
else if(str=="bulb1 off")
{
digitalWrite(bulb1,LOW);
Serial.println("BUlB 1 is OFF");
}
else
{
digitalWrite(bulb1,LOW);
}
//bulb2
if(str=="bulb2 on")
{
digitalWrite(bulb2,HIGH);
Serial.println("BUlB 2 is ON");
}
else if(str=="bulb2 off")
{
digitalWrite(bulb2,LOW);
Serial.println("BUlB 2 is OFF");
}
else
{
digitalWrite(bulb2,LOW);
}
////bulb3
if(str=="bulb3 on")
{
digitalWrite(bulb3,HIGH);
Serial.println("BUlB 3 is ON");
}
else if(str=="bulb3 off")
{
digitalWrite(bulb3,LOW);
Serial.println("BUlB 3 is OFF");
}
else
{
digitalWrite(bulb3,LOW);
}
//bulb4
if(str=="bulb4 on")
{
digitalWrite(bulb4,HIGH);
Serial.println("BUlB 4 is ON");
}
else if(str=="bulb4 off")
{
digitalWrite(bulb4,LOW);
Serial.println("BUlB 4 is OFF");
}
else
{
digitalWrite(bulb4,LOW);
}
}
}
Programming Code Explanation
Include the libraries required for the project, SoftwareSerial.h library is imported for serial communication with Bluetooth Module HC-05.
Declaration of variables of output pins of Arduino at 8, 9, 10 and 11 which goes to data pin of each of the four relays. Variable string “str” stores the data we get from smartphone using HC-05 Bluetooth Module.
#include<SoftwareSerial.h>
int bulb1 = 8;
int bulb2 = 9;
int bulb3 = 10;
int bulb4 = 11;
String str;
pinMode(bulb1,OUTPUT);
pinMode(bulb2,OUTPUT);
pinMode(bulb3,OUTPUT);
pinMode(bulb4,OUTPUT);
Bluetooth serial communication and serial monitor are initiated at 9600 baud rate.
bt.begin(9600);
Serial.begin(9600);
If the data got from the smartphone using Bluetooth Module HC-05 is “bulb1 on” then we turn on the bulb 1 by setting data pin of the relay as HIGH. If data is “bulb1 off” then we turn off the bulb by setting the data pin of the relay as LOW. If no data received for bulb 1 then we set our bulb 1 to LOW. The same thing is done for bulb 2, bulb 3, bulb 4.
if(str==”bulb1 on”)
{
digitalWrite(bulb1,HIGH);
Serial.println(“BUlB 1 is ON”);
}
else if(str==”bulb1 off”)
{
digitalWrite(bulb1,LOW);
Serial.println(“BUlB 1 is OFF”);
}
else
{
digitalWrite(bulb1,LOW);
}

Comments
Post a Comment