You are on page 1of 49

HOME AUTOMATION WITH VOICE

By
Muhammad Areeb Irfan
Taha Ahmad Sheikh

Supervisor
Mr. Haroon Ibrahim

Co-Supervisor
Mr. Ahmed Raheeq Sultan

Department of Electrical Engineering


Institute of Space Technology
Islamabad 2021
HOME AUTOMATION WITH VOICE

Thesis submitted to the Institute of Space Technology in partial fulfillment of the


requirements for the degree of Bachelor of Science in Electrical Engineering

By
Muhammad Areeb Irfan
Taha Ahmad Sheikh

Supervisor
Mr. Haroon Ibrahim

Co-Supervisor
Mr. Ahmed Raheeq Sultan

Department of Electrical Engineering


Institute of Space Technology, Islamabad
2021

i
Institute of Space Technology

Department of Electrical Engineering

Home Automation with Voice

By
Muhammad Areeb Irfan
Taha Ahmad Sheikh

APPROVAL BY BOARD OF EXAMINERS

Mr. Haroon Ibrahim Mr. Ahmed Raheeq Sultan

ii
AUTHOR’S DECLARATION

We take entire and full responsibility for all the research conducted for our project
“Home Automation with Voice”.
We solemnly declare that all the research undertaken, and all the development
undergone for the work presented in this thesis is done entirely by us. A little help has been
taken from sources which have been cited and referenced accordingly. Apart from this, no
foreign assistance or help is administered. This thesis is written in its entirety by us.
Furthermore, this thesis, nor any parts of this thesis, has been presented to any Institution.
We are clearly and aware of IST’s policy towards plagiarism and understand that
no tolerance is held regarding this concern. We solemnly declare that no part of this thesis
has been plagiarized. All references have been cited and there is no literal citation of more
than 100 words in total. All and any work presented in this thesis is our own original work.
Relevantly cited work has been distinguished from the originality of our research and
development.

Muhammad Areeb Irfan


BS-16-170401056

Taha Ahmad Sheikh


BS-16-160401044

3
We hereby acknowledge that submitted thesis is final version and should be
scrutinized for plagiarism as per IST’s policy.

Mr. Haroon Ibrahim

Dated: ________________

Mr. Ahmed Raheeq Sultan


Dated: ________________

Verified by Plagiarism Cell Officer


Dated: ________________

4
CERTIFICATE

This is to certify that the research work described in this thesis is the original work
of the authors and has been carried out under my direct supervision. I have personally gone
through all the data/results/materials reported in the manuscript and certify their
correctness/authenticity. I further certify that the material included in this thesis is not
plagiarized and has not been used in part or full in a manuscript already submitted or in the
process of submission in partial/complete fulfillment of the award of any other degree from
any institution. I also certify that the thesis has been prepared under my supervision
according to the prescribed format and I endorse its evaluation for the award of Bachelor
of Science in Electrical Engineering degree through the official procedures of the Institute.

____________________
(Mr. Haroon Ibrahim)

v
COPYRIGHT STATEMENT

Copyright in text of this thesis rests with the student author. Copies (by any process)
either in full, or of extracts, may be made only in accordance with instructions given by the
author and lodged in the Library of Institute of Space Technology (IST). Details may be
obtained by the Librarian. This page must form part of any such copies made. Further
copies (by any process) may not be made without the permission (in writing) of the author.
The ownership of any intellectual property rights which may be described in this
thesis is vested in Institute of Space Technology (IST), subject to any prior agreement to
the contrary, and may not be made available for use by third parties without the written
permission of the IST, which will prescribe the terms and conditions of any such
agreement.
Further information on the conditions under which disclosures and exploitation
may take place is available from the Library of Institute of Space Technology (IST),
Islamabad.

vi
DEDICATION

“To Allah ‘alone’ belongs the dominion of the heavens and the earth; He creates what He
wills. He gives to whom He wills female [children], and He gives to whom He wills
males [children]. Or He makes them [both] males and females, and He renders whom He
wills barren. He is indeed All-Knowing, Most Capable.”

(Chapter 25: Surah Ash – Shuraa: Ayat 49 – 50)

Dedicated to our exceptional parents, adored siblings, teachers and friends; whose
tremendous support and cooperation led us to this wonderful triumph; and of course, to
our beloved country Pakistan.

vii
ACKNOWLEDGEMENTS

First and foremost, we would use this opportunity to thank Allah Almighty for
granting us the spirit and strength to continue and complete this project. Without his
blessings, we are nothing. All praises for HIM and HIM alone.

We will thank our project and academic supervisor Mr. Haroon Ibrahim, who
guided us through all the technicalities and complexities of this project. His expertise and
guidance have made this project a very beneficial experience.

We am very grateful to our co-supervisor Mr. Ahmed Raheeq Sultan, as he made


this project easy for us through his supervision. His professional support throughout the
course of this project was of utmost importance and we gained a lot of exceptional feedback
from him. As supervisor and co-supervisor, their support and supervisions have always
been a valuable resource for us.

Finally, we would like to express our gratefulness to all the people who have
provided valuable support to our study and whose names we couldn’t bring to memory.

viii
ABSTRACT

