Sunteți pe pagina 1din 48

F

Y
P
2
Based Home Automation
0
1
6
DEPARTMENT OF APPLIED PHYSICS UNIVERSITY OF KARACHI

Internet Of Things (IOT)


Based Home Automation
Wireless Control

Syed Ahmed Ali –B1037033


Syed Umar Junaid Ahmed –B1037034

Submitted to

Sir Abid Hussain

This is the report about the project which is aimed about controlling the A.C loads sensors
using the public network that is the internet, data transmission to public network is another main
task of this project.
Internet Of Things (IOT) Based Home/Industrial Automation

Acknowledgements
In the name of ALLAH the most gracious and the most merciful, who has
bestowed us an opportunity to do this project.

We would like to thank ALMIGHTY ALLAH for his countless blessings


upon us. Our earnest gratitude goes to Prof. ABID HUSSAIN under whose
supervision we managed to complete this project. This was a great
chance for learning and professional development. We have taken efforts
in this project.
Internet Of Things (IOT) Based Home/Industrial Automation

Abstract
This report documents the development of a range of systems that enable
home automation systems to be integrated and exposed to the Web.
Requirements for the systems are elicited. Various implementation
strategies are considered. The terminology pertaining to the strategies is
explored and explained. The strategies are compared, and an informed
choice between them is made. Two home automation simulation systems
is developed. They are exposed and integrated
using the chosen implementation strategy and developed according to the elicit
ed requirements.
Internet Of Things (IOT) Based Home/Industrial Automation

S.# Topic Page.#


1 Introduction 1

2 Introduction to 2
Raspberry pi
3 Hardware Structure 3-8

4 Circuit Working And Design 9

5 Over-view about ESP8266 , windows 10 IOT Core 10-12


6 Algorithm Flowchart 13

7 GUI Designing 14-15

8 Interfacing of the GPIO with the GUI 16

9 Programming Hardware Which is Handling 19-24


User Request
10 Wifi Connectivity with Network 25

11 Enclosure box 26

12 Software Codes 27

13 Application 33

14 Usefulness 34

15 Associated Problems 35-38

17 Improvements For Future 39

18 Conclusion 40
19 Appendix 41-43
Internet Of Things (IOT) Based Home/Industrial Automation

Introduction
This is the project which will provide user with the control of AC
Appliances, monitor sensors data and provide visual feedback of the
environment remotely.

This project is about controlling the different AC appliances, monitor


sensors data using internet connection. Idea of controlling the
appliances using the internet connection gives this project the ability to
be controlled world widely.

The aim of the project is to work in the area which is not feasible for the
human observer and also designed for the users who wants to remotely
monitor his premises.

This project involves the knowledge of the


following.

 Programming
 Web designing
 Networking

Operating System used in this project:

 Win10 (IOT Core), Win.7.

1
Internet Of Things (IOT) Based Home/Industrial Automation

Introduction to Raspberry Pi
The Raspberry Pi is a series of credit card-sized single-board computers
developed in the United Kingdom by the Raspberry Pi Foundation to promote
the teaching of basic computer science.
The Raspberry Pi hardware has evolved through several versions that feature
variations in memory capacity and peripheral-device support.

Different Raspberry Pi models

Board CPU RAM GPU Ethernet USB Bluetooth Wi-Fi


Name GHz MHZ Ports

Raspberry 0.7x1 256 250 Yes 2 No No


Pi 1 MB

Raspberry 0.9x4 1 GB 300 Yes 4 No No


Pi 2

Raspberry 1.2x4 1 GB 300 Yes 4 Yes Yes


Pi 3

Raspberry 1X1 512 300 Yes 2 No No


Pi zero MB micro

All models feature a Broadcom system on a chip (SoC), which includes an


ARM compatible central processing unit (CPU) and an on chip graphics
processing unit (GPU, a Video Core IV). CPU speed ranges from 700 MHz
to 1.2 GHz for Pi 3 and on board memory range from 256 MB to 1 GB RAM.
Secure Digital (SD) cards are used to store the operating system and
program memory in either the SDHC or Micro SDHC sizes. Most boards
have between one and four USB slots, HDMI and composite video output,
and a 3.5 mm phone jack for audio. Lower level output is provided by a
number of GPIO pins which support common protocols like I²C. The B-
models have an 8P8C Ethernet port and the Pi 3 has on board Wi-Fi
802.11n and Bluetooth.
2
Internet Of Things (IOT) Based Home/Industrial Automation

The Foundation provides Raspbian, a Debian-based Linux distribution for


