SMART HOME AUTOMATION USING MOBILE APPLICATION

48
Home Automation Using Mobile Application A Project Report Submitted in partial fulfilment for the award of the Degree of Bachelor of Technology (Electrical Engineering) Submitted By: Eklavya Sharma (12EBKEE031) Rakesh Sharma (12EBKEE083) Under the Guidance of: Mr. Dinesh Kumar Assistant Professor BKBIET (Electrical Engineering) Department of Electrical Engineering B K Birla Institute of Engineering & Technology, Pilani (Rajasthan) (Under Rajasthan Technical University, Kota) May 2016

Transcript of SMART HOME AUTOMATION USING MOBILE APPLICATION

Page 1: SMART HOME AUTOMATION USING MOBILE APPLICATION

Home Automation Using Mobile Application

A Project Report

Submitted in partial fulfilment for the award of the Degree of

Bachelor of Technology (Electrical Engineering)

Submitted By:

Eklavya Sharma (12EBKEE031)

Rakesh Sharma (12EBKEE083)

Under the Guidance of:

Mr. Dinesh Kumar

Assistant Professor BKBIET (Electrical Engineering)

Department of Electrical Engineering

B K Birla Institute of Engineering & Technology, Pilani (Rajasthan)

(Under Rajasthan Technical University, Kota)

May 2016

Page 2: SMART HOME AUTOMATION USING MOBILE APPLICATION

ii

DECLARATION BY CANDIDATE

We hereby declare that the work which is being presented in the thesis entitled

(“Home Automation Using Mobile Application)” in fulfilment of the

requirements for the award of degree of Bachelor of Technology in Electrical

Engineering and submitted to B. K. Birla Institute of Engineering and

Technology, Pilani (Rajasthan) , India, is an authentic record of my own work

carried by me under the supervision of Mr. Dinesh Kumar (Department Of

Electrical Engineering), B. K. Birla Institute of Engineering and Technology,

Pilani-333031, Rajasthan.

Date: 09th May 2016 Name and Signature of the Candidates

Eklavya Sharma

Rakesh Sharma

Page 3: SMART HOME AUTOMATION USING MOBILE APPLICATION

iii

CERTIFICATE BY PROJECT GUIDE

This is to certify that Mr. Eklavya Sharma and Mr. Rakesh Sharma,

student of B.Tech. Electrical Engineering IV Year has submitted their

Project Report entitled (“Home Automation Using Mobile

Application’’) under my guidance.

Mr. Dinesh Kumar Assistant Professor

Department of Electrical Engineering

This is to certify that the above statement made by the guide is correct

to the best of my knowledge.

Signature of the Principal (Academics)

Date:

Page 4: SMART HOME AUTOMATION USING MOBILE APPLICATION

iv

ACKNOWLEDGEMENT

It gives me immense pleasure to express my deepest sense of gratitude and sincere

thanks to my guide Mr. Dinesh Kumar (Department of Electrical

Engineering) BKBIET, Pilani for his valuable guidance, encouragement and

help for completing this work. I would like to express my sincere thanks to Dr. P

S Bhatnagar, Director BKBIET, Pilani for giving me this opportunity to

undertake this project. I would also like to thank Dr. L Solanki, Principal

(Academics) BKBIET, Pilani for whole hearted support. I am also grateful to

my teachers for their constant support and guidance.

At the end I would like to express my sincere thanks to all my friends and others

who helped me directly or indirectly during this project work.

Student Name - Eklavya Sharma

Enrollment no. - 12EBKEE031

Student Name – Rakesh Sharma

Enrollment no. - 12EBKEE083

Date: 09th May 2016

Page 5: SMART HOME AUTOMATION USING MOBILE APPLICATION

v

TABLE OF CONTENTS

S.NO Topic PAGE NO.

Declaration By Candidate ii

Certificate By Project Guide iii

Acknowledgement iv

Abstract vi

1. Introduction 1

List Of Components Required 2

1.1 The Arduino Platform 2

1.1.1 Schematic Diagram 4

1.1.2 Power Supply 4

1.1.3 Memory 5

1.1.4 Input And Output 5

1.1.5 Communication 6

1.2 Arduino IDE 7

1.3 Bluetooth Module Hc-06 8

1.4 Dc Relays 10

1.5 Relay Driver Uln2003 Ic/ L293d 12

1.6 Ultrasonic Sensor (Hc – Sr04) 14

1.7 Power Supply For Arduino And Relay Driver 16

2. Connections With Arduino

2.1 Connecting Bluetooth Module Hc-06 20

2.2 Connecting Ultrasonic Sensor. 21

3. Smart Home Automation Flow Chart 23

3.1 Smart Home Automation Block Diagram 23

3.2 Programming Implementation Block

Diagram

23

4. Android Application Development 24

4.1 MIT App Inventor 24

4.2 Application Development Block Code For Smart Home

Automation

25

5. Program Code 30

Page 6: SMART HOME AUTOMATION USING MOBILE APPLICATION

vi

6.1 Arduino Program Code For Smart Home Automation 30

6.2 Arduino Program Code For Tank Level Measurement And

Control

33

6. Conclusion 36

7. Future Work 37

8. Applications Of Smart Home Automation 38

9. References 39

Page 7: SMART HOME AUTOMATION USING MOBILE APPLICATION

vii

ABSTRACT

Smart home automation refers to the use of computer and information technology to control

home Appliances and features (such as windows or lighting) through home networking to

enhance power efficiency and improve the quality of living. Nowadays home automation is

becoming more and more popular due its abundant advantages. Home automation systems can

range from simple remote control of lighting through to complex computer/micro-controller

based networks with varying degrees of intelligence and automation. Smart home automation

is adopted for reasons of ease, security and energy efficiency. Here, our aim is to design a kit

that can be used for controlling AC Loads from Android phone via Bluetooth Module HC-06

by using Arduino as microcontroller. I have also used the ultrasonic sensor HC-SR04 for the

tank level measurement which measures the water level of the water tank in real time and sends

the data to the Arduino phone accessed via the Mobile Application via the Bluetooth module