The emergence of technology has enabled mankind to automate his daily life in
ways that was considered impossible a few years ago. Humans have grown accustomed to
smart systems that can offer help in daily-life tasks for as minimal effort as possible. The
need for comfort is the sole motivation behind smart-oriented environments. This project
aims to bring that comfort in the hands of the user as he gains total control over his own
living space. We’re using smart voice control along with android interface that allows in-
app control to the user and enables him to perform tasks such as turning the lights on or
turning the fans off without having to move. With the help of an app, the user relays a
voice-command to a smart Arduino - controlled system. With the help of integrated relays,
this system conveys the command to the required unit and performs that task. The virtual
assistant can be modified to fit the users’ daily routines. This project can soon find
integration in all households at a very effective cost, allowing room for further upgrades.
This approach to home automation should be attractive to people who seek to have control
over basic tasks without much mobility. In addition, the hardware needed to implement the
system is commonly available and inexpensive. The most sophisticated device in this entire
project is an android smart phone which has inarguably become one of the most crucial
integrations in our daily lives.

ix
This page is left intentionally blank.

x
TABLE OF CONTENTS

1 INTRODUCTION ...................................................................................................... 1

1.1 Accessibility of smartphones ............................................................................... 1

1.2 Internet of Things ................................................................................................. 1

1.3 Home Automation ................................................................................................ 2

1.3.1 Primary ideas on Home Automation............................................................. 2

1.3.2 Home Automation in Today’s Era ................................................................ 2

1.3.3 Voice Controlled Automation ....................................................................... 3

1.4 Research Objectives ............................................................................................. 3

1.5 Contribution ......................................................................................................... 3

1.6 Thesis Outline ...................................................................................................... 3

2 PRELIMINARIES ...................................................................................................... 4

2.1 Components.......................................................................................................... 4

2.1.1 Arduino Uno ................................................................................................. 4

2.1.2 Esp8266 Wi-Fi Module................................................................................. 5

2.1.3 Android Smartphone ..................................................................................... 6

2.1.4 Relay Module ................................................................................................ 6

2.1.5 Transistor 2N2222 ........................................................................................ 8

2.2 Deliverables .......................................................................................................... 8

2.3 Literature Review ................................................................................................. 8

2.3.1 The Present State of Home Automation ....................................................... 8

2.3.2 Popular Advancements in Automation ......................................................... 9

2.3.3 Amazon Alexa .............................................................................................. 9

2.3.4 Basic Working .............................................................................................. 9

2.3.5 Interface Application .................................................................................. 10

xi
2.3.6 Voice Commands ........................................................................................ 10

2.3.7 Google Home .............................................................................................. 10

2.3.8 Leviton Decora Smart Switch ..................................................................... 12

3 HOME AUTOMATION WITH VOICE .................................................................. 14

3.1 Basic Concept ..................................................................................................... 14

3.2 Basic Block Diagram ......................................................................................... 14

3.3 Circuit Diagram .................................................................................................. 15

3.3.1 Proteus Diagram.......................................................................................... 15

3.3.2 Simulation Results ...................................................................................... 15

4 CODING AND SIMULATION ............................................................................... 17

4.1 Arduino Coding .................................................................................................. 17

4.1.1 Setting up the Esp8266 Wi-Fi chip ............................................................. 17

4.1.2 Programming Arduino ................................................................................ 17

4.2 Development of Application .............................................................................. 21

4.2.1 Platform....................................................................................................... 21

4.2.2 Developing blocks for app .......................................................................... 21

4.2.3 Connecting with Wi-Fi ............................................................................... 22

4.2.4 Voice Recognition ...................................................................................... 22

4.3 Flow Diagram ..................................................................................................... 23

4.4 Final Project ....................................................................................................... 23

5 RESULT AND CONCLUSION ............................................................................... 24

5.1 Working Application .......................................................................................... 24

5.2 Control Box ........................................................................................................ 24

5.3 Deliverables ........................................................................................................ 24

5.3.1 Achieved Deliverables ................................................................................ 24

5.3.2 Un-achieved Deliverables ........................................................................... 24


xii
5.4 Differences between Simulation and Practical Results ...................................... 25

6 BIBLIOGRAPHY ..................................................................................................... 26

APPENDICES ................................................................................................................. 27

Schematic of Arduino Uno ..................................................................................... 27

Pin Configuration.................................................................................................... 27

Pin Configuration.................................................................................................... 29

ESP8266-01 Features .............................................................................................. 30

Pin Configuration.................................................................................................... 31

HC-05 Specifications and Features ....................................................................... 32

Features / technical specifications ......................................................................... 33

Schematic ................................................................................................................. 34

Pin Configuration.................................................................................................... 34

xiii
TABLE OF FIGURES

Fig 2.1 Smartphone as control center ................................................................................. 6