download, as well as third party Ubuntu, Windows 10 IOT Core, RISC OS,
and specialized media center distributions. It promotes Python and Scratch
as the main programming language, with support for many other languages.

Hardware Structure:

Schematic

3
Internet Of Things (IOT) Based Home/Industrial Automation

PCB layout

4
Internet Of Things (IOT) Based Home/Industrial Automation

This part of the project will mainly be containing of the pictures of the
project.

Following is the front panel view of complete device.

5
Internet Of Things (IOT) Based Home/Industrial Automation

This is the back View of the Pcb.

6
Internet Of Things (IOT) Based Home/Industrial Automation

This is the view of physical circuit components

7
Internet Of Things (IOT) Based Home/Industrial Automation

This is the picture of the circuit in operating mode.

8
Internet Of Things (IOT) Based Home/Industrial Automation

Circuit Working and Design:


A home automation system is a means that allow users to control electric appliances
and set up. The main components are:

Home automation is also known as " domotics". A c o n t r a c t i o n o f t h e w o r d s


“domestic robotics”. When home automation principles are applied to buildings not
falling in the “home” category, building automation system is a commonly used term.

 The most common usage scenario of a home automation system is lighting control,
which is fairly easy to both explain controller, or central control unit,
 An actuator, and
 A lamp.

The actuator in this case is a device that controls the flow of current from a wall
socket to the lamp in question. It does so by being plugged into both the wall socket, and
the lamp. The control unit communicates with the actuator to tell how much current to
let through to the lamp. The control unit may be operated through a Web
site, a remote control, or something similar.The setup is illustrated b e l o w i n f i g u r e .
The wireless communication between the remote, control unit, and the actuator is done
using a home automation communications protocol implement through coding in our case it
was implemented in C & C#.

9
Internet Of Things (IOT) Based Home/Industrial Automation

Over View about ESP8266:

The ESP8266 is a low-cost Wi-Fi chip with full TCP/IP stack and MCU (Micro
Controller Unit) capability produced by Shanghai-based Chinese
manufacturer, Espressif Systems.
The chip first came to the attention of western makers in August 2014 with the
ESP-01 module, made by a third-party manufacturer, AI-Thinker. This small
module allows microcontrollers to connect to a Wi-Fi network and make simple
TCP/IP connections using Hayes-style commands. However, at the time there
was almost no English-language documentation on the chip and the
commands it accepted. The very low price and the fact that there were very

10
Internet Of Things (IOT) Based Home/Industrial Automation

few external components on the module which suggests that it could


eventually be very inexpensive in volume, attracted many hackers to explore

the module, chip, and the software on it, as well as to translate the Chinese
documentation.
The ESP8285 is an ESP8266 with 1 MB of built-in flash, allowing for single-
chip devices capable of connecting to Wi-Fi.

Over View about Windows 10 IOT Core:

11
Internet Of Things (IOT) Based Home/Industrial Automation

Windows 10 IoT Core is a version of Windows 10 that is optimized for smaller


devices with or without a display, and that runs on the Raspberry Pi 2 and 3,
Arrow DragonBoard 410c & Minnow Board MAX. Windows 10 IoT Core
utilizes the rich, extensible Universal Windows Platform (UWP) API for building
great solutions.

Why Windows 10 IoT Core?


Windows 10 IoT Core brings the power of Windows to your device and makes
it easy to integrate richer experiences with your devices such as natural user
interfaces, searching, online storage and cloud based services

Visual Studio
To develop your applications, you can use the latest free Visual Studio 2015
Community Edition. Visual Studio is a professional quality development tool
that is available free and includes universal app templates, a code editor, a
powerful debugger, rich language support, you can use any language i.e. C,
C#, C++, Python and more.

12
Internet Of Things (IOT) Based Home/Industrial Automation

Algorithm Flowchart:

13
Internet Of Things (IOT) Based Home/Industrial Automation

GUI Designing
Mian Page:

Side Panel:

14
Internet Of Things (IOT) Based Home/Industrial Automation

WiFi Scan Tab:

Connect Tab:

15
Internet Of Things (IOT) Based Home/Industrial Automation

Interfacing of the GPIOs with the GUI


The interfacing of the GPIO with the wifi,esp is used as a bridge between the webpage
(html code) and GPIO control.all pins are not only the GPIOs or other purpose pins
like PWM, SPI or I2C as in microcontroller.