using thee serial communication. Here I’m using Arduino Uno r3 which is a microcontroller

board based on the ATmega328. The android mobile application is developed using the MIT

App-Inventor 2 tool. This project is beneficial in energy saving and security as well as for those

who are physically challenged as this application can take input as the voice command of the

user. The given system is cost effective, provides an ease of control and management and can

be easily installed for homes or commercial buildings.

Page 8: SMART HOME AUTOMATION USING MOBILE APPLICATION

viii

TABLE OF FIGURE

S.NO. FIGURE PAGE NO.

Fig. 1.1. Arduino Prototyping Board (Arduino Uno) 3

Fig. 1.2. Arduino Prototyping Board Pin Diagram

Fig. 1.3. Arduino Integrated Development Environment 8

Fig. 1.4. Arduino Integrated Development Environment 9

Fig. 1.5. DC 6/12 V Relays 10

Fig. 1.6. Relay Driving Circuit 11

Fig. 1.7. ULN2003 IC 12

Fig. 1.8. L293D Relay Driver IC 13

Fig. 1.9. Ultrasonic Sensor 14

Fig. 1.10. Full Wave Bridge Rectifier 15

Fig. 1.11. Full Wave Bridge rectifier 16

Fig. 1.12. Pin configuration of LM78XX series 17

Fig. 1.13. LM7805 Connections 18

Fig. 2.1. Arduino Uno and HC-06 (Bluetooth Module) Connections 26

Fig. 2.2. Arduino Uno and HC-SR04 (Ultrasonic) Connections 27

Fig. 4.1. MIT App Inventor 30

Fig. 4.2. Smart Home Mobile Application 31

Fig. 4.3. Block Code of Smart Home Application 32

Fig. 4.4. Tank Level Measurement Application 33

Fig. 4.5. Block Code For Tank Level Measurement 33

Page 9: SMART HOME AUTOMATION USING MOBILE APPLICATION

1

INTRODUCTION

Our smart home automation kit provides smartphone application based solutions for control &

energy optimization in industry, commercial buildings & homes. The kit requires a Arduino

Uno R3 having ATMega328 microcontroller for processing, Bluetooth module HC-06 is

required to transmit and receive data, relays are required to control the AC loads, ULN2003 IC

is used to drive the relays, an Android smartphone with the Smart Home Automation

application installed is required to control the AC loads fixed in the switch board and a power

supply of 12 V is required to power up the relays and Arduino requires the power supply of 7

V. If the DPDT (Double Pole Double Throw) switches are used then the kit can be made to

work manually as well as remotely.

Furthermore, the system can be improved for the door control, the temperature detection, the

light dimmer control etc. Similarly, the application can be improved for voice recognition. The

Smart Home Automation can be improved for receiving and sending signal through ESP8266

Wi-Fi module and can be controlled through mobile or computer via web.

Page 10: SMART HOME AUTOMATION USING MOBILE APPLICATION

2

OBJECTIVE

Aim is to design a kit that can be used for controlling AC Loads from Android phone using

Arduino

To understand the concept of Smart Home Automation

To communicate with the microcontroller or sensors

To establish Serial communication between Arduino and Mobile

To design a User Interface for HMI i.e. Mobile Application

To design the hardware connections between Arduino, HC-06, Relay and AC-loads

LIST OF COMPONENTS REQUIRED

1.1 THE ARDUINO PLATFORM

The Arduino platform is an open source electronic prototyping system. It is composed of two

parts, the Arduino Uno board and the Arduino IDE (Integrated Development Environment).

The Uno board is designed to provide an easy to use human changeable pin interface to the

Atmel AVR AT mega microcontroller, the heart of the Arduino hardware. The AVR

microcontrollers from Atmel use the C language for programming and are commercially

available and very popular with hobbyists and electronics enthusiasts. Arduino builds on this

by adding simplicity to the hardware interface and an easy to use software package.

The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital

input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal

oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains

everything needed to support the microcontroller; simply connect it to a computer with a USB

cable or power it with a AC-to-DC adapter or battery to get started. The Uno differs from all

preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it features

theAtmega16U2 (Atmega8U2 up to version R2) programmed as a USB-to-serial converter.

Arduino is meant to be used as a physical computing platform. That is, to use the electronic

hardware to interface with humans using sensors and actuators controlled by software executed

by a computer. The groundwork of this paper focuses on the physical computing aspect of

Arduino.

Page 11: SMART HOME AUTOMATION USING MOBILE APPLICATION

3

Fig. 1.1. - Arduino Prototyping Board (Arduino Uno)

Microcontroller ATmega328

Operating Voltage 5 volt

Input Voltage (recommended) 7-12 volt

Input Voltage (limits) 6-20 volt

Digital I/O Pins 14 (of which 6 provide PWM output)

Analog Input Pins 6

DC Current per I/O Pin 40 mA

DC Current for 3.3V Pin 50 mA

Table 1.1. - Arduino Specifications

Page 12: SMART HOME AUTOMATION USING MOBILE APPLICATION

4

SCHEMATIC DIAGRAM

Fig. 1.2. - Arduino Prototyping Board (Arduino Uno)

POWER SUPPLY

The Uno board can be powered via the USB connection or with an external power supply. The

power source is selected automatically.

External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery.

The adapter can be connected by plugging a 2.1mm center-positive plug into the board's power

jack. Leads from a battery can be inserted in the GND and Vin pin headers of the POWER

connector.

Page 13: SMART HOME AUTOMATION USING MOBILE APPLICATION

5

The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V,

however, the 5V pin may supply less than five volts and the board may become unstable. If

using more than 12V, the voltage regulator may overheat and damage the board. The

recommended range is 7 to 12 volts.

The power pins are as follows:

Vin- The input voltage to the Uno board when it's using an external power source (as opposed

to 5 volts from the USB connection or other regulated power source). You can supply voltage

through this pin, or, if supplying voltage via the power jack, access it through this pin.

5V.This pin outputs a regulated 5V from the regulator on the board. The board can be supplied

with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin

of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and

can damage your board. We don't advise it.

3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.

GND. Ground pins.

IOREF. This pin on the Uno board provides the voltage reference with which the

microcontroller operates. A properly configured shield can read the IOREF pin voltage and

select the appropriate power source or enable voltage translators on the outputs to work with

the 5V or 3.3V.

MEMORY

The ATmega328 has 32 KB (with 0.5 KB occupied by the bootloader). It also has 2 KB of

SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM library).

INPUT AND OUTPUT

See the mapping between Arduino pins and ATmega328P ports. The mapping for the Atmega8,

168, and 328 is identical.

Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode(),

digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or

receive 20 mA as recommended operating condition and has an internal pull-up resistor

(disconnected by default) of 20-50k ohm. A maximum of 40mA is the value that must not be

exceeded on any I/O pin to avoid permanent damage to the microcontroller.

Page 14: SMART HOME AUTOMATION USING MOBILE APPLICATION

6

In addition, some pins have specialized functions:

Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins

are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value,

a rising or falling edge, or a change in value. See the attachInterrupt() function for details.

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using

the SPI library.

LED: 13. There is a built-in LED driven by digital pin 13. When the pin is HIGH value, the

LED is on, when the pin is LOW, it's off.

TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of

resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though

is it possible to change the upper end of their range using the AREF pin and the

analogReference() function.

There are a couple of other pins on the board:

AREF. Reference voltage for the analog inputs. Used with analogReference().

Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to

shields which block the one on the board.

COMMUNICATION

The Uno has a number of facilities for communicating with a computer, another Uno board, or

other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication,

which is available on digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels

this serial communication over USB and appears as a virtual com port to software on the

computer. The 16U2 firmware uses the standard USB COM drivers, and no external driver is

needed. However, on Windows, a .inf file is required. The Arduino Software (IDE) includes a

serial monitor which allows simple textual data to be sent to and from the board. The RX and

TX LEDs on the board will flash when data is being transmitted via the USB-to-serial chip and

USB connection to the computer (but not for serial communication on pins 0 and 1).

Page 15: SMART HOME AUTOMATION USING MOBILE APPLICATION

7

A “SoftwareSerial” library allows serial communication on any of the Uno's digital pins.

The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino Software

(IDE) includes a Wire library to simplify use of the I2C bus; see the documentation for details.

For SPI communication, use the SPI library.

1.2 ARDUINO IDE

The open-source Arduino Software (also known as the Arduino IDE - short for Integrated

Development Environment) makes it easy to write code and upload it to the board. It runs on

Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing

and other open-source software. This software can be used with any Arduino board.

This software can be used with any Arduino board. The Arduino IDE is the software

environment used to create the programs, called “sketches,” that will be executed by the

Arduino hardware. The IDE uses a modified C language compiler to build, translate, and

transmit the code to the microcontroller board. The AVR microcontrollers are typically

programmed using the C language. Since C can be somewhat difficult to learn for the typical

hobbyist, the IDE makes a combination of modified C and Arduino specific commands

available to the user. The IDE provides the simplicity for less proficient users but supports

advanced users who are knowledgeable in C. The IDE also has a set of additional code

functions called libraries. Libraries extend the commands available to provide capabilities not

available in the core Arduino language. In essence, a library allows the user to perform

seemingly complex functions using a small set of commands.

Installing Arduino IDE

For Windows 8, 7, Vista, and XP

Go to the Arduino download page and download the latest version of the Arduino software

for Windows.

When the download is finished, un-zip it and open up the Arduino folder to confirm that

yes, there are indeed some files and sub-folders inside. The file structure is important so

don’t be moving any files around unless you really know what you are doing.

Power up your Arduino by connecting your Arduino board to your computer with a USB

cable (or FTDI connector if you are using an Arduino pro).

Page 16: SMART HOME AUTOMATION USING MOBILE APPLICATION

8

Fig. 1.3. - Arduino Integrated Development Environment

1.3 BLUETOOTH MODULE HC-06

The Bluetooth module is used for communication between smart phone and the Arduino. The

Bluetooth module HC-06 allows the serial and UART communication between your Arduino

Uno or any microcontroller with a PC or a Smartphone equipped with a Bluetooth facility.

Connecting the Bluetooth module HC-06 with Arduino Uno have numerous application like

controlling home lights using Bluetooth module, driving a RC car, controlling robot using

mobile application etc. The Arduino pins 0 and 1 are specified for Universal Asynchronous

Receiver/Transmitter (UART) that control the interface with its attached serial devices.

Page 17: SMART HOME AUTOMATION USING MOBILE APPLICATION

9

The HC-06 Bluetooth module contains four pins-

PINS FUNCTIONS

TXD Serial output of the module used for the transmission of data

RXD Serial output of the module for receiving the data,

VCC It is in the range of 3.3-6 V

GND Ground.

NOTE: The Arduino pins 0 and 1 are specified for Universal Asynchronous

Receiver/Transmitter (UART) that control the interface with its attached serial devices. The

module is powered from Arduino 3.3 volt supply.

Fig. 1.4. - Arduino Integrated Development Environment

Page 18: SMART HOME AUTOMATION USING MOBILE APPLICATION

10

Specification of Bluetooth Module HC-06-

Bluetooth number HC-06

Operating Voltage 3.3-6.0 volts

Default baud rate 9600 bps

Signal Coverage 30ft

Default Password 1234

1.4 DC RELAYS

A relay is an electrically operated switch. Many relays use an electromagnet to mechanically

operate a switch, but other operating principles are also used, such as solid-state relays. Relays

are used where it is necessary to control a circuit by a low-power signal (with complete

electrical isolation between control and controlled circuits), or where several circuits must be

controlled by one signal. The first relays were used in long distance telegraph circuits as

amplifiers: they repeated the signal coming in from one circuit and re-transmitted it on another

circuit. Relays were used extensively in telephone exchanges and early computers to perform

logical operations.

Fig. 1.5. – DC 6/12 V Relays

Page 19: SMART HOME AUTOMATION USING MOBILE APPLICATION