Fig 2.2 4-channel relay module .......................................................................................... 7
Fig 2.3 Image of Amazon Alexa/Echo ............................................................................... 9
Fig 2.4 Speculated architecture of Amazon Alexa ........................................................... 10
Fig 2.5 Block architecture of a Google Nest appliance .................................................... 11
Fig 2.6 Leviton Decora Smart Switch............................................................................... 12
Fig 2.7 Architecture for Leviton smart switch .................................................................. 13
Fig 3.1 Basic block diagram for Home Automation ......................................................... 14
Fig 3.2 Block Diagram of Home Automation System ...................................................... 15
Fig 3.3 Proteus Simulation ................................................................................................ 15
Fig 3.4 One LED ON ........................................................................................................ 16
Fig 3.5 LED OFF .............................................................................................................. 16
Fig 3.6 ALL LED ON ....................................................................................................... 16
Fig 4.1 Initializing pins ..................................................................................................... 17
Fig 4.2 Setting Pin modes ................................................................................................. 18
Fig 4.3 Sending AT commands ........................................................................................ 18
Fig 4.4 Get command ........................................................................................................ 19
Fig 4.5 Switching relay ..................................................................................................... 20
Fig 4.6 Feedback ............................................................................................................... 20
Fig 4.7 App interface ........................................................................................................ 21
Fig 4.8 List picker ............................................................................................................. 21
Fig 4.9 Connection status .................................................................................................. 22
Fig 4.10 Voice Recognition block .................................................................................... 22
Fig 4.11 Flow Diagram ..................................................................................................... 23

xiv
Chapter 1

INTRODUCTION
1.1 Accessibility of smartphones
This advancing age of technology has enabled us to carry fast and powerful devices
in our pockets for daily life usage. The bulky computers have become smaller, faster, and
more reliable, and thus are finding more and more integrations in our lives. A smartphone
of today carries more processing power than a desktop from a few years ago. According to
trusted outlets such as Forbes [1], and Business Inside [2], smartphones have become one
of the most rapidly growing industries.

A few years ago, in Pakistan, smartphones had just begun to expand as a daily utility.
As tradition calls, older generation was less uncomfortable with adapting to this but with
the passage of time they have grown more comfortable with it. As reported by Pew
Research Center [4]: older people, mostly above 65 years of age had difficulties in learning
computers then. For them, computers were huge, unnecessary, and considered difficult to
learn and operate, whereas nowadays, the elderly population in the Pakistan is getting more
open to using smartphones than personal computers. This is as a result of more and more
accessible features such as portability, easy interface, etc. Sensors such as health monitors,
voice recognition software allow for more ease of access. In addition, smartphones provide
a real-time connection to the surroundings using the internet.

1.2 Internet of Things


In the age of rapid growth and progress, everything is in a race to achieve the status
of ‘smart’. From cars to appliances, everything is becoming more and more user-friendly,
and these advancements aim at connecting more to the user’s daily and personal life. In a
nutshell, the Internet of Things is the concept of connecting any device (so long as it has
an on/off switch) to the Internet and to other connected devices [3]. The IoT is a giant
network of connected things and people – all of which collect and share data about the way
they are used and about the environment around them.

1
Devices and objects with built in sensors are connected to an Internet of Things
platform, which integrates data from the different devices and applies analytics to share the
most valuable information with applications built to address specific needs.

1.3 Home Automation


The most concerned department of IoT’s influence in today’s age is the concept of
smart homes. These homes are a set of automated appliances and devices that work together
in order to give the residents a complete and innovative experience. This technology is also
referred to as Domotic computing, and it allows the user to control home devices using a
remote, a UI, or any other method.

Now a day, the technology for making homes smart, malleable, fast, and responsive
with less errors and crashes is ready, and so are its consumers. The homes of today are
getting ready to being controlled by a single universal smart remote. They are getting smart
enough to automatically decide, how appliances can interact or how to adapt to their
owner’s requirements. There are already smart thermostats and sensors setup in modern
homes, which can learn and study their users' needs and preferences. It can then adapt to
the new habits, and changing routines of its user

1.3.1 Primary ideas on Home Automation


In 1930, the first idea of what could be called home automation was proposed at
the World Fairs. In 1966, Jim Sutherland developed a home automation system called
"ECHO IV" [4]. Unfortunately, this was a private project, and it never reached a stage
where it could be commercialized. This system was too advanced for its time, and another
reason for its demise was the lack of computing power and technology to utilize this system
to its desired extent.

The first patent for a remote-controlled system was, however, was put forward by
Nikola Tesla.

1.3.2 Home Automation in Today’s Era


Today’s technology has enabled the production of powerful, feasible, and
inexpensive automation devices. This has caused a surge in the popularity of home

2
automation as well as industrial automation. Big companies such as Amazon and Google
have jumped in on the race to commercialize smart residency. These will be discussed later.

1.3.3 Voice Controlled Automation


There was a time when talking to technology was one of the most focal points of
science fiction. This had a natural appeal to all those fascinated by it as the idea seemed
alien and foreign. Now, this concept is no longer a thing of the future. Through voice-
controlled access, users can interact with their own homes and carry out basic tasks through
a single spoken command. This appeal is one of the foremost driving factors of the surge
in automation and smart home industry.

1.4 Research Objectives


The main objectives of thesis are:

a.

1.5 Contribution
This thesis will contribute in the following ways:

a.

1.6 Thesis Outline


The basic outline of the thesis is:

Chapter 1: Introduction.

Chapter 2: Preliminaries.

Chapter 3: Working of Home Automation with Voice.

Chapter 4: Coding and Simulation

Chapter 5: Results and Conclusions

Chapter 6: Bibliography

3
Chapter 2