<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
-->
<Page
x:Class="WiFiScan.Scenario4_Connect"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WiFiScan"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<DataTemplate x:Key="ResultsListViewTemplate">
<Grid Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*" MinWidth="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.Column="0" Grid.Row="0" Height="32" Width="32" Margin="0,5"
VerticalAlignment="Top" HorizontalAlignment="Left">
<Image Source="{Binding Path=WiFiImage}"
Stretch="UniformToFill"/>
</Border>

<Border Grid.Column="1" Grid.Row="0" Margin="5">


16
Internet Of Things (IOT) Based Home/Industrial Automation

<StackPanel Orientation="Horizontal">
<TextBlock Text="Ssid:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=Ssid}" FontWeight="Bold"
TextWrapping="Wrap"/>
</StackPanel>
</Border>
<Border Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Margin="5">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Bssid:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=Bssid}" TextWrapping="Wrap" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Rssi:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=Rssi}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Ch. Frequency:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=ChannelCenterFrequency}"
TextWrapping="Wrap"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=SecuritySettings}" TextWrapping="Wrap"
Margin="0,0,5,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock FontWeight="Bold" Text="{Binding Path=ConnectivityLevel}"
TextWrapping="Wrap" Margin="0,0,5,0"/>
</StackPanel>
</StackPanel>
</Border>
</Grid>
</DataTemplate>

</Page.Resources>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">


<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
Margin="12,20,12,50">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Margin="0,0,0,10">
<TextBlock Text="Description:" Style="{StaticResource SampleHeaderTextStyle}"/>
<TextBlock Style="{StaticResource ScenarioDescriptionTextStyle}"
TextWrapping="Wrap"
Text="View available networks on the first WiFi Adapter and connect to a selected
network." />
17
Internet Of Things (IOT) Based Home/Industrial Automation

</StackPanel>

<ScrollViewer Grid.Row="1" VerticalScrollMode="Auto" VerticalScrollBarVisibility="Auto"


Margin="0,0,0,10">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Name="Buttons">
</StackPanel>
</ScrollViewer>

<Border Grid.Row="2" BorderBrush="AntiqueWhite" BorderThickness="1">


<ListView x:Name="ResultsListView"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemTemplate="{StaticResource ResultsListViewTemplate}"
ItemsSource="{Binding Path=ResultCollection}"
SelectionChanged="ResultsListView_SelectionChanged">
</ListView>
</Border>

<ScrollViewer x:Name="ConnectionBar" Grid.Row="3" VerticalScrollMode="Auto"


VerticalScrollBarVisibility="Auto"
Margin="0,15,10,10" Visibility="Collapsed">
<StackPanel Orientation="Vertical" x:Name="ConnectButtons">
<StackPanel x:Name="NetworkKeyInfo" Orientation="Horizontal" >
<TextBlock Text="Security Key:" Margin="5,0,5,0" VerticalAlignment="Bottom"/>
<PasswordBox x:Name="NetworkKey" Width="124" Margin="5,0,10,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<CheckBox x:Name="IsAutomaticReconnection" IsChecked="False">Auto
reconnect?</CheckBox>
<Button Click="ConnectButton_Click" Margin="5,0,0,0">Connect</Button>
</StackPanel>
</StackPanel>
</ScrollViewer>

</Grid>
</Grid>
</Page>

18
Internet Of Things (IOT) Based Home/Industrial Automation

Programming Hardware Which is Handling User Request


#include <ESP8266WiFi.h>
#include "PCF8574.h"
#include <Wire.h>
#include <dht.h>

#define IN_BUFFER_SIZE 4
#define SENSOR_BUFFER_SIZE 2
#define RELAY_BUFFER_SIZE 4
#define REV_BUFFER_SIZE 4
#define DHT11_PIN 16
#define PIR_PIN 14

dht DHT;
PCF8574 PCF_01(0x38);

int btn[IN_BUFFER_SIZE];
int Sensor[SENSOR_BUFFER_SIZE];
char relay[RELAY_BUFFER_SIZE];
char receive_data[REV_BUFFER_SIZE];
int PIR_PIN_STATUS ;
//======================================

char char_array[10];
int h1 = 0, h2 = 0, t1 = 0, t2 = 0;
String str ;

//======================================
//const char* ssid = "Tenda";

// const char* ssid = "connect net j4";


// const char* password = "Forex_2005";

const char* ssid = "TP-LINK_EDA53A";


const char* password = "35718338";

WiFiServer server(21);
WiFiClient serverClients;