11

A Relay is an electrically operated switch. Many relays use an electromagnet to mechanically

operate the switch and provide electrical isolation between two circuits. In this project there is

no real need to isolate one circuit from the other, but we will use an Arduino UNO to control

the relay.

Why to use relay for controlling AC light?

AC is alternating current 220v (India) which powers the ac lights. Arduino cannot control high

volt n amp, but a relay can do this job, which is the sole design of it. So we are using relay as

switch to control high power devices.

What is NO NC and COM in relay?

COM (Common connection) - It is the center terminal, It is hot as power to the load is

connected at this terminal.

NO (Normally open) - It acts like a switch, since it is open - there will be no contact between

COM and NO, When we trigger the relay module, it connects to COM by the electromagnet

inside the relay and supply to the load is provided, which powers up the light. Thus the circuit

is closed until we trigger the state to low in relay.

NC (Normally closed) - It is always in contact with COM, even when relay is not powered.

When we trigger the relay it opens the circuit, so the connection is lost. It behaves just opposite

to NO.

Fig. 1.6. – Relay Driving Circuit

Page 20: SMART HOME AUTOMATION USING MOBILE APPLICATION

12

To control the relays and thereby the lights we need to make a driver circuit which is needed

for the driving purpose as well as for the isolation of the AC power with the Arduino (Dc

power). For the driving purpose the LM293d can also be used.

1.5 RELAY DRIVER ULN2003 IC/ L293D

The relay driver ULN2003 ic is a high voltage and current darlington array ic, it comprises of

7-open collector darlington pairs with common emitters. A pair of darlington is an arrangement

of two bipolar transistors. This IC belongs to the family of ULN200x ICs and various types of

this family interface to various logic families. This ULN2003 IC is for 5V TTL and CMOS

logic devices.

Fig. 1.7. – ULN2003 IC

These ICs are used as relay drivers as well as to drive a wide range of loads, line drivers, display

drivers etc. This IC is also normally used while driving Stepper Motors. The pairs of darlington

Page 21: SMART HOME AUTOMATION USING MOBILE APPLICATION

13

in ULN2003 is esteemed at 500mA and can withstand peak current of 600mA.In the pin layout,

the i/ps & o/ps are provided reverse to each other. Each driver also has a suppression diode to

dissipate voltage spikes while driving inductive loads.

The ULN2003 has a 2.7kΩ series base resistor for each Darlington pair for operation directly

with TTL or 5V CMOS devices. The ULN2003 is known for its high-current, high-voltage

capacity. The drivers can be paralleled for even higher current output. Even further, stacking

one chip on top of another, both electrically and physically, has been done. Generally it can

also be used for interfacing with a stepper motor, where the motor requires high ratings which

cannot be provided by other interfacing devices.

Features:

500mA rated collector current(Single output)

High-voltage outputs: 50V

Inputs compatible with various types of logic.

Relay driver application

Inputs pinned opposite outputs to simplify layout

Seven Darlington’s per package

A Darlington transistor (also known as Darlington pair) achieves very high current

amplification by connecting two bipolar transistors in direct DC coupling so the current

amplified by the first transistor is amplified further by the second one. The resultant current

gain is the product of those of the two component transistors:

The seven Darlington pairs in ULN2003 can operate independently except the common

cathode diodes that connect to their respective collectors.

L293D IC:

The L293D is quadruple high-current half-H driver. The L293D is designed to provide

bidirectional drive currents of up to 600 milliampere at voltages from 4.5 Volts to 36 Volts.

L293D IC’s are designed to drive a wide array of inductive loads such as relays, solenoids, DC

and bipolar stepping motors, as well as other high-current and high-voltage loads [6]. Here, it

Page 22: SMART HOME AUTOMATION USING MOBILE APPLICATION

14

is used to drive two DC geared motors which are functioning as the rear wheels of the

RoboDroid. The features and specification can be found in the datasheet.

Fig. 1.8. – L293D Relay Driver IC

1.6 ULTRASONIC SENSOR (HC – SR04)

Ultrasonic ranging module HC - SR04 provides 2cm - 400cm non-contact measurement

function, the ranging accuracy can reach to 3mm. The modules include ultrasonic transmitters,

receiver and control circuit.

The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats do. It

offers excellent non-contact range detection with high accuracy and stable readings in an easy-

to-use package. From 2cm to 400 cm or 1” to 13 feet. It operation is not affected by sunlight

Page 23: SMART HOME AUTOMATION USING MOBILE APPLICATION

15

or black material like Sharp rangefinders are (although acoustically soft materials like cloth

can be difficult to detect). It comes complete with ultrasonic transmitter and receiver module.

This sensor is really cool and popular among the Arduino Tinkerers. So I’ve decided to post a

project example using this sensor. In this project the ultrasonic sensor read and write the

distance in the serial monitor. It’s really simple.

The basic principle of work:

(1) Using IO trigger for at least 10us high level signal,

(2) The Module automatically sends eight 40 kHz and detect whether there is a pulse signal

back.

(3) IF the signal back, through high level, time of high output IO duration is the time from

sending ultrasonic to returning.