PRELIMINARIES
Before digging into the solution, there are some preliminaries that need to be
addressed. The literature review is also carried out in this chapter.

2.1 Components
2.1.1 Arduino Uno
Arduino Uno is our choice of micro-controller for this project. It is one of the most
widely used prototyping microcontroller platform. It is built and tested on robust AT mega
controller series from Atmel Corporation. Arduino hardware platform already has the
power, reset circuitry setup, as well as circuitry to program and communicate with the
microcontroller over USB. It offers 14 digital I/O pins and 6 analog pins. 6 out of the 14
digital I/O pins can also be used for a PWM output. Further, it comes with a 16 MHz quartz
crystal [7]. We will now discuss why we chose Arduino Uno over any other
Microcontroller.

2.1.1.1 Price
Arduino Uno is a very cost-effective gateway into the world of automation. It is
cheap as compared to other pricey alternatives such as the raspberry-pi. Price plays a very
vital role in this project since the goal is to provide home automation at a relatively lower
cost. This goal can be achieved by utilizing the processing capabilities of Arduino Uno
with a very low cost. An Arduino board costs around $10-15.

2.1.1.2 Availability
Arduino is readily available, and one does not have to wait for foreign deliveries to
get hands on one. Its availability is one major factor in giving it preference over other
controllers. Combined with its cost effectiveness, this becomes the most ideal component
for us.

2.1.1.3 Ease of Integration


One of the main reasons to employ the Arduino Uno is its ease of access and
usability. Arduino requires a basic command over the C language, and it can easily be
programmed to perform any required tasks. The interface for the Arduino IDE is user-
4
friendly and ready to use. This means the user can dive straight into coding without having
to worry about setting up an entire environment.

Furthermore, the hardware interaction and integration of devices with the Arduino
is very straightforward and does not require much mastery of the subject. This makes
Arduino very favorable and comfortable to work with.

2.1.2 Esp8266 Wi-Fi Module


For our project, we have chosen to use Wi-Fi as a mode of communication between
the user and the controller. Any commands given to the application will be relayed to the
control box through Wi-Fi. For this purpose, we have employed the Esp8266 Wi-Fi
module.

2.1.2.1 Reason for choosing Wi-Fi over Bluetooth


There was a time when Bluetooth was considered the benchmark for data transfer
between devices. It could exchange information in any place where the internet was not
accessible. Nowadays, the internet virtually encompasses every corner of the globe. Urban
centers are populated with Wi-Fi access points and there is hardly a household that does
not employ internet for daily needs. In short, Wi-Fi has become a core component of each
household. This gives Wi-Fi a fair advantage over Bluetooth.

Furthermore, Wi-Fi technology has a large range of connection, and it can cover
wide areas without any hindrance. In contrast, Bluetooth is unable to cover the span of an
entire house, so it becomes hard to believe that Bluetooth can be used as a substitute for
Wi-Fi. These reasons have made Wi-Fi our primary mode of communication between the
user and the appliances.

2.1.2.2 Price
Esp8266 Wi-Fi module is a very cost-effective solution to our needs. We need a
low-price module that can emulate a Wi-Fi connection. It is easy to interface with the
Arduino and comes with Flash presets that can make it ready to be used with home
automated systems.

5
2.1.2.3 Availability
This section falls more in line regards to availability of Wi-Fi in general. As
described earlier, internet has become one of the most integral parts of our lives and we
need Wi-Fi to access it easily at most times. This has made Wi-Fi technology easily
accessible and available throughout the globe. Any household that chooses to employ home
automation must have already a Wi-Fi system integrated into their homes and daily
lifestyles. This ease of availability makes Wi-Fi, and the Esp8266 module, our preferred
solution.

2.1.3 Android Smartphone


This is perhaps the most obvious choice of a component. We need a medium to
relay information between the user and the control box. For this, we will use our
smartphone. This is an obvious choice because everyone is equipped with a smartphone
for daily life uses and it has become a crucial part of our daily activities. Giving the user
total control over their house through a device they keep with themselves always is why a
smartphone is an optimal choice. We use the phone’s built-in functionalities to process
speech and get a desired feedback.

Fig 2.1 Smartphone as control center

2.1.4 Relay Module


At the core of our project, we are using relays to control our circuitry. When the
Arduino receives a command, it is required to either turn ON or OFF an appliance or a
device. For this purpose, we employ the Relay module. It acts as an electromagnetic switch
which opens or closes with respect to the given command. Upon closing, it completes the
circuit, and the appliance is turned ON, and vice versa.

6
Fig 2.2 4-channel relay module

2.1.4.1 Types of Relays


There are many kinds of relays, and we must choose one that suits our needs.

Electromechanical Relays: These relays rely on a mechanical switch which is controlled


electromagnetically. The passing current generates a field which opens or closes the switch.
These relays can be used for both AC and DC purposes.
Electro-thermal Relays: These relays rely on thermal properties of metals. Two metal
strips with different thermal expansion coefficients are fused together to make a bimetallic
strip. This strip is placed near a heating coil. As current passes and raises the temperature,
this strip is bent due to both metals having a different coefficient of thermal expansion.
This bending makes the switch open or close a circuit.