void setup()
{
Serial.begin(115200);
Wire.pins(12, 13);
PCF_01.begin();
pinMode(PIR_PIN, INPUT_PULLUP);
19
Internet Of Things (IOT) Based Home/Industrial Automation

// wifi setup start


Serial.setDebugOutput(false);
WiFi.begin(ssid, password);
Serial.print("\nConnecting to "); Serial.println(ssid);
uint8_t i = 0;
while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500);
if (i == 21) {
Serial.print("Could not connect to"); Serial.println(ssid);
//while (1) delay(500);
}

server.begin();
server.setNoDelay(true);
Serial.print("Server is started at");
Serial.print(WiFi.localIP());
Serial.println("on Port # 21' to connect");
// wifi setup end

delay(1000);
}

void loop()
{

//==========================================
// TCP Protocol start
//==========================================
if (server.hasClient()) {

Serial.println("gotclient");
serverClients = server.available();

while (serverClients.connected())
{
if (serverClients.available()) {
Serial.println("Receiving data from client");
while (serverClients.available()) {

for (int n = 0; n < 4; n++) {


receive_data[n] = serverClients.read();
Serial.print(receive_data[n]);
}
Serial.println("");
}//Serial.println("disconnected");

//you can reply to the client here

20
Internet Of Things (IOT) Based Home/Industrial Automation

} else {

Serial.print("Sending data to Client");


Main_Routine(); // For taking user input & update sensor data while client is connected
for (int y = 0; y < sizeof(char_array); y++) {
size_t len = sizeof(char_array);
serverClients.write((const uint8_t*)char_array, len); //(const uint8_t*)dest

}
//delay(2000);
}

//=======================================================
// TCP Protocol end
//=======================================================
Main_Routine();

void Toggle(int pin_num) {

switch (pin_num)
{
case 0: PCF_01.toggle(0); break;
case 1: PCF_01.toggle(1); break;
case 2: PCF_01.toggle(2); break;
case 3: PCF_01.toggle(3); break;

}
void All_Input_Read() {

btn[0] = PCF_01.read(5);
btn[1] = PCF_01.read(6);
btn[2] = PCF_01.read(4);
btn[3] = PCF_01.read(7);
//delay(200);

}
void All_Output_Read() {

if (PCF_01.read(0) == 0) {
relay[0] = '1';
} else {
relay[0] = '0';
21
Internet Of Things (IOT) Based Home/Industrial Automation

if (PCF_01.read(1) == 0) {

relay[1] = '1';
} else {
relay[1] = '0';
}

if (PCF_01.read(2) == 0) {
relay[2] = '1';
} else {
relay[2] = '0';
}

if (PCF_01.read(3) == 0) {
relay[3] = '1';
} else {
relay[3] = '0';
}

}
void Read_Sensor_Data(void) {

int check = DHT.read11(DHT11_PIN);


Sensor[0] = DHT.humidity;
Sensor[1] = DHT.temperature;

}
void Print_Output() {

Serial.print("char_array = ");
for(int u = 0; u < sizeof(char_array); u++){
Serial.print(char_array[u]);
}
Serial.println("");

}
void split_h(int input_number) {
h1 = (input_number / 10);
h1 = h1 - ((h1 / 10) * 10);

h2 = input_number - ((input_number / 10) * 10);


}
void split_t(int input_number) {

t1 = (input_number / 10);
t1 = t1 - ((t1 / 10) * 10);

22
Internet Of Things (IOT) Based Home/Industrial Automation

t2 = input_number - ((input_number / 10) * 10);


}
void conver_to_char(void) {

str += String(h1);
str += String(h2);
str += String(t1);
str += String(t2);
//str += String(Sensor[2]);

str.toCharArray(char_array, sizeof(char_array));

PIR_PIN_STATUS = digitalRead(PIR_PIN);
if (PIR_PIN_STATUS == 1) {
char_array[4] = '1' ;
} else {
char_array[4] = '0' ;
}

char_array[5] = relay[0] ;
char_array[6] = relay[1] ;
char_array[7] = relay[2] ;
char_array[8] = relay[3] ;
char_array[9] = '#' ;

}
void read_char(void) {

split_h(Sensor[0]);
split_t(Sensor[1]);
conver_to_char();

}
void Main_Routine(void) {

Read_Sensor_Data();
All_Input_Read();

if (btn[0] == 0|receive_data[0] == '1') {


Toggle(0);
receive_data[0] = '0';
delay(150);
}
if (btn[1] == 0|receive_data[1] == '1') {
Toggle(1);
receive_data[1] = '0';
delay(150);
}
23
Internet Of Things (IOT) Based Home/Industrial Automation

if (btn[2] == 0|receive_data[2] == '1') {


Toggle(2);
receive_data[2] = '0';
delay(150);

}
if (btn[3] == 0|receive_data[3] == '1') {
Toggle(3);
receive_data[3] = '0';
delay(150);
}

All_Output_Read();
read_char();
Print_Output();

24
Internet Of Things (IOT) Based Home/Industrial Automation

Wifi Connectivity with Network

Features:

• WiFi IEEE 802.11n 2.4Ghz single-band.


• 64/128 bit WEP, WPA/WPA2, WPA-PSK/WPA2-PSK and Wi-Fi Protected
Setup (WPS requires software activation, no hardware WPS button on device)
• Backward compatible with 802.11g/b and USB 1.1
• Data transfer rates of up to 150Mbps theoretical- 24Mbps realistic in field testing.
• Supports Ad-hoc and Infrastructure modes

Supported Operating Systems:

• Windows XP, Windows Vista (32-bit and 64-bit), Windows 7, 8, & 10 (32-bit and
64-bit).
• Linux (driver included with kernel versions 2.6.38, 3.0.8 and later, compile
required for 2.6.18-2.6.37)
• Raspberry Pi running Raspbian

Performance:

The small size of this adapter makes it extremely portable and keeps it nicely flush
with the USB port. However, the small antenna has trade-offs in terms of range
and performance.
We recommend using with an access point or peer wifi adapter that is in the same
room or nearby. The adapter works best with line of sight to the access point

25
Internet Of Things (IOT) Based Home/Industrial Automation

Enclosure Box: We have made some changes in enclosure box that are shown in
Appendix.

26
Internet Of Things (IOT) Based Home/Industrial Automation

Software Codes

Info:
<Page>
x:Class="WiFiScan.Info"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WiFiScan"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Height="Auto" Width="Auto"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="-


115,-2,0,0">
<Grid HorizontalAlignment="Left" Height="400" Margin="80,5,0,-3" VerticalAlignment="Top"
Width="910">
<TextBlock x:Name="textBlock" TextWrapping="Wrap" Margin="96,3,-188,301">
<Run Text="DESCRIPTION:"/>
<LineBreak/>
<Run Text="This application is part of final year project which has title &quot; IOT
HOME &amp; INDUSTRIAL AUTOMATION&quot;"/>
</TextBlock>
</Grid>

</Grid>
</Page>

Scan:
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
-->
<Page

27
Internet Of Things (IOT) Based Home/Industrial Automation

x:Class="WiFiScan.Scenario2_Scan"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WiFiScan"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<DataTemplate x:Key="ResultsListViewTemplate">
<Grid Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*" MinWidth="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.Column="0" Grid.Row="0" Height="32" Width="32" Margin="0,5"
VerticalAlignment="Top" HorizontalAlignment="Left">
<Image Source="{Binding Path=WiFiImage}"
Stretch="UniformToFill"/>
</Border>

<Border Grid.Column="1" Grid.Row="0" Margin="5">


<StackPanel Orientation="Horizontal">
<TextBlock Text="Ssid:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=Ssid}" FontWeight="Bold"
TextWrapping="Wrap"/>
</StackPanel>
</Border>
<Border Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Margin="5">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Bssid:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=Bssid}" TextWrapping="Wrap" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Rssi:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=Rssi}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Ch. Frequency:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=ChannelCenterFrequency}"
TextWrapping="Wrap"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=SecuritySettings}" TextWrapping="Wrap"
Margin="0,0,5,0"/>
28
Internet Of Things (IOT) Based Home/Industrial Automation

</StackPanel>
<StackPanel Orientation="Horizontal">

<TextBlock FontWeight="Bold" Text="{Binding Path=ConnectivityLevel}" TextWrapping="Wrap"


Margin="0,0,5,0"/>
</StackPanel>
</StackPanel>
</Border>
</Grid>
</DataTemplate>

</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<ListView HorizontalAlignment="Stretch" Height="240" VerticalAlignment="Stretch"
Margin="0,10,0,0">
<TextBlock x:Name="connectionStatus" Text="Not Connected" TextWrapping="Wrap"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox x:Name="ssidHost" Text="SSID" Width="200" Margin="10,0,0,0"
VerticalAlignment="Center" ></TextBox>
<TextBox x:Name="portHost" Text="Port" Width="100" Margin="10,0,0,0"
VerticalAlignment="Center" ></TextBox>
<Button x:Name="connectHost" Content="Connect" Width="100" Margin="10,0,0,0"
Click="Button_Click"/>
</ListView>
<Grid Margin="25, 0, 0, 0" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Humidity:"/>
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0,10,0,0" Text="Temperature:"/>
<TextBlock Grid.Row="2" Grid.Column="0" Margin="0,10,0,0" Text="Motion:"/>
<TextBlock Grid.Row="3" Grid.Column="0" Margin="0,10,0,0" Text="Load1:"/>
<TextBlock Grid.Row="4" Grid.Column="0" Margin="0,10,0,0" Text="Load2:"/>
<TextBlock Grid.Row="5" Grid.Column="0" Margin="0,10,0,0" Text="Load3:"/>
<TextBlock Grid.Row="6" Grid.Column="0" Margin="0,10,0,0" Text="Load4:"/>
<TextBlock x:Name="sensor1" Grid.Column="1" Grid.Row="0" Margin="3"
HorizontalAlignment="Right"/>
<TextBlock x:Name="sensor2" Grid.Column="1" Grid.Row="1" Margin="0,10,0,0"
HorizontalAlignment="Right" />
<TextBlock x:Name="sensor3" Grid.Column="1" Grid.Row="2" Margin="0,10,0,0"
29
Internet Of Things (IOT) Based Home/Industrial Automation

HorizontalAlignment="Right" />
<TextBlock x:Name="led1" Grid.Column="1" Grid.Row="3" Margin="0,10,0,0"
HorizontalAlignment="Right" />
<TextBlock x:Name="led2" Grid.Column="1" Grid.Row="4" Margin="0,10,0,0"
HorizontalAlignment="Right"/>
<TextBlock x:Name="led3" Grid.Column="1" Grid.Row="5" Margin="0,10,0,0"
HorizontalAlignment="Right"/>
<TextBlock x:Name="led4" Grid.Column="1" Grid.Row="6" Margin="0,10,0,0"
HorizontalAlignment="Right"/>

</Grid>
<StackPanel Height="30" HorizontalAlignment="Stretch" VerticalAlignment="Center"
Orientation="Horizontal" Margin="0,5,0,0">
<Border Width="75" Margin="4,0,0,0" >
<TextBlock Text="" x:Name="led1status" VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Border>
<Border Width="75" Margin="4,0,0,0" >
<TextBlock Text="" x:Name="led2status" VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Border>
<Border Width="75" Margin="4,0,0,0" >
<TextBlock Text="" x:Name="led3status" VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Border>
<Border Width="75" Margin="4,0,0,0" >
<TextBlock Text="" x:Name="led4status" VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Border>
</StackPanel>
<StackPanel Height="60" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
Orientation="Horizontal" Margin="0,5,0,0">
<Button x:Name="led1Btn" Content="Load1" Width="75" Margin="4,0,0,0"
Click="Button_Click_1"/>
<Button Content="Load2" Width="75" Margin="4,0,0,0" Click="Button_Click_2"/>
<Button Content="Load3" Width="75" Margin="4,0,0,0" Click="Button_Click_3"/>
<Button Content="Load4" Width="75" Margin="4,0,0,0" Click="Button_Click_4"/>
</StackPanel>
</StackPanel>
</Grid>

</Page>

Connect:
<Page
x:Class="WiFiScan.Scenario4_Connect"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WiFiScan"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
30
Internet Of Things (IOT) Based Home/Industrial Automation

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<DataTemplate x:Key="ResultsListViewTemplate">
<Grid Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*" MinWidth="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.Column="0" Grid.Row="0" Height="32" Width="32" Margin="0,5"
VerticalAlignment="Top" HorizontalAlignment="Left">
<Image Source="{Binding Path=WiFiImage}"
Stretch="UniformToFill"/>
</Border>

<Border Grid.Column="1" Grid.Row="0" Margin="5">


<StackPanel Orientation="Horizontal">
<TextBlock Text="Ssid:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=Ssid}" FontWeight="Bold"
TextWrapping="Wrap"/>
</StackPanel>
</Border>
<Border Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Margin="5">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Bssid:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=Bssid}" TextWrapping="Wrap" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Rssi:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=Rssi}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Ch. Frequency:" Margin="0,0,5,0"/>
<TextBlock Text="{Binding Path=ChannelCenterFrequency}"
TextWrapping="Wrap"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=SecuritySettings}" TextWrapping="Wrap"
Margin="0,0,5,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock FontWeight="Bold" Text="{Binding Path=ConnectivityLevel}"
TextWrapping="Wrap" Margin="0,0,5,0"/>
</StackPanel>
</StackPanel>
31
Internet Of Things (IOT) Based Home/Industrial Automation

</Border>
</Grid>
</DataTemplate>

</Page.Resources>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">


<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
Margin="12,20,12,50">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Margin="0,0,0,10">
<TextBlock Text="Description:" Style="{StaticResource SampleHeaderTextStyle}"/>
<TextBlock Style="{StaticResource ScenarioDescriptionTextStyle}"
TextWrapping="Wrap"
Text="View available networks on the first WiFi Adapter and connect to a selected
network." />
</StackPanel>

<ScrollViewer Grid.Row="1" VerticalScrollMode="Auto" VerticalScrollBarVisibility="Auto"


Margin="0,0,0,10">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Name="Buttons">
</StackPanel>
</ScrollViewer>

<Border Grid.Row="2" BorderBrush="AntiqueWhite" BorderThickness="1">


<ListView x:Name="ResultsListView"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemTemplate="{StaticResource ResultsListViewTemplate}"
ItemsSource="{Binding Path=ResultCollection}"
SelectionChanged="ResultsListView_SelectionChanged">
</ListView>
</Border>

<ScrollViewer x:Name="ConnectionBar" Grid.Row="3" VerticalScrollMode="Auto"


VerticalScrollBarVisibility="Auto"
Margin="0,15,10,10" Visibility="Collapsed">
<StackPanel Orientation="Vertical" x:Name="ConnectButtons">
<StackPanel x:Name="NetworkKeyInfo" Orientation="Horizontal" >
<TextBlock Text="Security Key:" Margin="5,0,5,0" VerticalAlignment="Bottom"/>
<PasswordBox x:Name="NetworkKey" Width="124" Margin="5,0,10,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<CheckBox x:Name="IsAutomaticReconnection" IsChecked="False">Auto
reconnect?</CheckBox>
<Button Click="ConnectButton_Click" Margin="5,0,0,0">Connect</Button>
</StackPanel>
32
Internet Of Things (IOT) Based Home/Industrial Automation

</StackPanel>
</ScrollViewer>

</Grid>
</Grid>
</Page>

Application
There are various applications of such a project that has a worldwide
control following are the applications of this projects.

 Smart home. Smart Home clearly stands out, ranking as highest Internet of

Things application on all measured channels.

 Wearable.

 Smart City.

 Smart grids.

 Industrial internet.

 Connected car.

 Connected Health (Digital health/Tele-health/Telemedicine).

 Smart retail.

 smart Switch for Appliances.

33
Internet Of Things (IOT) Based Home/Industrial Automation

Usefulness

 This project is less expensive as it has the low cost equipment.

 This project uses the Internet connection as a media of the communication

making it controllable over the world wide public network so can be

controlled from anywhere in the world if the project has Internet

Connection.

 Less power consuming project as it has all the low power equipment on

board.

34
Internet Of Things (IOT) Based Home/Industrial Automation

Associated Problems
The problems associated with the project are those technical and those
which are associated with the hardware and the circuit designing. We will
be addressing all the problems one by one under the following heading
and the how we solved the respected problem.

Software Related:

 Programming:

 First of all the problem that we faced is in installing the Visual Studio
2015 which take very long time to complete and then using it since
we were not familiar with the VS interface and so we had to deal with
the problem by studying about the visual studio 2015 interface and
coding syntax using the knowledge available on the internet and
thus we have found the required commands that were necessary for
the project.

 As we are the students of the electronics and we do not have the


skill in the web designing, web designing is one of the most
important part of this project as it was the interface to connect the
user with the ESP8266 base wifi device and that is why we have to
find the workable codes for the project that will work in the required
situations and functions for this purpose we had to search the codes
on the different forums these are as follows:

 www.w3school.com
 www.stackoverflow.com
 www.github.com
 www.developer.microsoft.com
 www.support.smartbear.com
 www.docs.microsoft.com
 www.esp8266.github.io
35
Internet Of Things (IOT) Based Home/Industrial Automation

 Networking

 For the communication to be possible between the board and the user
it is very important that there should be a good network between the
two devices the one that the user is using for the communication i.e.
Raspberry pi 2 with UWP App on it and the ESP8266 base device for
controlling hardware but the real problem we face when we had to
connect the esp8266 base device with the public Network and that’s
where we had to study about the port forwarding on the router for that
purpose.

The other problem was the dynamic IP which was the greatest huddle in
the way of communication between the Board and the User as to be in
contact with the board the user must constantly know that what is the
current Public IP on board and this problem was solved by getting an
account on www.noip.com this provided the domain name
"iothomeautomation.zapto.org" for the server on ESP8266 WiFi
Device. This domain name is temporary and expire in 30 days to keep this
free host name Click the hostname confirmation link in the email sent 7
days before the hostname expires. This domain name can change and
renew by log-in in www.noip.com account.

36
Internet Of Things (IOT) Based Home/Industrial Automation

Hardware Related

 Enclosure box

 It was difficult to accurately design and create enclosure box which


accommodate the Circuit that we have made for that we had to
roam use some cad software which not only provide us accurate
design, light in size but also give 3d view of enclosure box so that we
can change thing as required and to do all that we use a cad software
called "eMachineShop " free version from www. eMachineShop.com

 Circuit

 Our aim was to make an IoT device that connect our home or office
appliances or equipment to internet and control and monitor them
remotely through an Universal windows platform offer by windows 10
IOT core in which using Microsoft visual studio 2015 we can design a
universal windows app, it's called universal app because it can be run
on windows, windows mobile or standalone device which is capable of
running windows 10 IOT core on it as operating system, to connect our
device to wifi router and control appliances we use two-in-one
microcontroller plus wifi module chip called esp8266 but the problem
arose when we required to connect four manual button ,four relays and
sensors which require lots of GPIO's and our esp8266 ran out of GPIO
to tackle this problem we use I/O GPIO Extender PCF8574At an I2C
chip but using I2C chip required knowledge of bit masking ,i2c

37
Internet Of Things (IOT) Based Home/Industrial Automation

Transmission protocol, bitwise operator and much more things off-


course we take help from internet browse countless websites and
forums and finally by the grace of Allah we did it.

 Our circuit was not small and because of this it was not feasible for us
to use the Vero Board because then it would look so untidy and for
this we had to make the PCB for it was a very tough task and we
had never done that before we were greatly assisted by our project
coordinator Sir Abid for this and the Route2000pro was used by us
to make the PCB for the circuit that we had this task had taken the
complete one week and would not have been possible if Professor
Abid Hussain would not have assisted us for this.

 After completion of all project work we face Electromagnetic


interference in our circuit and our project start to behave abnormally
our project Incharge Sir Abid point out that the problem was due to the
high voltage AC load wires that were directly connected to low dc
voltage circuit. To solve this problem we create a separate relay
module PCB that isolate our low dc voltage circuit from high voltage
AC wire and then our project works correctly. The schematic diagram
and pcb can be seen in Appendix.

38
Internet Of Things (IOT) Based Home/Industrial Automation

Improvements for Future


There are certain improvements that we will be suggesting for the future
for this project to make it more advanced and to increase its demand in
the market such that making it compatible with the other jobs as well we
will be discussing all these one by one.

Decade over decade, technology advances the way society behaves, both on
a personal and economic level. Because IoT involves an unlimited number of
connected devices, the market is greenfield. There will be new ideas, business
models approaches and solutions that will change how things are currently
being done.

According to Cisco, 99% of the “things” in the world that could be connected,
remain unconnected today. The opportunities are seemingly endless. Just like
how Apple and Google took over the mobile industry, any player can come in
and change the game. It will be interesting to see which businesses see the
most change in the next few years.

Having (almost) everything in your home talking to your broadband router


means updates and software patches can be rolled out from headquarters in
minutes. Updating your smart phone's operating system on a regular basis
improves security, adds extra features and squashes bugs, and in the near
future you're going to be able to do the same for your microwave and your hall
clock (and most updates will be automatic too).

39
Internet Of Things (IOT) Based Home/Industrial Automation

Conclusion
The project is useful for most of the cases and is even fun to work with and
makes a working environment friendlier, but with all the good.

There is a lot more work to be done on this type of projects in future but we
have worked the best in all our good capacity and achieved a great milestone in
this field of technology that’s is we have achieved the controlling over the
Internet and as well controlling of sensors.

We had learnt a lot more during this project and all of this is credit goes to
Our respected teacher Professor Abid Hussain

40
Internet Of Things (IOT) Based Home/Industrial Automation

APPENDIX
Schematic Diagram of Isolation relay module:

PCB layout of

Isolation relay

module:

41
Internet Of Things (IOT) Based Home/Industrial Automation

Below is the picture

of the modified

Electronics

enclosure box that

we made as

required by our

needs.

42
Internet Of Things (IOT) Based Home/Industrial Automation

There are some picture of the final device with custom design front panel and

sensor integration..

43

S-ar putea să vă placă și