Test distance = (high level time×velocity of sound (340M/S) / 2.

Fig. 1.9. – Ultrasonic Sensor

Page 24: SMART HOME AUTOMATION USING MOBILE APPLICATION

16

1.7 POWER SUPPLY FOR ARDUINO AND RELAY DRIVER IC

To make a power supply that can give you 12 V and current of 1 A.

The easy steps to design a power supply that can give you the DC output voltage you want with

input as 230 V AC. I’m using the power supply to power up my Arduino board and the relay.

The input voltage of an Arduino can vary from 7 -12 Volts. For the 12 V power supply design

I’ve used a simple full wave bridge rectifier circuit. A Full Wave Bridge Rectifier is a circuit,

which converts an ac voltage into a pulsating dc voltage using both half cycles of the applied

ac voltage.

The full wave bridge rectifier circuit is very reliable, cheaper and the resulting output is much

easier to smooth. The designing of the circuit would cost you less than ₹150(less than $5).

The input voltage of an Arduino can vary from 7 -12 Volts. For the 12 V power supply design

I have used a simple full wave bridge rectifier circuit. A Full Wave Bridge Rectifier is a circuit,

which converts an ac voltage into a pulsating dc voltage using both half cycles of the applied

ac voltage. The full wave bridge rectifier circuit is very reliable, cheaper and the resulting

output is much easier to smooth. The designing of the circuit would cost you less than ₹150(less

than $5).

Fig. 1.10. - Full Wave Bridge Rectifier

Page 25: SMART HOME AUTOMATION USING MOBILE APPLICATION

17

1. Step Down Transformer – A single phase 230:18 V step down transformer is required for

12v dc power supply. Likewise, to design a 5 V power supply you may use the 230:10.

There are three wire in the transformer and 9-0-9 (considering the 18 v) is written on it. So,

you are needed to connect the outermost wires of the transformer (which are of same

colors).

2. Diode – Four Diodes are used in the circuit for rectification and a single diode is used as

freewheeling diode. All diodes are 1N4007.

3. Voltage Regulator IC– LM 7812 a voltage regulator IC is used in the 12V DC Power

supply. Similarly, for 5 volt power supply just replace the LM 7812 with LM 7805.

4. Capacitances– capacitances are used for reducing ripples in DC power supply as per

specifications. A 1000 µF and a 10 µF capacitances. All these items are easily available at

electronics shop.

5. Copper wires– For AC mains they should have the current capacity of more than 1 A.

6. Jumper wires– For connection purposes.

7. Soldering iron

8. Soldering wire

9. General Purpose PCB

10. Two pin plug

Optional components

1. Adapter Jack- The adapter jack is used to connect the power supply with the Arduino

board.

2. Heat sink (optional) – For the high current outputs from the power supply and for proper

heat dissipation from the voltage regulator. The heat sink may be connected to the Voltage

regulator IC.

3. LED- You can also connect the led with a limiting resistor for the indication of power

supply.

4. Limiting resistor- Limiting resistors are used to limit the current flow through the LED.

A LM7805 Voltage Regulator is a voltage regulator that outputs +5 volts and the current up to

750mA. The output of LM7812 is given to the LM7805. The LM7805 is sufficient to drive the

three servo motors.

Page 26: SMART HOME AUTOMATION USING MOBILE APPLICATION

18

Fig. 1.11. - Full Wave Bridge rectifier

An easy way to remember the voltage output by a LM78XX series of voltage regulators is the

last two digits of the number. A LM7805 ends with 05, thus it outputs 5 volts. The 78 part is

just the convention that the chip makers use to denote the series of regulators that output voltage

is positive. The other series of regulators, the LM79XX, is the series that output voltage is

negative. After you have all the above required items, plan the layout of the power supply and

carefully solder all the components. The resulting system will be a 12 volt power supply with

700mA and check the output of the power supply with a multimeter.

Fig. 1.12. - Pin configuration of LM78XX series

Page 27: SMART HOME AUTOMATION USING MOBILE APPLICATION

19

The LM7805, like most other regulators, is a three-pin IC.

Pin 1(input pin): The input pin is the pin that accepts the incoming DC voltage, which the

voltage regulator will eventually regulate down to 5volts.

Pin 2(ground): Ground pin establishes the ground for the regulator.

Pin3 (output Pin): The output pin is the regulated 5 volts DC.

Fig. 1.13. - LM7805 Connections

Page 28: SMART HOME AUTOMATION USING MOBILE APPLICATION

20

CONNECTIONS WITH ARDUINO

In this section the connection of different components with the Arduino. The programming in

the Arduino will be according to the hardware connections with the Arduino. The Arduino is

needed to be connected with the Bluetooth module HC-06 and the ULN2003. The ULN2003

is connected with the relays. The relays controls the AC loads as per the instruction given by

the users through the Smartphone. The smartphone send instructions to the Arduino Uno which

gives the input to the ULN2003 (Darlington pair) which switch on or switch off the relay.

2.1 CONNECTING BLUETOOTH MODULE HC-06

The Bluetooth module HC-06 allows the serial and UART communication between your

Arduino Uno or any microcontroller with a PC or a Smartphone equipped with a Bluetooth

facility. Connecting the Bluetooth module HC-06 with Arduino Uno have numerous

application like controlling home lights using Bluetooth module, driving a RC car, controlling

robot using mobile application etc.

The Arduino pins 0 and 1 are specified for Universal Asynchronous Receiver/Transmitter

(UART) that control the interface with its attached serial devices.

BLUETOOTH MODULE HC-06 ARDUINO UNO R3

TX RX (pin 0)

RX TX (pin 1)

VCC 3.3 volt supply from Arduino

GND Arduino ground

Table 1.2. – Bluetooth Module And Arduino Connections

For the communication between the Arduino and the PC connected with a USB cable with

serial connection you’ll need a library called “SoftwareSerial.h“. This library allows

you to setup serial communication on (almost any) digital pin of the Arduino Uno.

Page 29: SMART HOME AUTOMATION USING MOBILE APPLICATION

21

Fig. 2.1. – Arduino Uno and HC-06 (Bluetooth Module) Connections

2.2 CONNECTING ULTRASONIC SENSOR.

The ultrasonic sensor is useful in tank level measurement the ultrasonic will measure the level

of the tank. A single I/O pin is used to trigger an ultrasonic burst and then "listen" for the echo

return pulse. Using this method, it measures the level of the water in the tank. This data of

water level is sent to the Android mobile phone using the Bluetooth Module HC-06 which

reads the data and can switch off the motor automatically at the time the water tank is full and

when the water tank is empty it will automatically starts the motor or the user

The HC-SR04 barely works to 10 feet giving a total path length of 20 feet and a path time of

about 20ms so set the timeout to something above that, say 25 or 30ms. If you put a resistor,

say 2k2 between E and T then only connect to T you can use the HC-SR04 from just one

Arduino pin. Look up single pin operation of ultrasonic sensors. Also if you are using a HC-

SR04 with a PicAxe you need to up the clockspeed to at least 8MHz otherwise they don’t see

the start of the echo pulse so pulsin never starts.

Page 30: SMART HOME AUTOMATION USING MOBILE APPLICATION

22

ULTRASONIC SENSOR (HC-SR04) ARDUINO UNO R3

TRIG Pin 6

ECHO Pin 7

VCC 5 Volts

GND Ground

Table 1.3. – Ultrasonic Sensor and Arduino Connections

Fig. 2.2. – Arduino Uno and HC-SR04 (Ultrasonic Sensor) Connections

Page 31: SMART HOME AUTOMATION USING MOBILE APPLICATION

23

SMART HOME AUTOMATION FLOW CHART

3.1 SMART HOME AUTOMATION BLOCK DIAGRAM

3.2 PROGRAMMING IMPLEMENTATION BLOCK DIAGRAM

Human InputMobile

ApplicationBluetooth Serial Communication

Arduino Processing

Relay ActionAC Load Action

Initialize Sensors Libraries

Initialize Bluetooth

Communication

Initialize All Variables

Assign Hardware Pins

Check Serial Communication

Read Serial Data

(Serial.read)

Input To Relays Via IC

ULN2003

Read Sensor Values

Send Serial Data To Mobile (Serial.write)

Automatic/ Manual (Users

Choice)

Page 32: SMART HOME AUTOMATION USING MOBILE APPLICATION

24

ANDROID APPLICATION DEVELOPMENT

4.1 MIT APP INVENTOR

MIT App Inventor is an open-source web application that allows the users to make software

applications for Android operating system. Even with limited programming experience one can

easily create an Android Application. App Inventor for Android is a visual language that relies

on simple programming blocks that users can drag and drop to create software applications. It

was made by Google and it is maintained by the Massachusetts Institute of Technology (MIT).

And MIT App Inventor 2 is the latest version of App Inventor.

It allows newcomers to computer programming to create software applications for the Android

operating system (OS). It uses a graphical interface, very similar to Scratch and the StarLogo

TNG user interface, which allows users to drag-and-drop visual objects to create an application

that can run on Android devices. In creating App Inventor, Google drew upon significant prior

research in educational computing, as well as work done within Google on online development

environments.

App Inventor and the projects on which it is based are informed by constructionist learning

theories, which emphasizes that programming can be a vehicle for engaging powerful ideas

through active learning. As such, it is part of an ongoing movement in computers and education

that began with the work of Seymour Papert and the MIT Logo Group in the 1960s and has

also manifested itself with Mitchel Resnick's work on Lego Mindstorms and StarLogo.

App Inventor makes Android app development highly visual, and highly intuitive. It is an easy

and fun way for the uninitiated to learn about computer programming, and is at the same time

a productive tool for advanced programmers alike. It is worth mentioning that despite being in

its infancy – that is to say beta phase – this platform still offers a robust set of programming

tools for all levels of programming ability and is ideal for use in education.

Indeed, a major angle being promoted by MIT/Google is its instrumentality in teaching and for

introducing anyone to programming, particularly young people, in say a high school setting.

Although, it has a much broader target audience than that. That is, adult non-programmers who

wish to teach themselves, and professional programmers.

Page 33: SMART HOME AUTOMATION USING MOBILE APPLICATION

25

MIT app inventor doesn’t support Internet Explorer browser. To use MIT App Inventor 2 for

Android, to develop mobile application you must use a compatible browser. Currently the

supported browsers are:

• Google Chrome 29+

• Safari 5+

• Firefox 23+

Fig. 4.1. – MIT App Inventor

4.2 APPLICATION DEVELOPMENT BLOCK CODE FOR SMART HOME

AUTOMATION

The application development for the smart home automation is done using thee MIT app

inventor tool. The user interface for the Android mobile application is made visually attractive

and intuitively designed. Four buttons to control for four light bulbs, a button for enabling the

Bluetooth and a list picker for connecting the Bluetooth Module is provided.

Page 34: SMART HOME AUTOMATION USING MOBILE APPLICATION

26

The commands for controlling the light can be given through voice a voice command mode

button is also provide for the voice control of the lights.

Fig. 4.2. – Smart Home Mobile Application

The application can be run on all android mobile phones. It provides fine, better, accurate and

fast control for the home ac lights. To use the application first of all the user, have to press the

Bluetooth button which will automatically switch on the Bluetooth on if it was not enabled.

After enabling the Bluetooth, the user has to pick the Bluetooth Module HC-06 and enter the

password.

The default password for the Bluetooth module is 1234. The user can also change the password

of the Bluetooth Module HC-06 using the AT commands. After the connection between the

Page 35: SMART HOME AUTOMATION USING MOBILE APPLICATION

27

mobile and Bluetooth Module has been established the user can easily control the lights by

pressing the buttons which are being provided near each label of the light name.

The block code image for the application development is shown in the figure given below:

Fig. 4.3. – Block Code of Smart Home Application

Page 36: SMART HOME AUTOMATION USING MOBILE APPLICATION

28

The mobile application for tank level measurement is shown in the figure:

Fig. 4.4. – Tank Level Measurement Application

Smart home application would give you the real time data of the water tank installed right into

your phone. So any time you can turn off or turn on the motor through your phone or otherwise

it will do it for you for a given minimum and maximum water limit. For an industry where

more than one tankers are installed you’ll get the real-time data of the filled capacity of the

different tanks and you can control them individually.

The real time tank level can be measured and seen in the mobile application. And accordingly

the motor connected with the water tank be controlled either automatically or manually. For

manual mode a button is provided to switch on or switch off the motor. For automatic mode,

whenever the tank level reaches to its 100% water level the motor will get turned off and when

Page 37: SMART HOME AUTOMATION USING MOBILE APPLICATION

29

the tank level reaches 0% the motor will get automatically switched on by the Arduino using a

relay and relay driver IC.

The Block code for the tank level measurement is shown below:

Fig. 4.3. – Block Code of Tank Level Measurement

Page 38: SMART HOME AUTOMATION USING MOBILE APPLICATION

30

PROGRAM CODE

The open-source Arduino Software (also known as the Arduino IDE - short for Integrated

Development Environment) is used to write the program code as it makes it easy to write the

code and upload it to the Arduino board. It runs on Windows, Mac OS X, and Linux.

The environment is written in Java and based on Processing and other open-source software.

This software can be used with any Arduino board.

The Arduino IDE is the software environment used to create the programs, called “sketches,”

that will be executed by the Arduino hardware. The program code for the project “Smart Home

Automation” is also written in the Arduino IDE.

Serial Communication:

To begin the serial communication, the statement “Serial.begin(speed)” is used that

communicate over the pins 0 and 1 of the Arduino board. It opens the serial port and sets the

data rate in bits per second (baud) for serial data transmission. Now to get the number of bytes

(characters) available for reading from the serial port “Serial.available( )”is used. The incoming

serial data sent from the mobile application is read using the function “Serial.read( )”.

6.1 ARDUINO PROGRAM CODE FOR SMART HOME AUTOMATION

/////// Relay pins are defined which are connected with the

output pins of ULN2003 ///////

const int relay1 = 13; // Pin 13 of Arduino is connected to

the first input pin of ULN2003

const int relay2 = 14; // Pin 14 of Arduino is connected to

the second input pin of ULN2003

const int relay3 = 15; // Pin 15 of Arduino is connected to

the third input pin of ULN2003

const int relay4 = 16; // Pin 16 of Arduino is connected to

the fourth input pin of ULN2003

Page 39: SMART HOME AUTOMATION USING MOBILE APPLICATION

31

int val;

int count1;

int count2;

int count3;

int count4;

// the setup routine runs once when you press reset:

void setup()

// initialize the digital pin as an output.

pinMode(relay1, OUTPUT);

pinMode(relay2, OUTPUT);

pinMode(relay3, OUTPUT);

pinMode(relay4, OUTPUT);

Serial.begin(9600);

// the loop routine runs over and over again forever

void loop()

if (Serial)

if (Serial.available() > 0)

val = Serial.read();

Page 40: SMART HOME AUTOMATION USING MOBILE APPLICATION

32

Serial.println(val, DEC);

relaycontrol(val);

void relaycontrol(int val)

switch (val)

case 101 : digitalWrite(relay1, HIGH);

delay(1000);

Serial.println("Relay 1 On");

break;

case 102 : digitalWrite(relay1, LOW);

delay(1000);

Serial.println("Relay 1 Off");

break;

case 103 : digitalWrite(relay2, HIGH);

delay(1000);

Serial.println("Relay 2 On ");

break;

case 104 : digitalWrite(relay2, LOW);

delay(1000);

Serial.println("Relay 2 Off");

break;

case 105 : digitalWrite(relay3, HIGH);

Page 41: SMART HOME AUTOMATION USING MOBILE APPLICATION

33

delay(1000);

Serial.println("Relay 3 On");

break;

case 106 : digitalWrite(relay3, LOW);

delay(1000);

Serial.println("Relay 3 Off");

break;

case 107 : digitalWrite(relay4, HIGH);

delay(1000);

Serial.println("Relay 4 On");

break;

case 108 : digitalWrite(relay4, LOW);

delay(1000);

Serial.println("Relay 4 Off");

break;

6.2 ARDUINO PROGRAM CODE FOR TANK LEVEL MEASUREMENT AND

CONTROL

#define trigPin 9

#define echoPin 8

const int relay1 = 13;

void setup()

Serial.begin (9600);

Page 42: SMART HOME AUTOMATION USING MOBILE APPLICATION

34

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(relay1, OUTPUT);

void loop()

int val;

long duration, distance, fdistance;

digitalWrite(trigPin, LOW);

digitalWrite(trigPin, HIGH);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = ((duration / 2) / 29.1);

if (distance > 0 && distance < 200)

fdistance = ((200 - distance) / 200) * 100;

Serial.print(fdistance, DEC);

if (fdistance == 99)

digitalWrite(relay1, LOW);

if (fdistance == 1)

digitalWrite(relay1, HIGH);

Page 43: SMART HOME AUTOMATION USING MOBILE APPLICATION

35

if (Serial.available() > 0)

val = Serial.read();

relaycontrol(val);

void relaycontrol(int val)

switch (val)

case 101 : digitalWrite(relay1, HIGH);

delay(1000);

break;

case 102 : digitalWrite(relay1, LOW);

delay(1000);

break;

delay(1000);

Page 44: SMART HOME AUTOMATION USING MOBILE APPLICATION

36

CONCLUSION

We have successfully designed a kit that controls the AC Loads from Android phone via

Bluetooth Module HC-06 by using Arduino as microcontroller. And designed a tank level

measurement system using the ultrasonic sensor HC-SR04 which measures the water level of

the water tank in real time and sends the data to the Arduino phone accessed via the Mobile

Application via the Bluetooth module using thee serial communication. We have also added

the voice command mode for the smart home application to control the AC loads and the tank

level measurement can be either automatic or can be controlled manually.

The system is cheap and designed for the commercial use. The minimum cost for designing the

smart home automation system and the water level measurement system is Rs 1000.

Page 45: SMART HOME AUTOMATION USING MOBILE APPLICATION

37

FUTURE WORK

Observing the present situation, we can build cross platform system that can be set up on

various platforms like iOS, Windows. Restriction only several devices can be removed by

extending automation of all other home appliances. To observe activity around a house or

business Security cameras can be controlled by the user. Security systems can include motion

sensors that will detect unauthorized movement and notify the user. Scope of this project can

be expanded to many areas by not restricting to only home. It will be flexible to support various

wired as well as wireless technologies like Bluetooth, ZigBee, Wi Wide Web.

Furthermore, the system can be improved for the door control, the temperature detection, the

light dimmer control etc. Similarly, the application can be improved for voice recognition. The

Smart Home Automation can be improved for receiving and sending signal through ESP8266

Wi-Fi module and can be controlled through mobile or computer via web.

Page 46: SMART HOME AUTOMATION USING MOBILE APPLICATION

38

APPLICATIONS OF SMART HOME AUTOMATION

1. Enhances energy saving, quality of living and security

2. Provides ease of control, management and energy optimization in industry, commercial

buildings & homes.

3. Beneficial for physically challenged

4. Cost effective and easy to installed in homes

5. Saving the water overflow problem thereby saving the water

6. Medical alert / Tele assistance.

7. Detection of fire, gas leaks and water leaks.

8. Smoke detector can detect a fire or smoke condition, causing all lights in the house to blink

to alert any person of the house to the possible emergency.

9. The system can call the home owner on their mobile phone to alert them, or call the fire

department or alarm monitoring company.

10. In terms of lighting control, it is possible to save energy when hours of wasted energy in

both residential and commercial applications by auto on/off light at night time in all major

city office buildings, say after 10pm.

Page 47: SMART HOME AUTOMATION USING MOBILE APPLICATION

39

REFERENCES

Books

1. McRoberts, Michael. Beginning Arduino. New York: Apress, 2010. Print.

2. Banzi, Massimo. Getting Started with Arduino. Sebastopol, CA: O'Reilly, 2009.

3. Margolis, Michael. Arduino Cookbook. Sebastopol, CA: O'Reilly, 2011.

4. Analog Devices Inc. "ADXL322 Datasheet." Small and Thin +- 2g Accelerometer.

5. Norwood: Analog Devices, 2007.

Website Site Links

1. http://www.codevista.net/182/how-to-connect-bluetooth-module-hc-06-with-arduino-uno

2. http://www.codevista.net/85/how-to-control-lights-through-mobile-app-using-bluetooth-

module-hc-06-and-arduino

3. http://www.codevista.net/269/introduction-to-the-arduino-platform-and-why-you-need-

one

4. http://www.instructables.com/id/Controlling-AC-light-using-Arduino-with-relay-

modu/?ALLSTEPS

5. http://googleblog.blogspot.in/2011/05/android-momentu m-mobile-and-more-at.html

6. http://developer.android.com/about/index.html

7. http://research.microsoft.com/en-us/projects/homeos

8. http://source.android.com/tech/accessories/index.html

9. http://developer.android.com/guide/topics/connectivity/us b/accessory.html#manifest.

10. http://source.android.com/tech/accessories/aoap/aoa.html

11. http://arduino.cc/en/Main/ArduinoBoardADK

12. http://source.android.com/tech/accessories/aoap/aoa2.htm

Reference Papers

1. “Smart Home for Elderly Care based on wireless sensor networks”, Ransing, Rasika S,

Nascent Technologies in Engineering Field (ICNTE), IEEE 2015.

2. “Smart Home Automation using wi-fi low power devices”, Folea S, Bordencea D, Hotea

C, Valean H, Automation Quality and Testing Robotics(AQTR), IEEE 2012

3. “Universal Mobile Application Development (UMAD) on Home Automation”, Amul

Jadhav, S. Anand, Nilesh Dhangare, K.S. Wagh, India Network and Complex Systems

ISSN 2224-610X (Paper) ISSN 2225-0603 (Online) Vol 2, No. 2, 2012.

Page 48: SMART HOME AUTOMATION USING MOBILE APPLICATION

40

4. “Ad-Hoc Low Powered 802.15.1 Protocol Based Automation System for Residence using

Mobile Devices”, Pradeep G., B. Santhi Chandra, M. Venkateswarao, Department of ECE,

K.L. University, Vijaywada, Andhra Pradesh, India IJCST Vol 2, SP 1, 2011

5. “Bluetooth Based Home Automation System using Cell Phone”, R Piyare, M. Tazil, IEEE

15th International Symposium on Consumer Electronics, 2011.

6. “Zigbee Based Home Automation”, Rana, Jitendra, Rajendra and Sunil N., April 2010.

7. “Safe and Secure PIC Based Remote Control Application for Intelligent Home”, E. Yavuz,

B. Hasan, I. Serkan and K. Duygu, International Journal of Computer Science and Network

Security, Vol 7. No. 5, May 2007.

8. “Towards Smart Home: Control Electrical Devices Online”, Muhammad Izhar Ramli,

Mohd. Wahab, Nabihah, Nornabihah Ahmad, International Conference on Science and

Technology: Application in Industry and Education, 2006.

9. “Java-Based Home Automation”, Al-Ali, Member IEEE & M. Al-Rousan, IEEE

Transaction on Consumer Electronics, Vol 50. No. 2, May 2004. [10] “Bluetooth Based

Home Automation System”, N. Sriskanthan and Tan Karand,Journal of Microprocessors

and Microsystems, Vol 26, 2002.

10. Hsien-Tang Lin" Implementing Smart Homes with Open Source Solutions" International

Journal of Smart Home Vol. 7, No. 4, July, 2013.

11. Rosslin John Robles1 and Tai-hoon Kim1" Applications, Systems and Methods in Smart

Home Technology: AReview" International Journal of Advanced Science and Technology

Vol. 15, February, 2010.

12. Sook-Ling Chua and Stephen Marsland and HansW. Guesgen" Beha viour Recognition

in Smart Homes Sook" Proceedings of the TwentySecond International Joint Conference

on Artificial Intelligence 2011.

13. Gowthami, Dr. Adiline macriga "Smart Home Monitoring and Con

trolling System Using Android Phone" International Journal of Emerging Technology and

Advanced Engineering Website: www.ijetae.com ISSN 2250-2459, ISO 9001:2008

Certified Journal, Volume 3, Issue 11, November 2013.

14. Saisakul Chernbumroong, Anthony S. Atkins, and Hongnian Yu Perception of Smart Home

Technologies to Assist Elderly People" 4th International conference on software,

Knowledge information manage and applications (SKIMA 2010).

15. Christian Reinisch, Mario J. Kofler, Wolfgang Kastner"ThinkHome: A Smart Home

as Digital Ecosystem" 4th IEEE International Conference on Digital Ecosystems and

Technologies (IEEE DEST 2010).