0% found this document useful (0 votes)
17 views40 pages

SP33

For students enquiry

Uploaded by

badeolu63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views40 pages

SP33

For students enquiry

Uploaded by

badeolu63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/309634807

Home Automation System Description

Technical Report · November 2016

CITATIONS READS
0 11,438

1 author:

Amit Sharma
Guru Jambheshwar University of Science & Technology
4 PUBLICATIONS 0 CITATIONS

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Virtual Assistance View project

All content following this page was uploaded by Amit Sharma on 03 November 2016.

The user has requested enhancement of the downloaded file.


ABSTRACT

Home automation involves introducing a degree of computerized or automatic control to certain


electrical and electronic systems in a building. These include lighting, temperature control,
security systems, garage doors, etc. A hardware system is installed to monitor and control the
various appliances. The system would control the appliances based on its configuration. For
example, it could automatically turn on the lights at a specified time in the evening, or it could
measure the ambient light using a hardware sensor and turn on the lights when it grows dark. It
can also allow a person to control appliances from a remote location, such as over the internet.
For example, one could turn on the air conditioning from the office, before leaving for home.

This project demonstrates a simple home automation system that allows the user to control it
with a wireless device such as a Wi-Fi or Bluetooth enabled mobile phone. A desktop PC is used
to run the server software. The system allows the user to control each of the lights and fans
individually. It can automatically turn off the main lights and turn on a night lamp at a specified
time. By measuring the signal strength, it can detect when the user enters a room and
automatically turn on the light and fans, and then automatically turn them off when the user
leaves the room.

1
TABLE OF CONTENTS

ABSTRACT .................................................................................................................................... 1
INTRODUCTION .......................................................................................................................... 5
1.1 OBJECTIVE.......................................................................................................................... 5
1.2 VISUAL STUDIO 2010........................................................................................................ 6
1.3 FEATURES OF VS 2010 ..................................................................................................... 6
1.3.1 Code Editor ..................................................................................................................... 6
1.3.2 Debugger ........................................................................................................................ 7
1.3.3 Designer .......................................................................................................................... 7
1.3.4 Other Tools ..................................................................................................................... 7
1.4 SUPPORTED PRODUCTS .................................................................................................. 7
SYSTEM ANALYSIS .................................................................................................................... 9
2.1 EXISTING SYSTEMS ......................................................................................................... 9
2.2 PROPOSED SYSTEM.......................................................................................................... 9
SYSTEM REQUIREMENTS ....................................................................................................... 10
3.1 SOFTWARE REQUIREMENTS ....................................................................................... 10
3.2 HARDWARE REQUIREMENTS ...................................................................................... 10
3.3 DEVELOPMENT TOOLS ............................................................................................ 10
3.3.1 Microsoft Visual Studio 2010....................................................................................... 10
3.3.2 Arduino IDE For Microcontroller .................................................................................... 10
3.3.3 PIC PGM Programmer1.0.1.4 .......................................................................................... 10
SYSTEM DESIGN SPECIFICATION ........................................................................................ 11
4.1 DESIGN SPECIFICATION ................................................................................................ 11
4.2 DESIGN DIAGRAM .......................................................................................................... 11
IMPLEMENTATION ................................................................................................................... 13
5.1 SERVER MODULE ........................................................................................................... 13
5.1.1 COM-PORT.................................................................................................................. 13

2
5.1.2 AUTOMATIC TIMING CONTROLS ......................................................................... 13
5.2 MICROCONTROLLER AND HARDWARE MODULE ................................................. 14
5.2.1 ARDUINO UNO R3 ATMEGA320P .......................................................................... 14
5.2.2 RELAY BOARD .......................................................................................................... 14
5.3 CLIENT ............................................................................................................................... 15
TESTING ...................................................................................................................................... 16
6.1 SERVER MODULE ........................................................................................................... 16
6.1.1 ACTIVATION OF TIME-BASED PROFILE ............................................................. 16
6.1.2 UPDATING GUI ON RECEIVING COMMANDS .................................................... 16
6.1.3 PORT SELECTION ..................................................................................................... 16
6.2 MICROCONTROLLER AND HARDWARE MODULE ................................................. 17
6.2.1 QUALITY OF MAINS SUPPLY................................................................................. 17
6.2.2 ELECTRICAL GROUNDING PROBLEM ................................................................. 17
6.3 RECOGNIZING VOICE .................................................................................................... 17
CODING ....................................................................................................................................... 18
1. SERVER MODULE .......................................................................................................... 18
2. MICROCONTROLLER AND HARDWARE MODULE ................................................ 34
SCREENSHOTS........................................................................................................................... 35
8.1 Arduino Controller Front .................................................................................................... 35
8.2 IC Diagram .......................................................................................................................... 35
8.3 Hardware Arrangement ....................................................................................................... 36
8.6 Default Commands .............................................................................................................. 37
8.7 Temp and Weather Data ...................................................................................................... 37
CONCLUSION ............................................................................................................................. 38
FUTURE ENHANCEMENTS .................................................................................................. 38
REFERENCES ............................................................................................................................. 39

3
HOME AUTOMATION SYSTEM

4
CHAPTER 1

INTRODUCTION