Solid State Relays: This kind of relay does not have any mechanical or moving parts.
Unlike other types, this relay is made up of a semiconductor in conjunction with an opto –
coupler. As current passes, a lit up led emits light onto the semi-conductor and this
phenomenon emulates a switch.

Hybrid Relays: As is obvious by the name, this kind of relay is a mix between an
electromechanical and a solid-state relay. This relay reduces heat and limits any kind of
loss.

Choice for Relay: We have chosen to implement an electromechanical relay for our
project. This kind of module is best suited for the functioning of home automation. A hub
of 12-V relays will be used to act as switches throughout our circuitry.

7
2.1.5 Transistor 2N2222
This transistor is an NPN BJT transistor. We need a transistor because the relay needs
a 12V input to turn on. However, since we are controlling through Arduino, we can only
provide a 5V signal. The 2N222 transistor allows the 5V signal from Arduino to switch a
12V signal and turning it on. Also, this transistor acts as a protection in case of a current
flowing backwards.

2.2 Deliverables
The deliverables for the project are as follows:

a. Create a control box to control appliances


b. Use application to interface with control box
c. Create App to receive voice command or touch and relay it to control box

2.3 Literature Review


2.3.1 The Present State of Home Automation
Today, home automation is already popular as it is present in discrete manners in
almost all places. From Air conditioners to smart TVs, all appliances come equipped with
a smart utility in some form or the other. Most of the top companies are trying to make a
visible appearance in this industry as well.

In 2010, former Apple engineer Tony Fadell founded Nest Labs [5] with his partner
Matt Rogers. This company specializes in the production of smart devices and smart-home
based systems that can find easy integrations in an ordinary home. This company was
bought by Google in 2014 for $3.2 billion. The acquisition of a smart-based company by
Google is a marker of the technology’s significance.

Most of the world’s top technology companies have been working on developing
their own version of home automation technology. The research has been ongoing for a
couple of years now. Many of them have either come up with their version of the
technology for the general public to buy, or they have their initial prototypes, ready to be
launched soon.

Amazon has also been leading the Home-automation industry through their line of
Alexa/Echo products which aim at providing a smart user-friendly environment.
8
2.3.2 Popular Advancements in Automation
It is essential to study in the work already done in this field in order to make the
current work more effective. For this we look at some of the most popular advancements
in the field of home automation and study their aspects.

2.3.3 Amazon Alexa


Alexa by Amazon is a voice-based approach to smart home automation. It operates
on an ecosystem of gadgets that work together in order to create a smart AI-powered
environment. The physical device used to interact with Alexa is called the Echo, which
gets the actual voice-command and relays it to Alexa.

Fig 2.3 Image of Amazon Alexa/Echo

2.3.4 Basic Working


Alexa follows the same principal of getting the command from the user and then
relaying it forward, to be processed. This command then returns the required service by
carrying it out through integrated systems. As shown in Fig.1.3.

9
Fig 2.4 Speculated architecture of Amazon Alexa

2.3.5 Interface Application


This system utilizes a smartphone/desktop application in order to provide a
seamless experience. This app includes modifications and adjustments, so that the user can
employ desirable features for suitable locations.

2.3.6 Voice Commands


The most notable feature of the Alexa is its voice-control based home automation.
As described earlier, Alexa is a network, and can be described as the internet. To access
this network, a device called the Echo is used. This device receives the command from the
user and relays it forward to be converted and understood by the system. The trigger for
these commands is usually the keyword ‘Alexa’, but it can be modified to fit the user’s
needs. It needs a Wi-Fi connection to connect to the home Internet, thus all the natural
language processing and understanding should be done on the cloud. Echo has a default
female voice to talk back to the user.

2.3.7 Google Home


Google Home is another notable name in the field of home and residential
automation. Google bought and owned Nest and integrated it as Google Nest which is now
Google’s own branch dedicated to smart home appliances. Nest devices work with Google
home in order to provide a reliable experience.

10
2.3.7.1 Basic Concept of Google Home
Google home integrates Nest as an essential part of its system. It uses the same
approach as any automation system where the command is sent forward to the server to be
processed and give feedback. We can take the Nest Thermostat for example which is
programmed to learn the user’s preferred settings for specific times of the, or for specific
days of the year.

Fig 2.5 Block architecture of a Google Nest appliance

2.3.7.2 Interface
Google is a vital component in almost any software we use. Let it be operating
systems, search engines, or smartphone integrations. Google has made itself a necessary
inclusion in all fields of work. Due to this, it is always in the palm of our hands and a simple
touch away. In smartphones, saying ‘OK Google’ acts as a wake-up trigger for the smart
assistant to meet the user’s needs. Similarly, all Google appliances can be interacted with
via the Google assistant. This is highly user-friendly and extremely comfortable to get used
to.

The interface is not limited to a single device either. The Google home mini or the
Google home device, can act as a universal assistant which stays always connected to
Google. It can receive audio commands and process them as per the users’ requirements.

11
2.3.8 Leviton Decora Smart Switch
Leviton is a leading name when it comes to smart home appliances. It specializes
in smart switches. The switch is primarily used for smart lights or dimmers and can be
controlled with any smartphone provided the application is installed. This resembles very
closely to our project.

Fig 2.6 Leviton Decora Smart Switch

2.3.8.1 Working of Leviton Switch