A typical home automation system allows one to control house hold appliances from a
centralized control unit. These appliances include lights, fans, air conditioners, television sets,
security cameras, electronic doors, computer systems, audio/visual equipment, etc. These
appliances usually have to be specially designed to be compatible with each other and with the
control unit for most commercially available home automation systems. The project
“Implementation of a Low-Cost Home Automation System”, demonstrates a system that can be
integrated into a building’s electrical system and allows one to wirelessly control lights, fans, and
turn on or off any appliance that is plugged into a wall outlet. The system can be controlled from
a Laptop acts as the server. Thus the installation cost and hardware cost is kept to a minimum as
most users already own the requisite hardware such as a mobile phone and desktop PC.
A wire is sed to provide connectivity between the server and the controller. The power supply for
each appliance is wired through an electromechanical relay. A number of relays are used
depending on the number of appliances to be used.
All the relays are controlled by a microcontroller. The microcontroller is connected to the server
via a USB interface. This makes it plug-and-play and compatible with virtually any PC. The
system can be configured with time-based profiles. For example, one could have it automatically
turn on the lights at 6:00 in the evening. At 10:00P.M. it could automatically turn off the main
lights and turn on a night lamp. It could then turn off the night lamp the next morning. The server
can also connect from the internet to receive various data.

1.1 OBJECTIVE

Home automation or smart home is the residential extension of building automation and involves
the control and automation of lighting, heating (such as smart thermostats), ventilation, air
conditioning (HVAC), and security, as well as home appliances such as washer/dryers, ovens or
refrigerators/freezers which means Stimulating smart, understandable and accessible solutions
and services for the personal environment.

This project comprises of two sub-parts. The front end involves designing a C# application to
communicate with microcontroller through USB. The back end involves building a network of
microcontroller based prototypes to emulate devices used at residential locations for the purpose
of home automation such as temperate sensors, motors, lighting control etc. Micro-controllers
communicate with each other via Relay. It also provides a platform for experiments and research.

5
1.2 VISUAL STUDIO 2010

Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is