The architecture for a Leviton switch is entirely different than the systems discussed
before. This switch does not rely on a HUB system. This means that it is a hub-less solution
which simply uses Wi-Fi or your wireless access point in the home to control these devices
[6]. Leviton Decora switch uses a dedicated IP address to connect with a smartphone app.
Each Leviton Decora switch has an inbuilt Wi-Fi chip that can individually act as a TCP/IP
server. The Leviton Decora app is free to download through app stores. Once installed, the
app asks user to connect 24 with the Leviton Decora’s own Wi-Fi access point.

The user must manually connect to the Wi-Fi access point of Leviton Decora
switch. The app then requests user to enter the main router’s login credentials. This router
is the Wi-Fi router that connects to your smart device. The app then sends the credentials
to the Leviton Decora switch. The Leviton Decora switch uses this login credentials to
authenticate itself as a device on the wireless network and receives an IP address on the
network. The switch then sends it to its app, which stores it in its memory for sending and
receiving messages.

12
Fig 2.7 Architecture for Leviton smart switch

13
Chapter 3

WORKING OF HOME AUTOMATION WITH VOICE


3.1 Basic Concept
This automation system follows a basic concept of interacting with daily-use devices
through the smartphone without having to move from one place. The user could interact
with these devices using an application on their android device. This could either be carried
out through touch, or a voice command. A basic block diagram is presented in Figure 1.1.

Fig 3.1 Basic block diagram for Home Automation

The user would input a command in the application installed on their device. The
method of input is entirely up to the user. The application processes this command and
communicates it to the dedicated micro-controller. This micro-controller is itself integrated
to the house’s electrical system through a series of relays. These relays act as switches and
upon receiving a command from the micro-controller, turn ON or OFF. This will be
elaborated further.

3.2 Basic Block Diagram


The user inputs his command to his smart phone using voice or touch-based interface.
This command is relayed to the Arduino over Wi-Fi, using the Wi-Fi module integrated
with the control box. The control box consists of the Arduino, Wi-Fi module, and the Relay
module. Illustrated below is the basic block diagram of how our project is supposed to
work.
14
Fig 3.2 Block Diagram of Home Automation System

3.3 Circuit Diagram


3.3.1 Proteus Diagram
This is the circuit diagram proposed for our project. The Esp8266 Wi-Fi module
cannot be simulated, and it is only being used to represent Wi-Fi connectivity. Two modes
of communication are being used. Two devices are connected to the HC-05 Bluetooth
module while the other two are connected to Esp8266.

Fig 3.3 Proteus Simulation

3.3.2 Simulation Results


We have successfully been able to convey a voice command to the Arduino using
an emulation port and connecting our simulation with the actual app as well as the serial
monitor. Following are the results. As mentioned earlier, we can only simulate results from
the Bluetooth.
15
Fig 3.4 One LED ON

Fig 3.5 LED OFF

Fig 3.6 ALL LED ON

16
Chapter 4

CODING AND SIMULATION


4.1 Arduino Coding
Our first step into making this project is to program the Arduino in such a way that
it can respond to whatever the user requires from it. All commands will be relayed to the
Arduino, and it will then perform the specific task. We will look at each aspect as we move
on.

4.1.1 Setting up the Esp8266 Wi-Fi chip


The Esp8266 has a variety of uses. For these uses to be utilized, we need to update
the firmware of the chip in order to utilize AT commands. AT commands are solely
responsible for the functioning of thus module, such as restart, test, disconnect, etc. A detail
of these commands is given in in the appendix.

We will download the AT v0.9.4.2 firmware for our module and flash it into the
chip. Before this process, we attach the GP_IO and ground pins of the Wi-Fi module to
ground of Arduino and the CH-PD and Vcc pins of the module to 3.3v pin of Arduino.
After the chip has been flashed, we can use it for communication between the app and the
micro-controller.

4.1.2 Programming Arduino


Now, we can move to write code for our Arduino. We use the Arduino IDE for this
purpose. In this section, we will look at each block of code to illustrate how it is working.

4.1.2.1 Initialize pins

Fig 4.1 Initializing pins


17
We have defined variables and at specific pins. These pins will be used as the
connection points for relays. The variable flag indicates the status of the relays. For default,
all relays are set at 0, which, means it is OFF.

4.1.2.2 Set Pin Modes


We now need to determine whether we need to use these pins as input or output.
Our requirement is an output to the relay, so we will be initializing them as output, also
setting them as LOW for default.

Fig 4.2 Setting Pin modes

4.1.2.3 Initialize AT commands


As mentioned before, we need AT commands to interface our Wi-Fi module. For
this, we will now implement some of them and discuss what each command does.

Fig 4.3 Sending AT commands

18
a. “AT+RST\r\n” is the command to reset the module and flush any existing garbage
values.
b. “AT+CWMODE=2\r\n” configures the module to serve as an access point.
c. “AT+CIFSR\r\n” receives the Ip address for the home device for effective
communication.
d. “AT+CIPMUX=1\r\n” configures the module to allow multiple connections. This can
be configured as per the user’s desires whether if he requires multiple devices to access
the automation system or not.
e. Finally, “AT+CIPSERVER=1, 80\r\n” configures the module to turn the server on at
port 80.