used to develop computer programs for Microsoft Windows, as well as web sites, web
applications and web services. Visual Studio uses Microsoft software development platforms
such as Windows API, Windows Forms, Windows Presentation Foundation, Store
and Microsoft Silverlight. It can produce both native code and managed code.
Visual Studio includes a code editor supporting IntelliSense (the code completion component)
as well as code refactoring. The integrated debugger works both as a source-level debugger
and a machine-level debugger. Other built-in tools include a forms designer for
building GUI applications, web designer, class designer, and database schema designer. It
accepts plug-ins that enhance the functionality at almost every level—including adding
support for source-control systems (like Subversion) and adding new toolsets like editors and
visual designers for domain-specific languages or toolsets for other aspects of the software
development lifecycle (like the Team Foundation Server client: Team Explorer).
Visual Studio supports different programming languages and allows the code editor and
debugger to support (to varying degrees) nearly any programming language, provided a
language-specific service exists. Built-in languages include C, C++and C++/CLI (via Visual
C++), VB.NET (via Visual Basic .NET), C# (via Visual C#), and F# (as of Visual Studio
2010). Support for other languages such as Python, Ruby, Node.js, and M among others is
available via language services installed separately. It also
supports XML/XSLT, HTML/XHTML, JavaScript and CSS. Java (and J#) was supported in
the past.

1.3 FEATURES OF VS 2010

1.3.1 Code Editor


Like any other IDE, it includes a code editor that supports syntax highlighting and code
completion using IntelliSense for variables, functions, methods, loops and LINQ queries.
IntelliSense is supported for the included languages, as well as for XML and
for Cascading Style Sheets and JavaScript when developing web sites and web
applications. Autocomplete suggestions appear in a modeless list box over the code editor
window, in proximity of the editing cursor. In Visual Studio 2008 onwards, it can be
made temporarily semi-transparent to see the code obstructed by it. The code editor is
used for all supported languages.

6
1.3.2 Debugger
Visual Studio includes a debugger that works both as a source-level debugger and as a
machine-level debugger. It works with both managed code as well as native code and can
be used for debugging applications written in any language supported by Visual Studio.
In addition, it can also attach to running processes and monitor and debug those
processes. If source code for the running process is available, it displays the code as it is
being run. If source code is not available, it can show the disassembly. The Visual Studio
debugger can also create memory dumps as well as load them later for debugging. Multi-
threaded programs are also supported. The debugger can be configured to be launched
when an application running outside the Visual Studio environment crashes.

1.3.3 Designer
Visual Studio includes a host of visual designers to aid in the development of
applications. These tools include:

 Windows Forms Designer


 WPF Designer
 Web designer/development
 Class designer
 Data designer
 Mapping designer

1.3.4 Other Tools

 Open Tabs Browser


 Properties Editor
 Object Browser
 Solution Explorer

1.4 SUPPORTED PRODUCTS

Visual Basic basically supported various products. There are five main products that are
supported by VS-2010.

I. Microsoft Visual C++

II. Microsoft Visual C#

III. Microsoft Visual Basic

7
IV. Microsoft Visual Web Developer

8
CHAPTER 2

SYSTEM ANALYSIS

2.1 EXISTING SYSTEMS

Most commercially available home automation systems are all-in-one solutions which require
that all controllable appliances are from the same company, or must be approved as compatible
with said company’s system. Moreover these systems normally come with a proprietary,
dedicated device which acts as the control center. To control the system from multiple locations,
additional control devices must be purchased. These complex systems usually need to be
integrated when the building is constructed and must be planned in advance. They are also
difficult to upgrade or replace once installed. The overall investment adds up considerably and is
financially infeasible in most cases. These drawbacks hinder the popularity of such systems.

2.2 PROPOSED SYSTEM

The objective of the proposed system is to offer a low-cost solution for a home automation
system that overcomes the above drawbacks. The
system provides basic control of appliances at a fraction of the cost of commerciallyavailable
systems. The concept of a proprietary control device is done away with as the system can be
controlled from a Bluetooth or Wi-Fi enabled mobile device, such as a mobile phone or laptop.
There is no need for a specialized server system as a typical desktop PC can act as the server.
Nowadays most users already own the requisites such as a mobile phone and a desktop PC;
hence the cost of the system is considerably reduced. The system can be easily integrated into an
existing electrical system of a building thanks to its simplified design. It can also be easily
installed for just a single room if one so desires. Modifications to the existing electrical system
are minimal, thereby reducing installations costs.

9
CHAPTER 3

SYSTEM REQUIREMENTS

3.1 SOFTWARE REQUIREMENTS

 Microsoft Windows 2000 SP3 or later.


 Microsoft .NET Framework 4.0 or later.

3.2 HARDWARE REQUIREMENTS

 Laptop running on Windows OS.


 Arduino Uno R3 ATMEGA328O Controller
 Breadboard
 Jumpers
 LED
 Motor(for FAN)

3.3 DEVELOPMENT TOOLS

Two different programming languages are used for the development of different
software components of the HAS (Home Automation System).

3.3.1 Microsoft Visual Studio 2010


The server application for Windows are coded in Microsoft Visual C# and compiled as a
standard Windows executable using CLR (Common Language Runtime) that runs under
the .NET Framework.

3.3.2 Arduino IDE For Microcontroller

The Arduino Integrated Development Environment - or Arduino Software (IDE) -


contains a text editor for writing code, a message area, a text console, a toolbar with
buttons for common functions and a series of menus.

3.3.3 PIC PGM Programmer1.0.1.4

PIC PGM Programmer is the software used to flash the compiled program to the
microcontroller’s EEPROM and verify that it has been successfully written.

10
CHAPTER 4

SYSTEM DESIGN SPECIFICATION

4.1 DESIGN SPECIFICATION

The system is designed keeping in mind the following key requirements:

 Change in the status of an appliance should be propagated to all software comp. in


real-time.
 Customizable time-based profiles to automatically activate and deactivate appliances
based on the time of day
 Hardware should be widely compatible with different Configurations.
 Server should run in the background without disturbing regular activities on the desktop
PC.
 Provide a simple and user-friendly interface on the client side.

4.2 DESIGN DIAGRAM

After initiating the program, user needs to send voice commands to the server. The
microcontroller is connected to the server via USB. On receiving speech commands, server
sends commands to the microcontroller over the USB connection. The microcontroller is
directly connected to the relays and it can enable or disable them. The relays are connected
to the electrical system of the building so that they can control the plug points.

11
START

USER VOICE

INPUT

SERVER

USB-to-SERIAL
BRIDGE

CONTROLLER

RELAY- SYSTEM

Electrical Appliances

12
Figure 4.1 Data Flow Diagram

CAHPTER 5

IMPLEMENTATION

The system is comprised of three different modules, which are described below:

 Server for Windows.


 Embedded program for microcontroller and hardware circuit.
 Client (Win laptop).

5.1 SERVER MODULE

The server module is executed on a desktop PC running Windows. It sends commands to the
microcontroller to control the relays, and accepts commands from clients connected to it.

The manual control on the bottom-right can be used to directly control the relays from the server
side without using a client. There are few checkboxes which are checked and unchecked on the
bases of the hardware status. If checkbox is checked i.e. the appliance is turned on, otherwise it
is turned off.

5.1.1 COM-PORT
The USB-to-Serial Bridge presents itself as a virtual COM port to the server. The port
number that corresponds to the USB-to-Serial Bridge is chosen so that the server
can communicate with the microcontroller.

5.1.2 AUTOMATIC TIMING CONTROLS


The server can be configured to automatically turn on or off particular appliances at
specific times. Up to 14 different configurations for different timings can be set. There is
also a system, which gets the temperature data and from the internet and sends that data
to controller for processing purpose. What the processing being done there is, if
controller find the current temperature below a certain level of it immediately sends
control signals to door-controller unit to close it.

For Example, at 6:00 PM, Relay 1 (Light 1) and Relay2 (Light 2) will be switched on and
Relay 3 (Night Lamp) will be switched off. The remaining relays will be left unchanged
at whatever state they previously were.

13
5.2 MICROCONTROLLER AND HARDWARE MODULE

5.2.1 ARDUINO UNO R3 ATMEGA320P


The microcontroller used is a ATMEGA320P manufactured by Italian Company Smart
Projects. It communicates with the server using Serial communication via a USB-to-
Serial Bridge. It has multiple outputs which are used to control the relays. The
microcontroller is programmed such that if it receives a lower case ‘a-h’ it turns off the
corresponding relay and if it receives an upper case ‘A-H’ it turns on the corresponding
relay. If it receives any other input it responds with an error saying the input was
unrecognized.

Microcontroller are powered with +5V through the USB connection to the laptop.

5.2.2 RELAY BOARD


The relay board is connected to one of the output ports on the microcontroller. The relay
board requires +12V for operation and
is powered by a transformer. If the mains supply delivers low voltage then thetransformer
voltage may drop below +12V and the relays may not function efficiently. To overcome
this, a higher voltage transformer is used and a 7812voltage regulator is used to deliver a
steady +12V to the relay board.

The output port on the microcontroller is 8 bits wide. When logical one (+5V) is output
on one of the bits, the corresponding relay is activated. The live terminal input of each
appliance is wired across the Common and Normally Open terminals of the relays, thus
the power to the appliance is switched on or off depending on whether the relay is active
or not. For the purpose of demonstrating a working model, three 220V outlets have been
attached the relay board. The maximum load switching capacity of each of the relays is
given below:

7 amperes @ 125 volts AC


7 amperes @ 12 volts DC
5 amperes @ 240 volts AC
5 amperes @ 28 volts DC

14
5.3 CLIENT

Basically a client is nothing but a human component which will give command to the server via
speech signal, this form is also known as speech recognition. After recognizing the speech signal
it first will convert it in the form of string. Since strings are easy to manipulate. it will then go to
its command dir. Where all the possible commands are stored by the admin It start reading each
command linearly until it finds the exact same match of the command which is spoked. If it finds
the match then it checks the cross ponding response and executes the same one. If it does not
find any command which is spoked, it will give no response.

So here the main role of the client is to confer the required commands to the server. It should be
in the form of speech signal, means one must have to pronunciate the commands which are
defined in the default commands dir. If, somehow client’s speech couldn’t be recognized the
software has an alternative. It has two different control modes to control the relay. One is
through voice and another is manually. It has three checkbox namely ‘Light on/off’, ‘Fan on/off’,
‘Door open/close’. So software has the option to switch the client to manual control if voice is
not recognized.

15
CHAPTER 6

TESTING

Each of the modules was tested using both black box and white box testing techniques. Black
box testing ensures the correctness of the system’s output, given various possible inputs. White
box testing involves providing calculated inputs so that the internal structure of the system can
be verified to be error free. For example, white box testing of a software module
involves providing different inputs that test all possible code paths within the program. The
modules were designed keeping in mind all possible inputs and any erroneous inputs as well.
Any exceptions that occur are handled appropriately without compromising the stability of the
system. Different issues, both foreseen and unforeseen, were encountered during the design
process. These issues and the measures that were adopted to overcome them are described in this
chapter.

6.1 SERVER MODULE

6.1.1 ACTIVATION OF TIME-BASED PROFILE


The system checks whether it’s time to activate a profile by comparing the current time
with the profile’s activation time. However there is a possibility that the comparison is
incorrect when the current time wraps around to 00:00:00 for the next day/month/year.
The calculation is modified to account for such situations.

6.1.2 UPDATING GUI ON RECEIVING COMMANDS


When a command to activate or deactivate a relay is received, the corresponding push
button needs to be changed. However since the .NET form engine runs in a separate
thread, it is unsafe to modify the buttons directly from the network thread. To overcome
this, a delegate function had to be implemented to update the buttons from within the
context of the form’s thread.

6.1.3 PORT SELECTION


It’s possible that a COM port that was previously used for communication with the
microcontroller which was saved in the configuration file no longer exists the next time
the application is started. This may occur if the microcontroller is plugged into a different
USB port from last time, in which case Windows will assign it to a different virtual COM
port. To prevent an error the COM ports are enumerated and the last used port is
activated only of it still exists in the current enumeration.

16
6.2 MICROCONTROLLER AND HARDWARE MODULE

6.2.1 QUALITY OF MAINS SUPPLY


The electromagnetic relays require a stable +12V DC supply in order to function reliably.
Initially a transformer with a rectifier was used to provide a +12V DC supply from the
mains.

6.2.2 ELECTRICAL GROUNDING PROBLEM


During tests it was found that the USB specification required that the ground wire join
exactly two end points. In this case only the two data connectors were joined to the
ground wire and the ground wire on the power connector was not connected to the PC’s
ground.

The Power plug was changed to a three pin top and a direct connection to the wall
outlet’s ground pin was provided to absorb the stray currents.

6.3 RECOGNIZING VOICE

It was observed that the voice signals speak by the end user was not accurately recognized by
the server. It was found that 60% signals were observed accurately and 40% were not. The
enhancement in the system was bringing in the form of training the speech API. There was
also an option to use the GOOGLE VOICE API which will work fine, but this system uses MS
Speech API.

17
CHAPTER 7

CODING

1. SERVER MODULE

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.AudioFormat;
using System.Speech.Synthesis;
using System.Speech.Recognition;
using System.Globalization;
using System.Threading;
using System.Diagnostics;
using System.Xml;
using System.IO;
using System.Net.NetworkInformation;
using System.IO.Ports;

namespace Test1ProInit
{
public partial class Form1 : Form
{
//DO I LIKE _something_??? iTS A LITTLE BIT BUGGY...WORKING ON THAT
//ADD 'SEARCH FOR' FUNCTIONALITY??? CAN'T BE ADDED
'SEARCH FOR' FUNCTIONALITY. WAIT FOR THE NEXT VERSION :-)

frm_Default_Commands s = new frm_Default_Commands();

SpeechSynthesizer _synthesizer = new SpeechSynthesizer();


SpeechRecognitionEngine recogEngine = new SpeechRecognitionEngine();
SpeechRecognizer _recognizer = new SpeechRecognizer();
PromptBuilder pBuilder = new PromptBuilder();

18
Choices commands = new Choices();
Choices commomEng = new Choices();
Grammar _grammar;
SerialPort port = new SerialPort("COM4",9600, Parity.None, 8, StopBits.One);

private Boolean _hasShown;


private Boolean _isConnected;
private Boolean _wake = true;
private Boolean _isLightOn = false;
private Boolean _isFanOn = false;
private Boolean _isDoorOpen = false;
private Boolean _isManualControlEnabled = false;
private Boolean _isLight;
private Boolean _isFan;
private Boolean _isDoor;
private Boolean _isLightStatus;
private Boolean _isFanStatus;
private Boolean _isDoorStatus;
private Boolean _hasCommandRecognized = false;

private int _commandNOTRecognizedCounter = 0;

private String temp; //CAN TELL THE ARDUINO TO CLOSE THE


DOOR IF TEMP IS BELOW A CERTAIN TEMP OR IF ITS NIGHT
private String condition;

public static string MasterName = "mike";


public static string AIName = "david";
private static string LIGHT = "LIGHT";
private static string FAN = "FAN";
private static string DOOR = "DOOR";
private static string ON = "ON";
private static string OFF = "OFF";
private static string OPEN = "OPEN";
private static string CLOSE = "CLOSE";
private static string ENABLE = "ENABLE";
private static string DISABLE = "DISABLE";
private static string DOOR_Status = DOOR + " Status";
private static string FAN_Status = FAN + " Status";
private static string LIGHT_Status = LIGHT + " Status";
private string[] greetingAutoResponses = { "Yes Sir?", "How can i Help you?", "What's up
sir?", "hello sir, how are you?" };
private string[] thankYouResponses = { "No problem sir", "It is my pleasure sir" };
private string[] DemandAutoResponses = { "Yes Sir", "OK", "No problem" };

19
//FORM1 CONSTRUCTOR
public Form1()
{
_hasShown = false;
_isConnected = NetworkInterface.GetIsNetworkAvailable();

// _synthesizer.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Adult);

commands.Add(File.ReadAllLines(@"C:\Users\Amit Attri\Documents\Visual Studio


2010\Projects\Test1ProInit\Test1ProInit\grammar\commands.txt"));

_grammar = new Grammar(new GrammarBuilder(commands));

try
{
recogEngine.RequestRecognizerUpdate();
recogEngine.LoadGrammar(_grammar);
recogEngine.SpeechRecognized += rec_SpeachRecognized;
recogEngine.SetInputToDefaultAudioDevice();
recogEngine.RecognizeAsync(RecognizeMode.Multiple);
}
catch (Exception _e)
{
_synthesizer.SpeakAsync("Sir, I'm facing some trouble while initating Speech Engine.
"
+ "Error Code: ERR\\CONSTR\\T-C\\12" +
" Problem is as fallows. :- " + _e.Message);
}

//INIT DEFAULT COMPONENTS


InitializeComponent();
}

//SPEECH RECOGNIZED EVT


private void rec_SpeachRecognized(object sender, SpeechRecognizedEventArgs e)
{
string _speechRecognizedEvt = e.Result.Text;

//PLEASE RUN THIS


INSTR IF WE ARE IN SLEEP STATE
//WORD RECOG CONFDNC LVL
float _confidance_level = 0;
_confidance_level = e.Result.Confidence * 100;

20
//LOAD WHAT U SAY TO RSPONS AREA
txtAreaResponse.AppendText("YOU: " + e.Result.Text + " with " + _confidance_level +
"% Confidance" + "\n\n");

if (_speechRecognizedEvt == "wake" || _speechRecognizedEvt == "awake" ||


_speechRecognizedEvt == "wakeup" + AIName || _speechRecognizedEvt == "wakeup")
{
if (_wake)
say(greeting_response_action());
else
{
_wake = true;
say(greeting_response_action());
}
}

if (_speechRecognizedEvt.Contains("shut up"))
{
_wake = false;
txtAreaResponse.AppendText(AIName.ToUpper() + ": speech recognition " +
DISABLE + "D\n\n");
}

//CONDITION STATRTS FROM HERE


if (_wake)
{

if (_speechRecognizedEvt.Contains("default commands"))
{
_hasCommandRecognized = true;
_hasShown = true;
if (_hasShown == true) //OPEN NEW FORM BORDER RESPONSE
{
s.Show();
_hasShown = false;

say(demand_response_action());
}
if ((s.Focused) && (_hasShown == false))
{
say("Form is already shown.");
}
}

21
if (_speechRecognizedEvt == "close window")
{
_hasCommandRecognized = true;

s.Close();
say(demand_response_action());
}

if (_speechRecognizedEvt.Contains(AIName))
{
_hasCommandRecognized = true;

this.TopMost = true;
this.Focus();
this.BringToFront();
say("Yes!");
}

if (_speechRecognizedEvt == "create a file") //TAKE


COMMANDS SEPARATELY. BUT IN THE NEXT VRSN IT'LL TAKE THE WHOLE
CAMMAND TO EXECUTE
{
_hasCommandRecognized = true;

say("your file has been created successfully."); //PLEASE


CONSIDER IT 'IMP'
}

if (_speechRecognizedEvt == "create a note")


{
_hasCommandRecognized = true;

say("your note has been create successfully.");


}

if (_speechRecognizedEvt == "create an event")


{
_hasCommandRecognized = true;

say("your event has been created.");


}

if (_speechRecognizedEvt == "set a reminder")


{
_hasCommandRecognized = true;

22
say("reminder has been set.");
}

if(_speechRecognizedEvt == "set an alarm")


{
_hasCommandRecognized = true;

say("alarm has been set.");


}

if (_speechRecognizedEvt == "schedule an appointment")


{
_hasCommandRecognized = true;

say("appointment has been set.");


}

if (_speechRecognizedEvt == "schedule a meeting")


{
_hasCommandRecognized = true;

say("schedule has been set.");


}

if (_speechRecognizedEvt.Contains("say hello")) //ITS JUST A TEST


COMMAND (TO TEST WETHER THE RECOGNITION ENGINE HAS ENABLED OR NOT)
{
_hasCommandRecognized = true; //YOU CAN DISREGARD
OR REMOVE THIS COMMAND IF FEEL UNNECESSARY
say(greeting_response_action());
}

if (_speechRecognizedEvt.Contains("what is your name"))


{
_hasCommandRecognized = true;
say("my name is " + AIName.ToUpper());
}

if (_speechRecognizedEvt.Contains("open chrome"))
{
_hasCommandRecognized = true;
Process.Start("http://www.google.in");
say(demand_response_action());
}

23
if (_speechRecognizedEvt.Contains("restart"))
{
_hasCommandRecognized = true;
restart();
say(demand_response_action());
}

if (_speechRecognizedEvt.Contains("initate shutdown sequence"))


{
//say(demand_response_action()); //ASK FOR
CONFIRMATION(Eg: 'ARE U SAYING GOOD BYE TO ME, SIR??')

PromptBuilder _pBuilder = new PromptBuilder();


_pBuilder.StartSentence(); //TEMP CODE :(
_pBuilder.AppendText("initiating shutdown sequence");
_pBuilder.EndSentence();

_pBuilder.AppendBreak(new TimeSpan(0,0,3));

_pBuilder.StartSentence();
_pBuilder.AppendText("shutdown sequence completed, good bye "+MasterName);
//GET THE CURRENT TIME(AM OR PM) AND WISH ME ACCORDINGLY(Eg: HAVE A
GOOD NIGHT, SIR)
_pBuilder.EndSentence();

_synthesizer.SpeakAsync(_pBuilder);

this.Close();
}

if (_speechRecognizedEvt == ("open chrome"))


{
_hasCommandRecognized = true;
Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe");
say("opening chrome!");
}

if (_speechRecognizedEvt == ("close chrome"))


{
_hasCommandRecognized = true;
killProg("chrome.exe");
say(demand_response_action());
}

24
if (_speechRecognizedEvt == ("whats the weather like"))
{
_hasCommandRecognized = true;

if (_isConnected)
{
say("The sky is " + GetWeather("cond") + ".");
}
else say("I'm not connected with the server! Please connect it to get the weather
data.");
}

if (_speechRecognizedEvt == ("whats the temprature"))


{
_hasCommandRecognized = true;

if (_isConnected)
{
int _inCelsius = 0;
int.TryParse(GetWeather("temp"), out _inCelsius);
_inCelsius = (_inCelsius - 32) * 5 / 9;
say("It is " + _inCelsius + " degrees Celsius.");
}
else say("I'm not connected with the server! Please connect to get the tempreature
data."); //CURRENTLY GETTING TEMP DATA FROM SERVER
} //SWITCH IT TO
SENSORS AFTER INSTALLATION

if (_speechRecognizedEvt == ("minimize"))
{
_hasCommandRecognized = true;
this.WindowState = FormWindowState.Minimized;
say("ok"); //LOW RESPONSE CMD
//LOW, MEDIUM AND HIGH LEVEL CMDS CAN BE GENERATED FOR:
} //RESPONSES LIKE
(GREETING, DEMAND AND THANK YOU)

if (_speechRecognizedEvt == ("maximize"))
{
_hasCommandRecognized = true;
this.WindowState = FormWindowState.Normal;
this.Focus();
say("alright"); //LOW RESPONSE CMD
}

25
if (_speechRecognizedEvt.Contains(LIGHT.ToLower() + " " + ON.ToLower()) ||
_speechRecognizedEvt.Contains("turn " + ON.ToLower() + " the " + LIGHT.ToLower()))
{
//THIS IS A TEST, ACTUALLY WE HAVE TO SAND A CHAR CODE TO
CONTROLLER
_isLight = true;
_hasCommandRecognized = true;

if (_isLightOn)
{
say(LIGHT + " is already turned " + ON);
}
else if (!_isLightOn)
{
_isLightOn = true;

try
{
port.Open();
port.WriteLine("A");
port.Close();
}catch(IOException)
{
say("IO Exception ");
}

say(demand_response_action());
lblHALightStatus.Text = ON;
chkBoxLight.Text = LIGHT + " " + OFF;
btnTurnOnOff.Text = "TURN " + OFF;
say(LIGHT + " turned " + ON);
}
else { say(hardwreNotFunc()+"214\\"+LIGHT+"-"+ON+"\\232"); _isLight = false; }
}

if (_speechRecognizedEvt.Contains(LIGHT.ToLower() + " " + OFF.ToLower()) ||


_speechRecognizedEvt.Contains("turn " + OFF.ToLower() + " the " + LIGHT.ToLower()))
{
_isLight = true;
_hasCommandRecognized = true;

if (!_isLightOn)
{
say(LIGHT + " is already turned " + OFF);
}

26
else if (_isLightOn)
{
_isLightOn = false;

try
{
port.Open();
port.WriteLine("B");
port.Close();
}
catch (IOException)
{
say("IO Exception ");
}

lblHALightStatus.Text = OFF;
chkBoxLight.Text = LIGHT + " " + ON;
btnTurnOnOff.Text = "TURN " + ON;
say(LIGHT + " turned " + OFF);
}
else { say(hardwreNotFunc()+"235\\"+LIGHT+"-"+OFF+"\\253"); _isLight = false;
}
}

if (_speechRecognizedEvt.Contains(FAN.ToLower() + " " + ON.ToLower()) ||


_speechRecognizedEvt.Contains("turn " + ON.ToLower() + " the " + FAN.ToLower()))
{
_isFan = true;
_hasCommandRecognized = true;

if (_isFanOn)
{
say(FAN + " is already turned " + ON); //SHOW THE
TIME WHEN FAN IS TURNED ON
}
else if (!_isFanOn)
{
_isFanOn = true;

try
{
port.Open();
port.WriteLine("C");
port.Close();
}
catch (IOException)

27
{
say("IO Exception ");
}

lblHAFanStatus.Text = ON;
chkBoxFan.Text = FAN + " " + OFF;
btnTurnOnOff.Text = "TURN " + OFF;
say("ok");
}
else { say(hardwreNotFunc()+"256\\"+FAN+"-"+ON+"\\273"); _isFan = false; }
}

if (_speechRecognizedEvt.Contains(FAN.ToLower() + " " + OFF.ToLower()) ||


_speechRecognizedEvt.Contains("turn " + OFF.ToLower() + " the " + FAN.ToLower()))
{
_isFan = true;
_hasCommandRecognized = true;

if (!_isFanOn)
{
say(FAN + " is already turned " + OFF);
}

else if (_isFanOn)
{
_isFanOn = false;

try
{
port.Open();
port.WriteLine("D");
port.Close();
}
catch (IOException)
{
say("IO Exception ");
}

lblHAFanStatus.Text = OFF;
chkBoxFan.Text = FAN + " " + ON;
btnTurnOnOff.Text = "TURN " + ON;
say(FAN + " turned " + OFF);
}
else { say(hardwreNotFunc()+"276\\"+FAN+"-"+OFF+"\\294"); _isFan = false; }
}

28
if (_speechRecognizedEvt.Contains(OPEN.ToLower() + " the " + DOOR.ToLower()))
{
_isDoorStatus = true;
_hasCommandRecognized = true;
if (_isDoorOpen)
{
say(DOOR + " is already " + OPEN + "ED");
}
else if (!_isDoorOpen)
{
_isDoorOpen = true;

try
{
port.Open();
port.WriteLine("E");
port.Close();
}
catch (IOException)
{
say("IO Exception ");
}

lblHADoorStatus.Text = OPEN;
chkBoxDoor.Text = CLOSE + " " + DOOR;
btnTurnOnOff.Text = CLOSE + " " + DOOR;
lblDoorStatus.Text = DOOR + " IS " + OPEN + "ED";
say(DOOR + " is " + OPEN + "ED");
}
else { say(hardwreNotFunc()+"297\\"+DOOR+"-"+OPEN+"\\314"); _isDoorStatus
= false; }
}

if (_speechRecognizedEvt.Contains(CLOSE.ToLower() + " the " +


DOOR.ToLower()))
{
_isDoorStatus = true;
_hasCommandRecognized = true;

if (!_isDoorOpen)
{
say(DOOR + " is already " + CLOSE + "D");
}
else if (_isDoorOpen)
{
_isDoorOpen = false;

29
try
{
port.Open();
port.WriteLine("F");
port.Close();
}
catch (IOException)
{
say("IO Exception ");
}

lblHADoorStatus.Text = CLOSE + "D";


//CREATE A FUNC TO REDUCE THE REDUDENCY
chkBoxDoor.Text = OPEN + " " + DOOR;
btnTurnOnOff.Text = OPEN + " " + DOOR;
lblDoorStatus.Text = DOOR + " IS " + CLOSE + "D";
say(DOOR + " is " + CLOSE + "D");
}
else { say(hardwreNotFunc()+"317\\"+DOOR+"-"+CLOSE+"\\335"); _isDoorStatus
= false; }
}

if (_speechRecognizedEvt.Contains("whats the status of the " + LIGHT.ToLower()))


{
_isLightStatus = true;
_hasCommandRecognized = true;

if (_isLightOn)
{
say(LIGHT + " is turned " + ON);
}
else if (!_isLightOn)
{
say(LIGHT + " is turned " + OFF);
}
else { say(hardwreNotFunc()+"338\\"+LIGHT_Status); _isLightStatus = false; }
}

if (_speechRecognizedEvt.Contains("whats the status of the " + FAN.ToLower()))


{
_isFanStatus = true;
_hasCommandRecognized = true;

if (_isFanOn)
{

30
say(FAN + " is turned " + ON);
}
else if (!_isFanOn)
{
say(FAN + " is turned " + OFF);
}
else { say(hardwreNotFunc()+"354\\"+FAN_Status); _isFanStatus = false; }
}

if (_speechRecognizedEvt.Contains("whats the status of the " + DOOR.ToLower()))


{
_isDoorStatus = true;
_hasCommandRecognized = true;

if (_isDoorOpen)
{
say(DOOR + " is " + OPEN + "D");
}
else if (!_isDoorOpen)
{
say(DOOR + " is " + CLOSE + "D");
}
else { say(hardwreNotFunc()+"370\\"+DOOR_Status); _isDoorStatus = false; }
}

if (_speechRecognizedEvt.Contains("enable manual control") ||


_speechRecognizedEvt.Contains("switch me to the manual control"))
{
_hasCommandRecognized = true;

if (_isManualControlEnabled)
{
say("manual control is already " + ENABLE + "D");
}
else if (!_isManualControlEnabled)
{
_isManualControlEnabled = true;
manualControlArea.Show();
say("manual control " + ENABLE + "D");
}
else say("could not " + ENABLE + " the manual control. Please review settings. "
+"\nError code: ERR\\FUN-386\\MC-EN");

31
if (_speechRecognizedEvt.Contains(DISABLE.ToLower() + " manual control") ||
_speechRecognizedEvt.Contains("switch me to the automatic control"))
{
_hasCommandRecognized = true;

if (!_isManualControlEnabled)
{
say("manual control is already " + DISABLE + "D");
}
else if (_isManualControlEnabled)
{
_isManualControlEnabled = false;
manualControlArea.Hide();
say("manual control " + DISABLE + "D");
}
else say("could not " + DISABLE + " the manual control. Please review settings. "
+"\nError code: ERR\\FUN-404\\MC-DS");
}

//THIS COMMAND IS NOT FUNCTIONING


if (_speechRecognizedEvt != _grammar.RuleName)
{
_hasCommandRecognized = false;
_commandNOTRecognizedCounter++;

if (_hasCommandRecognized)
say("I think you are not " + MasterName.ToUpper() + " ain't you?,, Any way,
Would u like to check my default commands?");
{
if (_speechRecognizedEvt == "yes")
{
//DO SOMETHING FOR THE INSTR
}
}
}
}
}

32
33
2. MICROCONTROLLER AND HARDWARE MODULE

void setup()

Serial.begin(9600);

pinMode(13, OUTPUT);

void loop()

char id = Serial.read();

if(id == 'A')

digitalWrite(13, HIGH);

if (id == 'B')

digitalWrite (13, LOW);

34
CHAPTER 8

SCREENSHOTS

8.1 Arduino Controller Front

8.2 IC Diagram

35
8.3 Hardware Arrangement

8.4 Hardware Arrangement Diagram

8.5 Application Home

36
8.6 Default Commands

8.7 Temp and Weather Data

37
CONCLUSION

The home automation system has been experimentally proven to work satisfactorily by
connecting sample appliances to it and the appliances were successfully controlled from
speech recognition.

Thus a low-cost home automation system was successfully designed, implemented and tested.

FUTURE ENHANCEMENTS

A useful feature would be to add a wireless system which can send the encrypted char code to
controller, hence enhance the security of the system. More advanced features will be installed or
implemented through which user will be able to control the appliance effectively such as
temperature, control, fan speed, etc. I’ll also put my efforts to make this program more human
oriented, means not only it’ll be able to control the appliances effectively but also will be able to
response the user based on their inputs. It will be connected to the internet and will be able to
take queries from the user, search them over the internet, find the precise answer and return that
to the user again. After all, it’ll work like an assistance not real world but virtual world.

38
REFERENCES

[1] .NET Framework Developer Center


http://msdn.microsoft.com/en-us/netframework/default.aspx

[2] .NET Framework

https://en.wikipedia.org/wiki/.NET_Framework

[3] YouTube (Various Channels)

[4] Home Automation System CIS 542 Embedded Systems Programming


(Azriel, Sanket, Zoher, Vignesh)

[5] HAS Research papers

http://research.ijcaonline.org/volume116/number11/pxc3902601.pdf

[6] Arduino Microcontroller

https://en.wikipedia.org/wiki/Arduino
https://www.arduino.cc/

[7]Arduino Programming

https://www.youtube.com/watch?v=09zfRaLEasY

39

View publication stats

You might also like