4.1.2.4 Read incoming data from App


As has been made clear already, the app is supposed to send data to the Arduino for
specific pins. Each chunk of incoming data refers to a specific pin and requires it to be
turned off or on. For this, it is necessary for us to understand which pin needs to be
accessed.

Fig 4.4 Get command

This piece of code first checks if the Esp8266 is receiving anything from the phone
and relaying it to the Arduino. In case it is doing that, it reads and displays the command
that is coming from the client.

19
4.1.2.5 Switching relays on and off
After reading variables and getting the incoming data, the relay must be switched
ON or OFF. This is where we utilize the flags. If the command is to turn the relay OFF,
but the flag is already 0, it will do nothing. And vice versa.

Fig 4.5 Switching relay

The string is sent either through voice or a touch command from the app. The same
is done for all other relays.

4.1.2.6 Feedback
Another crucial aspect of home automation is that one should have complete
awareness of whatever appliances are on or off. For this, a piece of code is written which
can provide this feedback to the user.

Fig 4.6 Feedback


20
4.2 Development of Application
The android application for controlling the automation system is at the core of our
project. This app serves as the remote control which the user can use to access the entire
automation system. This app is supposed to get the speech command, process it, and send
it forward to carry out the given task.

Fig 4.7 App interface

4.2.1 Platform
We used MIT app inventor for this task. This site has frameworks that have already
been optimized to build an effective app. Instead of having to re-invent the wheel, one can
access components and utilize them together as per required.

4.2.2 Developing blocks for app

Fig 4.8 List picker

This figure represents label which we can modify to fit our needs. This block is a
list picker. What it means is that this is a type of button which when clicked, will drop
down a list of our desired category. In our case, it will be the available Wi-Fi Devices of
the Smartphone in which the app is running.

21
Fig 4.9 Connection status

Now, in the figure, the highlighted pat shows that in Label 2 changes its color from
red to green of the text in Label 2. And now the Label Shows Connected instead of not
Connected. Now the User knows that the connection is established successfully.

4.2.3 Connecting with Wi-Fi


Now, we need to interface our app with the Wi-Fi. What the user sees is the Labels
in which the text is Light, Fan, TV, and Door. Exactly in front of these are 2 buttons for
each label, or each device for the user to switch them on and off. These can be modified.
Each button is coded in a way that it will forward a string to the Arduino when pressed.

4.2.4 Voice Recognition


In the Fig.4.5, The Voice Control button is visible. When the User clicks this app,
the Speech Recognizer module powered by Google Inc. turns on and using the microphone
of the Smart Phone, it recognizes the speech of the user. As it is a module powered by one
of the tech savvies of the world, it is very accurate and precise in nature.

Fig 4.10 Voice Recognition block


22
The Speech Recognizer gets the text when the Button 12 labeled as VOICE
CONTROL in the user interface is pressed. Now what happens to the text is that it is shown
on the app just below the button (VOICE CONTROL) as a result what the user has spoken.
It acts as a feedback system for the user to ensure whether he has spoken the rights words
or not.

The speech is then converted into text and as Strings to be sent to the client who is
again the Bluetooth/Wi-Fi Client that we had picked from the List Picker. As soon as these
strings reach the Arduino, the code of the Arduino acts accordingly, and the digital pins
are set High and Low and accordingly the subsequent relays are controlled. The problem
with the speech recognizer is that when the user speaks 'one' it will never be converted to
text as '1'. It will always be considered as 'one'.

4.3 Flow Diagram


Following is a Flow diagram which illustrates the basic working of the project.

Fig 4.11 Flow Diagram

4.4 Final Project

23
Chapter 5

RESULT AND CONCLUSION


5.1 Working Application
In conclusion, we have managed to make an app that can be downloaded when the
link is provided. Once installed, this application can successfully be run on any android
device. The user-interface is basic and easy to get comfortable with. This app can interface
through Wi-Fi with our home automation system.

5.2 Control Box


The control box works perfectly. The video for the working is pending and will be
updated once we can access the prototype. (The prototype is installed at the house in
Islamabad, and due to one of the housemates being affected with covid-19, we were unable
to retrieve it). The Control box pairs with the application and turns appliances on or off as
per our requirements.

5.3 Deliverables
This section contains the Achieved and Un-achieved deliverables that were taken
upon at the start of the project. All simulations and prototyping were conducted as
per the timeline of the project.
5.3.1 Achieved Deliverables
We have achieved the following:

a. We have successfully built a functioning control box that can switch appliances ON
and OFF.
b. We have interacted with this control box using an android application
c. We have created such an application that can get voice command or touch command
from user and can relay this information to be processed by the Arduino. The Speech
recognition is done within the application

5.3.2 Un-achieved Deliverables


There have been no unachieved deliverables since all the work has been carried out
practically. The Voice recognition flow works as accurate as Google integration can get.

24
5.4 Differences between Simulation and Practical Results
During testing, no noticeable differences were observed between simulated and
practical results. Surprisingly, it was easier to achieve practical results since the need for
extra simulating software to emulate Wi-Fi port connectivity was eliminated.

The major portion of this project relied on software, and no difference between
simulation and practical application was observed.

25
Chapter 6

BIBLIOGRAPHY

1. http://www.forbes.com/sites/louiscolumbus/2014/11/09/mobile-is-eating-the-
world/
2. http://www.businessinsider.com/smartphone-bigger-than-pc-market-2011-2
3. https://www.ibm.com/blogs/internet-of-things/what-is-the-iot/
4. https://computerhistory.org/blog/the-echo-iv-home-computer-50-years-later/
5. https://www.cleverism.com/company/nest-labs/
6. https://www.mydimmerswitch.com/reviews/leviton-smart-switch/
7. https://www.arduino.cc/en/Main/arduinoBoardUno&gt.
8. https://robu.in/arduino-pin-configuration/
9. https://components101.com/wireless/esp8266-pinout-configuration-features-
datasheet
10. https://www.etechnophiles.com/hc-05-pinout-specifications-datasheet/
11. https://www.componentsinfo.com/2n2222-transistor-pinout-equivalent/

26
APPENDICES
Arduino [8]

Schematic of Arduino Uno

Pin Configuration

Vin: This is the input voltage pin of the Arduino board used to provide input supply from
an external power source.

5V: This pin of the Arduino board is used as a regulated power supply voltage, and it is
used to give supply to the board as well as onboard components.

3.3V: This pin of the board is used to provide a supply of 3.3V which is generated from a
voltage regulator on the board

GND: This pin of the board is used to ground the Arduino board.

27
Reset: This pin of the board is used to reset the microcontroller. It is used to Resets the
microcontroller.

Analog Pins: The pins A0 to A5 are used as an analog input and it is in the range of 0-5V.

Digital Pins: The pins 0 to 13 are used as a digital input or output for the Arduino board.

Serial Pins: These pins are also known as a UART pin. It is used for communication
between the Arduino board and a computer or other devices. The transmitter pin number 1
and receiver pin number 0 are used to transmit and receive the data resp.

External Interrupt Pins: This pin of the Arduino board is used to produce the External
interrupt and it is done by pin numbers 2 and 3.

PWM Pins: These pins of the board are used to convert the digital signal into an analog
by varying the width of the Pulse. The pin numbers 3, 5, 6, 9, 10 and 11 are used as a PWM
pin.

SPI Pins: This is the Serial Peripheral Interface pin; it is used to maintain SPI
communication with the help of the SPI library. SPI pins include:

SS: Pin number 10 is used as a Slave Select

MOSI: Pin number 11 is used as a Master out Slave In

MISO: Pin number 12 is used as a Master in Slave Out

SCK: Pin number 13 is used as a Serial Clock

LED Pin: The board has an inbuilt LED using digital pin-13. The LED glows only when
the digital pin becomes high.

AREF Pin: This is an analog reference pin of the Arduino board. It is used to provide a
reference voltage from an external power supply.

28
Esp8266 Wi-Fi module [9]

Pin Configuration

29
ESP8266-01 Features
a. Low cost, compact and powerful Wi-Fi Module

b. Power Supply: +3.3V only

c. Current Consumption: 100mA

d. I/O Voltage: 3.6V (max)

e. I/O source current: 12mA (max)

f. Built-in low power 32-bit MCU @ 80MHz

g. 512kB Flash Memory

h. Can be used as Station or Access Point or both combined

i. Supports Deep sleep (<10uA)

j. Supports serial communication hence compatible with many developments’


platform like Arduino

k. Can be programmed using Arduino IDE or AT-commands or Lua Script

30
HC – 05 Bluetooth module [10]

Pin Configuration

31
HC-05 Specifications and Features
a. Bluetooth protocol: Bluetooth Specification v2.0+EDR (Enhanced Data Rate)

b. Frequency: 2.4GHz ISM band

c. Modulation: GFSK (Gaussian Frequency Shift Keying)

d. Emission power: ≤4dBm, Class 2

e. Sensitivity: ≤-84dBm at 0.1% BER

f. Speed: Asynchronous communication: 2.1Mbps (Max) / 160 kbps, Synchronous


communication: 1Mbps/1Mbps

g. Security: Authentication and encryption

h. Profiles: Bluetooth serial port

i. Supply Voltage: +3.3V to 6.0 V

j. Supply Current: 30mA

k. Working temperature: -20 ~ +75Centigrade

l. Dimension: 26.9mm x 13mm x 2.2 mm

m. HC-05 Bluetooth module follows the IEEE 802.15.1 standardized protocol, through
which one can build a wireless Personal Area Network (PAN). It uses frequency-
hopping spread spectrum (FHSS) radio technology to send data over the air.

32
2N222 Transistor [11]

Pin Configuration and Symbol

Features / technical specifications


a. Package Type: TO-92

b. Transistor Type: NPN

c. Max Collector Current (IC): 600mA

d. Max Collector-Emitter Voltage (VCE): 40V

e. Max Collector-Base Voltage (VCB): 75V

f. Max Emitter-Base Voltage (VEBO): 6V

g. Max Collector Dissipation (Pc): 625 Mill watt

h. Max Transition Frequency (fT): 300 MHz

i. Minimum & Maximum DC Current Gain (hFE): 35 – 300

j. Max Storage & Operating temperature Should Be: -55 to +150 Centigrade

33
12V Relay module

Schematic

Pin Configuration

34

You might also like