Upload
phungmien
View
217
Download
3
Embed Size (px)
Citation preview
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 1
CHAPTER 1
INTRODUCTION
The “Home Automation” concept has existed for many years. The terms “Smart Home”,
“Intelligent Home” followed and has been used to introduce the concept of networking appliances
and devices in the house. The popularity of home automation has been increasing greatly in recent
years due to much higher affordability and simplicity through smart phone and tablet connectivity.
The concept of the "Internet of Things" has tied in closely with the popularization of home
automation. Home automation Systems (HASs) represents a great research opportunity in creating
new fields in engineering, architecture and computing. HASs becoming popular nowadays and
enter quickly in this emerging market. However, end users, especially the disabled and old aged
due to their complexity and cost, do not always accept these systems. Due to the advancement of
wireless technology, there are several different of connections are introduced such as GSM, Wifi,
ZIGBEE, and Bluetooth. Each of the connection has their own unique specifications and
applications.
Among the four popular wireless connections that often implemented in HAS project,
Bluetooth is being chosen with its suitable capability. Bluetooth with globally available
frequencies of 2400Hz is able to provide connectivity up to 100 meters at speed of up to 3Mbps
depending on the Bluetooth device class. The capabilities of Bluetooth are more than enough to be
implemented in the design. Also, most of the current laptop/notebook or cell phones are come with
built-in Bluetooth adapter. It will indirectly reduce the cost of this system. A host Bluetooth device
is capable of communicating with up to seven Bluetooth modules at the same time through one
link.
Considering its normal working area of within eight meters, it is especially useful in a
home environment. Thanks to Bluetooth technology and other similar techniques, the concept of
Smart Living has offered better opportunity in convenience, comfort and security which includes
centralized control of air conditioning, lighting, heating and cooling at home, and even service
robots. There are few issues involved when designing a home automation system. The system
should be scalable so that new devices can easily be integrated into it. It should provide a user-
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 2
friendly interface on the host side, so that the devices can be easily setup, monitored and
controlled.
This interface should also provide some diagnostic services so that if there is any problem
with the system, it can be tracked down. Moreover the overall system should be fast enough to
realize the true power of wireless technology. Finally the system should be cost effective in order
to justify its application in home automation. In this project we present a low cost secure cell
phone based, flexible home automation system. Appliances at home are connected to the Netduino
board. The communication between the cell phone and the Netduino board is wireless. Additional
devices can be connected into the system with little modifications. Since the cell phone language is
written in C# (sharp) and it is portable and can run on only on Windows Operating System.
1.1 PROBLEM STATEMENT
Developing a home automation system containing embedded devices from scratch and
programming it with C, C++ or even assembly language is challenging. Simulating hardware and
debugging embedded applications on development PC is hard. Running the software written for
one controller on another platform will not work even if the CPU core is same. Tools for
embedded development are not easy-to-use or complete even today. Therefore it is open challenge
to develop.
1.2 THE SOLUTION
The overall idea for the hypothesized problem is to implement a home automation system
using .NET Micro Framework that would be capable of doing the below possible things:
1. Controlling ambient light intensity with sound in the given room/surroundings.
2. Automated doors using Windows mobile phone via Bluetooth.
2. Controlling a robot using Windows mobile phone via Bluetooth.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 3
1.3 OBJECTIVES
The project was planned to execute with the following objectives:
To Implement a low cost, reliable and scalable home automation system that can be used to
remotely monitor and control using .NET Micro Framework
To emphasize the software development to operate the hardware
To confirm the implemented system to fulfill the defined requirements through testing
To evaluate the system with established requirements in mind and state possible limitations and
suggest future work in the area
1.4 ADVANTAGES
The project envisages the number of advantages:
If you want to build system and write your codes on classic ways, therefore you have to spend
lots of your time to learn low level language while here with NETMF you just need to know
C#, then you just be familiar with hardware catalog.
Here the user is allowed to install NETMF freely on the current .NET (Visual Studio 2010,
2012, 2013).
As .NETMF is open source. Ability to touch the hardware with managed drivers.
.NETMF debugging is as easy as .NET debugging. Our project is to implement a low cost,
reliable and scalable home automation system that can be used to remotely monitor and control
using .NET Micro Framework. Instead of dealing with hardware details, we need to set the
properties of an object.
The biggest reason to go with the .NETMF is the development speed.
Another advantage is the development environment with a 100% managed code, no pointers ,
no memory management bugs.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 4
1.5 LIMITATIONS OF PROJECT
Potential Limitations of our project are:
.NETMF works with high level language such as C# or VB.NET so it might be slower than
low level language such as Assembly.
It is not interoperable as it is limited to the windows technology.
NETMF is not a real time system.
Garbage Collector will run to free unused memory. Garbage Collector might block all threads
for a few milliseconds.
Executing managed code is bit slower than executing native code.
1.6 ORGANIZATION OF DISSERTATION
The project report is organized in terms of different chapters. Each chapter gives the
information about the project development.
Chapter 1 contains the introduction about the project which include problem statement,
solution for problem, objectives of project, advantages and limitations of the project.
Chapter 2 gives the software requirement specification for the project which is developed.
It includes the software and hardware requirements for the project and also input and output
requirements for the project.
Chapter 3 involves the system design procedure of the project, which include the modules
designed in the project. The flowchart and data flow diagrams are used in the system design.
Chapter 4 describes the language used to implement the project, the software tools used,
the code developed for the different functions.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 5
Chapter 5 includes the different testing procedures applied to the project to know the paper
working of the modules. In this stage the efficiency is checked by giving different input and
respective outputs are analyzed.
Chapter 6 gives you the different output snapshots, these snapshots describes how the
project works.
Finally, Chapter 7 includes the conclusion and also future scope of our project.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 6
CHAPTER 2
SOFTWARE REQUIREMENT SPECIFICATIONS
In this chapter we discuss the various software and hardware requirements of our project
cycle. Software requirements mainly involve the functional requirements and various non-
functional requirements like usability, availability, reliability etc.
2.1 FUNCTIONAL OVERVIEW
This project contains different modules depicting a home. These modules are operated by a
Windows mobile phone. Windows mobile phone is used to communicate to different modules of
the system and send commands using Bluetooth communication. The project uses Bluetooth
communication as it is cheaper and reliable and easy to prototype the modules for remote
communication.
The project uses .Net development board from Netduino which acts as a Microcontroller
for the project. The modules are assembled using different components like motor driver, sound
sensor, ultrasonic sensor, servo motor and different embedded components which help in
regulating different characteristics of the project.
When the system is completely ready, Windows mobile phone connects to microcontroller
device Netduino and start sending the commands to different modules of the project. Different
modules of the project are driving a robot, controlling the intensity of light using sound and
automate the doors by sending the commands from mobile phone.
Firstly we need to click the home automation application where we get the login page and
about page containing the information about project guide and project members’ details. The
login page contains the details like Enter pin. By entering the correct password, we get the control
page containing the robot page and the door page.
By clicking the robot page, the controller moves to the robot page where we can move the
robot by sending the directions as command using the windows mobile phone. By clicking the
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 7
door page the controller moves to the door page where we can latch or unlatch the doors using the
windows mobile phone.
2.2 USER CHARACTERSTICS
The user characteristics are as follows
User has to login to the system in Windows mobile phone to use the system.
User has to send commands from Windows mobile phone to different modules of the
project.
User has to move the thumb stick position to drive the Robot.
User has to send Open or Close commands to open or close the doors.
2.3 INPUT REQUIREMENTS
Input requirements consist of the server side and client side.
2.3.1 SERVER SIDE
Validate the commands received from windows mobile phone.
Validate the direction received from windows mobile phone.
Sends the distance to mobile phone.
2.3.2 CLIENT SIDE
Validate password.
Validate the paired device.
Displays appropriate user messages.
2.4 OUTPUT REQUIREMENTS
2.4.1 CRITICAL INFORMATION
If the Bluetooth connection has lost then the critical message displayed is “connection
attempted failed to connect host.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 8
2.4.2 ERROR MESSAGES
No paired devices were found.
Connection attempted failed to connect host.
Bluetooth status is off. Please switch on Bluetooth.
2.4.3 FUNCTIONAL REQUIREMENTS
Functional requirements denote the functions that a developer must build into the software
to achieve use-cases. The home automation system currently being developed would be capable of
performing the below listed functionalities:
o Use a microphone to listen to the level (loudness) of sound in the room and effect the
brightness of bunch of LEDs accordingly.
o Interfacing the Bluetooth module to the hardware and pairing the windows phone to the
respective Bluetooth module and sending a message from the windows phone to the
hardware to automate the doors.
o Interfacing the Bluetooth module to the hardware and pairing the windows phone to
respective Bluetooth module and sending the directions from windows phone to make the
robot move in the respective direction.
Controlling ambient light intensity with sound
o Input: Sound to an Electret microphone.
o Output: Effect the brightness of LEDs.
Automated doors using Windows mobile phone via Bluetooth
o Input: A message to the hardware using Bluetooth communication.
o Output: Latching or unlatching a hardware latch using a servo.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 9
Controlling a robot using Windows mobile phone via Bluetooth
o Input: Sending the directions as commands using the windows mobile phone
application via Bluetooth communication.
o Output: Driving the robot based on the directions provided by the windows mobile
phone application.
2.5 SOFTWARE REQUIREMENTS
The software’s required to run our project includes:
Operating System : Windows 7
IDE : Visual Studio 2010
Firmware : NET Micro framework SDK Version 4.2
SDK(Software Development Kit) : Netduino SDK Version 4.2.2.0
Language : C# .NET
2.6 HARDWARE REQUIREMENTS
The hardware required to run our project includes:
HDD : 40GB
RAM : 4GB
Microcontroller : Netduino & Netduino Plus 2
Mobile Device : Windows Phone
2.7 PROJECT LIFE CYCLE
The project follows a Waterfall model of Software Engineering. The Waterfall model is a
sequential design process, often used in software development processes, in which progress is seen
as flowing steadily downwards (like a waterfall) through the phase of conception, Initiation,
Analysis, Design, Construction, Testing and Maintenance. The result of each phase is one or more
documents that are approved are finished. The phase should not start until the previous phase has
finished. During design problem with requirements are identified during coding and design
problems are found and so on. The software process is not a simple linear model but involves a
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 10
sequence of iteration of the development activities. A small number of iteration it is normal to
freeze parts of the development such as specification and so on.
Fig 2.1: Waterfall model-Progress flows from the top to the bottom.
o Requirements analysis and definition:
The system’s services, constraint and goals are established by consultation with
system users. They are then defined in detail and serve as a system specification.
o System and software design:
The system design process partitions the requirements to either hardware or
software systems. It establishes overall system architecture. Software design involves
identifying and describing the fundamental software system abstractions and their
relationships.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 11
o Implementations:
During this stage, the software design is realized as a set of programs or program
units. Unit testing involves verifying that each unit meets its specifications.
o Integration and system testing:
The individual program unit or programs are integrated and tested as a complete
system to ensure that the software requirements have been met. After testing, the software
system is delivered to the customer.
o Maintenance:
The system is installed and put into practical use. The maintenance involves
correcting errors which were not discovered in earlier stages of lifecycle, improving the
implementation of system units and enhancing the system’s services as new requirements
are discovered.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 12
CHAPTER 3
SYSTEM DESIGN
In this chapter we are mainly discussing about the hardware design issues. In our project
we are using different hardware components like .Net development board like Netduino 1 and
Netduino plus 2, L293D motor driver, windows phone etc. So here in this chapter we discuss how
these hardware components are connected to various devices like Netduino and Windows mobile
phone and how data exchange takes between them and their specific use in our project.
3.1 PROJECT DESCRIPTION
The “Home Automation” concept has existed for many years. The terms “Smart Home”,
“Intelligent Home” followed and has been used to introduce the concept of networking appliances
and devices in the house.
The popularity of home automation has been increasing greatly in recent years due to much
higher affordability and simplicity through smartphone and tablet connectivity. The concept of the
"Internet of Things" has tied in closely with the popularization of home automation.
In this project, developing an embedded device from scratch and programming it with C,
C++ or even assembly language was challenging. Simulating hardware and debugging embedded
applications on development PC is hard. Running the software written for one controller on
another platform will not work even if the CPU core is same. Tools for embedded development are
not easy-to-use or complete even today.
The overall idea for the hypothesized problems is to implement a home automation system
using .NET Micro Framework that would be capable of doing the below possible things:
Controlling ambient light intensity with sound.
Automated doors using Windows mobile phone via Bluetooth.
Controlling a robot using Windows mobile phone via Bluetooth.
If you want to build system and write your codes on classic ways, therefore you have
to spend lots of your time to learn low level language while here with NETMF you just need to
know C#, then you just be familiar with hardware catalog. Classic ways need compiler for
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 13
microcontroller while here you are free to install NETMF on your current .NET (Visual Studio
2010, 2012, 2013).
NETMF is open source. Ability to touch the hardware with managed drivers. NETMF
debugging is as easy as .NET debugging. Implement a low cost, reliable and scalable home
automation system that can be used to remotely monitor and control using .NET Micro
Framework.
Instead of dealing with hardware details, we need to set the properties of an object. Define
requirements for a system that accommodates the hypothesis. Confirm that the implemented
system fulfills the defined requirements through testing. Evaluate the system with established
requirements in mind and state possible limitations and suggest future work in the area.
.NETMF works with high level language such as C# or VB.NET so it might be slower than
low level language such as Assembly. It is not interoperable as it is developed using windows
technology. NETMF is not a real time system. GC will run to free unused memory. GC might
block all threads for a few milliseconds. Executing managed code is bit slower than executing
native code.
User has to login to the system in Windows mobile phone to use the system. User has to
send commands from Windows mobile phone to different modules of the project. User has to
move the thumb stick position to drive the Robot. User has to send Open or Close commands to
open or close the doors.
3.2 CIRCUIT DESIGN
This project uses some hardware components to perform required actions.
The components are:
Netduino plus 2
L293D motor drive
3.2.1 NETDUINO PLUS 2
The Netduino plus 2 is based on a STMicro STM32F2 microcontroller
from STMicroelectronics. It has a clock frequency of 120 MHz, 192 kB of code space, 60 kB
of RAM and 22GPIO-pins. It also has hardware support for 6 PWM-channels, 4 UART-
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 14
channels, I²C and SPI. The Netduino Plus 2 is similar to the Netduino 2, with a faster 168 MHz
STM32F4 microcontroller and an Ethernet port and microSD slot added.
Fig 3.1 Netduino plus 2 Board
o Size of the board:
Length:2.8inch
Breadth:2.1inch
o Processor and Memory:
The Atmel ARM processor is the main part and it contains the RAM and code space
that is used by the blue pin headers along the side of the board.the pins are used to connect to
other components shields.
o Buttons and Led:
There are two types of LED’s on the board:
The White LED lights up when the board is powered up and acts as a power indicator.
The other LED which is blue is user LED and can be controlled from the program running on
the Netduino.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 15
o Input and Output
Analog Input:
There are 6 analog input pin headers that could be used to read any analog sensors measuring
any of the below things and more
Humidity
Temperature
Light
Pressure/force
Motion
Digital Input/output:
The Digital Input Output pins are the pin headers which can process digital signals as
Inputs or Outputs.
These are 14 in number
These can be plugged into on/off sensors like push buttons, switches, on/off sensors etc.
The output s like LEDs, relay and switches can also be plugged into these headers and
programmed
The Digital Input Output headers are capable of communicating using standard
protocols like I2C, SPI, UART[Serial]
The Digital Input Output headers are also used to send a pulse of electricity as output to
change the speed of a motor, intensity of light and etc.
o Networking:
Ethernet: 10 mbps
Network Stack: lwIP
o Storage:
Micro-sd (up to 2 GB)
auto card detect
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 16
o Power:
The Netduino requires voltage from 7.5V to 12V with the plug having a center positive
pole. The power can be supplied using a AC-to-DC adapter with 5.5mm by 2.1mm outer/inner
plug. In case we use a center pole negative plug the board is protected by integrated reverse
voltage protection fuse. The fuse will auto reset upon cooling.
o Erase pad:
This is the small golden dot at the end of digital I/O pin headers. This is used to erase the
Netduino completely and to start over from scratch. This was made in order make this board
Hacker friendly so the Netduino can be repurposed as an ARM microcontroller development
board. The erase function is activated by connecting a wire between the 3.3v pin and the erase
pad for a few seconds. Once the erase is complete we can even install new operating systems
on the Netduino or write C++ code on to the board or flash from scratch again.
o System Requirements
Windows
Windows XP, Vista, 7 or 8 (32 or 64 bit) ,Recommended: Windows 7 or 8
1.6 GHz or faster processor
1 GB RAM
Up to 3 GB of available hard drive space for Visual Studio Express 2010
Mac OS and Linux
VM Ware Fusion or Oracle Virtual Box Serial deployment and partial USB support
requires copy of Windows in virtual machine.
o Environmental
Operating temperature 0 - 70 °C (32 - 158 °F).
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 17
3.2.2 L293D Pin Diagram
Fig 3.2 L293D Pin Diagram
L293D is a typical Motor driver or motor driver IC which allows DC motor to drive on
either direction. It works on the concept of H-bridge. H-bridge is a circuit which allows the voltage
to be flown in either direction. As you know voltage need to change its direction for being able to
rotate the motor in clockwise or anticlockwise direction, hence IC are for driving a DC motor.
In a single L293D chip there two h-bridge circuit inside the IC which can rotate two dc
motor independently. Due to its size it is very much used in robotic application for controlling DC
motors. Given above is pin diagram of L293D motor controller.
There are two Enable pins on L293D .Pin 1 and pin 9, for being able to drive the motor,
the pin 1 and 9 need to be high. For driving the motor with left H-bridge you need to enable pin 1
to high. And for right H-bridge you need to make the pin 9 to high. If anyone of the either pin 1 or
pin 9 goes low then the motor in the corresponding section will suspend working. It’s like a switch.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 18
There are 4 input pins for this L293D, pin 2,7 on the left and pin 15,10 on the right as
shown on pin diagram. Left input pins will regulate the rotation of motor connected across left side
and right input for motor on right hand side. The motors are rotated on the basis of the inputs
provided across the input pins as LOGIC 0 or LOGIC 1.
3.2.2.1 Voltage specifications
VCC is the voltage that it need for its own internal operation 5v; L293DD will not use this
voltage for driving for driving he motor. For driving the motors it has a separate provision to
provide motor supply VSS (V supply). L293D will use this to drive the motor. It means if you
want to operate a motor at 9V then you need to provide a supply of 9V across VSS Motor supply.
The maximum voltage for VSS motor supply is 36V. It can supply a max current of 600mA
per channel. Since it can drive motors up to 36v hence you can drive pretty big motors with this
L293D. VCC pin 16 is the voltage for its own internal operation. The maximum voltage ranges
from 5v and up to 36v.
3.3 SERVICES
Using Windows mobile phone we are controlling Robot and Automated garage doors.
It is a client server technology where in client sends the commands to operate the different
modules of the system.
Windows mobile phone acts as client and Netduino microcontroller acts as server.
The commands sent by windows mobile phone are interpreted by Netduino microcontroller
and contemporaneously operates the different modules of the system.
In order to access the system in Windows mobile phone, it contains a login page where user
has to enter the password in order to access to system.
As Bluetooth is used for remote communication to devices, if there are no devices to pair
and connect, appropriate user messages are logged.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 19
3.4 UTILITIES
Controlling Ambient Light Intensity with Sound:
In this module we use a microphone to listen to the loudness of sound in the room and
effect the brightness of a bunch of LEDs. We can also stick this module behind TV and get an
awesome glow around the screen during the most intense scenes.
Controlling Robot using Windows mobile phone via Bluetooth:
In this module we move the robot based on the directions provided by the windows phone. We
can also fix the camera module to the robot in order to find the various objects surrounding us.
Controlling Automated Garage Doors using Windows mobile phone via
Bluetooth:
In this module we latch or unlatch the garage doors using the windows mobile phone. We
can save the time by latching or unlatching doors using the windows mobile phone and also
reduces the work of the man power.
3.5 DATA FLOW DIAGRAM
Fig 3.3 Data Flow Diagram
Mobile
Bluetooth
Micro-
controller
Door
Control
Robot
Control
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 20
Dataflow begins at the client side where the client is the mobile. The mobile checks for the
Bluetooth connection. Once the Bluetooth is connected, we can control either the robot or the door
from the microcontroller and the mobile device. For the robot control we can send the directions
as commands to the Micro-Controller through windows phone in order to control the robot. Micro-
Controller sends the calculated distance to the motor driver and also send the signal to Ultra sonic
sensor. As a result robot moves in desired directions and sends the calculated distance to the
microcontroller and then to the client.
In case of Door control the client sends the commands like open and close to the
microcontroller. The microcontroller sends the signal from the client and operates in the same
manner in order to open and close the lock using the windows mobile phone.
3.6 FLOW CHARTS
CLIENT SIDE
Fig 3.4(a) Client side flow chart
Start
Log in page
Control page
Select module
Robot button Door button
Stop
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 21
The above fig 3.4(a) shows the client side flow chart, where the user logins to the Home
automation login page by entering the password. If the password is wrong then the user needs to
re-enter the correct password. If the entered password is correct, control page will be displayed. In
control page the user needs to select the module. Based on the selected module the user needs to
operate the module.
SERVER SIDE
Fig 3.4(b) Server side flow chart
The above fig 3.4(b) shows the server side flow chart, firstly the user check for the
Bluetooth connectivity. If Bluetooth is paired either to the robot control or the door control, if it is
paired to the robot then the user sends the directions as commands, based on the directions the
robot moves and if it is paired to the door, then the user sends either the open or close command.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 22
3.7 Flow Chart of Ambient Light Intensity:
Fig 3.5 Ambient Light Intensity
The above fig 3.5 shows the flow chart of ambient light intensity where in we use a low
pass filter function which allows low frequency sound and avoids the high frequency sounds like
wind etc.
Start
LowPassFilter ()
Input double
SmoothingFactor
SmoothingFactor=SmoothingFactor;
Void Step(double sensor value values)
Smoothvalue=_SmoothigFactor*sensorvalue+(1-SmoothingFactor)
Return
Smoothedvalue
Stop
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 23
CHAPTER 4
IMPLEMENTATION
In this chapter we discuss the programming tool used to implement our project along with
the software tools used. This chapter majorly deals with the implementation of the .NETMF by
using the programming language.
4.1 SOFTWARE TOOLS USED
The following are the software tools used in our project:
VISUAL STUDIO
WINDOWS SDK
LED CALCULATOR
4.1.1 VISUAL STUDIO
Visual Studio is a complete set of development tools for building ASP.NET Web
applications, XML Web Services, desktop applications, and mobile applications. In addition, these
languages use the functionality of the .NET Framework, which provides access to key technologies
that simplify the development of ASP Web applications and XML Web Services.
4.1.2 WINDOWS SDK
Microsoft Windows SDK, Platform SDK, and .NET Framework SDK are software
development kits from Microsoft that contain header files, libraries, samples, documentation and
tools required to develop applications for Microsoft Windows and .NET Framework.
.NET Framework SDK is dedicated to developing applications for .NET Framework
1.1 and .NET Framework 2.0. Windows SDK is the successor of the two and supports developing
applications for Windows XP, Windows Vista, Windows 7, and Windows 8.
4.1.3 LED CALCULATOR
In order to determine what resistors to be used whether to lay them in series or parallel. So
we use the LED calculator each time we change the LEDs.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 24
4.2 IMPLEMENTATIONS DETAILS
The programming techniques and the coding are discussed in this section.
4.2.1 PROGRAMMING TECHNIQUES
This project is developed by using .NET. .NET has many advantages when compared
to other programming languages.
Platform Independent:
The concept of write-once-run-anyway (known as the platform independent) is one of
the important key feature of .NET language that makes .NET as the most powerful language.
Not even a single language is idle to this feature but .NET is closure to this feature. The
programs written on one platform can run on any platform provided the platform must have the
SDK.
Inheritance:
It is the process of creating the new classes and using the behavior of the existing
classes by extending them just to re-use the existing code and adding the additional features as
needed.
Encapsulation:
It is the mechanism of combining the information and providing the abstraction.
Polymorphism:
As the name suggest one name multiple form, Polymorphism is the way of providing
the different functionality by the functions having the same name based on the signatures of the
methods.
Dynamic binding:
Sometimes we don’t have the knowledge of objects about their specific types while
writing our code. It is the way of providing the maximum functionality to a program about the
specific type at run time.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 25
4.2.2 CODING
CLIENT SIDE
The following function represents the client side Bluetooth connectivity. If there are
no devices found then it displays the message that no devices found on the screen. If the paired
devices are found then we connect with the specified host name and it displays the name of the
device in the client side Bluetooth screen.
/// Connect To Bluetooth Device
private async void TryConnect()
{
try
{
PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
var pairedDevices = await PeerFinder.FindAllPeersAsync();
//Check for paired devices
if (pairedDevices.Count == 0)
{
MessageBox.Show("No paired devices were found.");
}
else //Connect to the paired device
{
foreach (var pairedDevice in pairedDevices)
{
if ("HC-05" == pairedDevice.DisplayName && "(30:15:01:16:19:67)" ==
pairedDevice.HostName.DisplayName)
{
_socket = new StreamSocket();
await _socket.ConnectAsync(pairedDevice.HostName, "1");
_isConnected = true;
break;
}
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 26
}
}
}
catch (Exception ex)
{
if (ex.HResult == -2147014836)
{
MessageBox.Show("Connection attempted failed to connect host");
}
else if (ex.HResult == -2147023729)
{
MessageBoxResult result = MessageBox.Show("Bluetooth status is off. Please switch
on bluetooth");
if (result == MessageBoxResult.OK)
{
var task = new ConnectionSettingsTask();
task.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
task.Show();
}
}
}
}
WaitForData Function:
The following function represents the WaitForData from the socket stream after client
side Bluetooth and server side Bluetooth is connected. The client side sends the stream of string
.i.e., “Forward, Backward, Spinning” to robot and “Open and Close” to garage doors along with
the delimetre “|” in the form of bytes to the server side device. Here delimeter is used to split the
strings sent from the client.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 27
/// Function to wait for the data to be received from UltrasonicSensor
async private void WaitForData(StreamSocket socket)
{
try
{
byte[] bytes = new byte[5];
await socket.InputStream.ReadAsync(bytes.AsBuffer(), 5,InputStreamOptions.Partial);
bytes = bytes.TakeWhile((v, index) => bytes.Skip(index).Any(w => w !=
0x00)).ToArray();
string str = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
if (str.Contains("|"))
{
_receivedBuffer += str.Substring(0, str.IndexOf("|"));
DoSomethingWithReceivedString(_receivedBuffer);
_receivedBuffer = str.Substring(str.IndexOf("|") + 1);
}
else
{
_receivedBuffer += str;
}
}
catch
{
TryConnect();
}
finally
{
WaitForData(socket);
}
}
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 28
SERVER SIDE
DataReceived function:
The following function is used receive the data sent from the Client side Bluetooth.
When the server receives the data in the form of bytes, and then the byte string is converted into
char string and is stored in the buffer. Then string is spilt into substring which is stored in the
buffer using the delimiter “|”, and then it calls the DoSomething function.
public static void bt_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
byte[] bytes = new byte[_bluetoothSerialPort.BytesToRead];
_bluetoothSerialPort.Read(bytes, 0, bytes.Length);
string str = new String(Bytes2Chars(bytes));
if (str != null && str.Length > 0)
{
if (str.IndexOf("|") > -1)
{
_bufferString += str.Substring(0, str.IndexOf("|"));
DoSomething(_bufferString);
_bufferString = str.Substring(str.LastIndexOf("|") + 1);
}
else
{
_bufferString += str;
}
}
}
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 29
ChangeDirection Function:
The following function is used to change the direction of the robot based on the strings
received from the client. Here the outputPort1 is the left motor and outputPort2 is right motor.
When the both outputPort1 and outputPort2 are true then robot moves either forward or backward.
When the both ouputPorts are false then robot stops.
private void ChangeDirection(Direction direction)
{
switch (direction)
{
case Direction.Forwards:
_outputPort1.Write(true);
_outputPort2.Write(true);
break;
case Direction.Backwards:
_outputPort1.Write(true);
_outputPort2.Write(true);
break;
case Direction.Stopped:
_outputPort1.Write(false);
_outputPort2.Write(false);
break;
}
}
Ambient light intensity code:
The following function is used to avoid the external noise with a high frequency such as the
noise from the wind etc. And it allows the low frequency of noise. Every time the value is updated.
The updated value is called in a function called step.
namespace HomeAutomationSystem
{
public class SoundSensor
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 30
{
private double smoothingFactor;
public double smoothedValue;
/// Parameterized Constructor for creating object of SoundSensor
/// <param name="smoothingFactor"></param>
public SoundSensor(double smoothingFactor)
{
this.smoothingFactor = smoothingFactor;
}
/// Calculating the smoothing factor
/// <param name="sensorValue"></param>
public void Step(double sensorValue)
{
smoothedValue = smoothingFactor * sensorValue + (1 - smoothingFactor) *
smoothedValue;
}
}
}
4.2.3 FRONT END FORMS DESIGN
The front end consists of the following:
Login Page at the client side.
Password entry form at the client side.
4.2.4 CONNECTIVITY ISSUES
In order to connect software with our hardware, we have used a type of connections
that is:
Bluetooth
Bluetooth is a proprietary open wireless technology standard for exchanging the data
over the short distance (using short wavelength radio transmissions) from fixed and mobile
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 31
devices, creating personal area networks(PANs) with high levels of security. It can connect several
devices, overcome problems of synchronization.
Bluetooth is managed by the Bluetooth special Interest Group, which has more than
14,000 member companies in the areas of telecommunication, computing, networking, and
Consumer electronics.
4.2.5 ARCHITECTURE DIAGRAM
Fig 4.1 Architecture of .NETMF
Hardware Layer: The hardware layer contains the microprocessor and other circuitry that you
select.
Runtime Component Layer: RCL includes three components: the .NET Micro Framework
common language runtime (CLR), a hardware abstraction layer (HAL), and a platform
abstraction layer (PAL).
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 32
CLR - The .NET Micro Framework CLR is a subset of the .NET Framework CLR, which is
the run-time. The CLR is fast; it performs at about 15,000 managed method calls per second at
27.6 MHz
HAL and PAL - The HAL and the PAL control the underlying system hardware. Both the
HAL and the PAL are groups of C++ functions called by the CLR. The PAL functions are
independent of the hardware and should not need to be ported.
The bootstrap code is an additional piece of code that is associated with the HAL. The
bootstrap code initializes the low-level hardware when the device is turned on. It then starts the
CLR, which performs the higher-level initializations. The bootstrap code performs its tasks
through calls to the HAL and assembly-language routines. Other than starting the CLR, it has
no interaction with the code preceding it in the software architecture.
Class Library Layer: The class library included with the .NET Micro Framework is an
object-oriented collection of reusable types that you can use to develop embedded applications.
Application Layer: The top layer of the .NET Micro Framework contains managed
applications that you create for your devices. The types of applications you develop depend
entirely on the hardware in your device.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 33
CHAPTER 5
TESTING
Software testing is a critical element for software quality assurance. It presents the ultimate
review of specification design and coding of software. Testing is called as structured activity. It is
the process of executing a program by detecting errors.
Good testing is that which has the probability of finding the errors error in software. The
final goal of testing is to see that system performs its intended process satisfactorily. In brief, the
common view of testing is that it proves system behavior. The testing phase involves the testing of
individual program units and functionality with various test data.
5.1 SCOPE
In the testing process we test the actual system in organization gather errors from the new
system and take initiatives to correct the same. All the front-end and back-end connectivity are
tested to be sure that the new system operates in full efficiency as stated. System testing is the
stage of implementation, which is aimed at ensuring that the system works accurately and
efficiently.
The main objective of testing is to uncover errors from the system. For the uncovering
process we have to give proper input data to the system. So we should have more conscious to give
input data. It is important to give correct inputs for efficient testing.
Testing is done for each module. After testing all modules, the modules are integrated and
testing of the final system is done with the test data, specially designed to show that the system
will operate successfully in all its expected conditions. Thus the system testing is a confirmation
that all is correct and an opportunity to show the user that the system works. Inadequate testing or
non-testing leads to errors that may appear few months later.
This will create two problems:
Time delay between the cause and appearance of the problem.
The effect of the system errors on files and records within the system.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 34
The purpose of the system testing is to consider all the likely variations to which it will be
suggested and push the system to its limits. The testing process focuses on logical intervals of the
software ensuring that all the statements have been tested and on the function intervals conducting
tests to uncover errors and ensure that the defined inputs will produce actual results that agree
with the required results.
During the development of our project we carried out the following testing procedures in
order to increase the performance and debug certain errors at different stages and thus we resulted
with the feasible, efficient and error free code.
5.2 FUNCTIONAL TESTING
Testing two or more modules together with the internet of finding defects, demonstrating
that defects are not present, verifying that the modules performs its intended functions as stated in
the specification and establishing confidence that a program does what is supposed to do.
In our project the design module is executed with implementation module in which the
components which are used in design module will perform operations which are implemented.
Here, the designed components like Login page, Control page are checked after
implementation by clicking on these pages to check whether they perform the assigned task or
not. Likewise every component of design mode is tested for the functioning by combing with the
implementation.
5.3 INTEGRATION TESTING
Integration testing is a systematic technique for constructing tests to uncover error
associated within the interface. In the project, each modules have been tested as a whole. In the
integration-testing step, all the error uncovered is corrected for the next testing steps.
5.4 BLACK BOX TESTING
Black box testing takes an external perspective of the test object to derive test cases. These
tests can be functional or non-functional. The test designer selects valid and invalid input and
determines the correct output. There is no knowledge of the test object’s internal structure.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 35
The higher the level, the bigger and more complex the box, the more one is forced to is use
black box testing to simplify. While this method can uncover unimplemented parts of the
specification, one cannot be sure that all existing paths are tested.
When black box testing is performed in one’s project then the results obtained clearly
specifies the type of error occurrence whenever inputs are not given properly.
5.5 TEST CASES
For our project, we have developed the following test cases.
Test Case for Login Page
Input Invalid Input
Input Description Password:
“Empty” or “Wrong password”
Expected Result It shouldn’t be accepted
Actual Result Not Accepted
Pass/Fail Fail
Remarks Invalid password
Tab.No 5.1 Login Page for Invalid password
Tab.No 5.2 Login Page for Valid password
Input Valid Input
Input Description Password:
****
Expected Result Accept & allow for the further access
Actual Result Accepted
Pass/Fail Pass
Remarks Hidden Password
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 36
Test Case for Control Page
Input Selecting Robot Page
Input Description Robot control
Expected Result Robot Layout will get open
Actual Result Accepted
Pass/Fail Pass
Remarks Robot Page will get open
Input Selecting Door Page
Input Description Door Control
Expected Result Door Layout will get open
Actual Results Accepted
Pass/Fail Pass
Remarks Door Page will get open
Tab.No 5.3 Control Page
Test case for Robot Page
Input Robot Page
Input Description Controlling Robot
Expected Result Forward/ Backward/spin
Actual Results Accepted
Pass/Fail Pass
Remarks Depending upon the given direction robot
moves in particular direction
Tab.No 5.4 Robot Page
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 37
Test case for Door Page
Input Door Page
Input Description Sending command to the door
Expected Result Latch or unlatch Door lock
Actual Results Accepted
Pass/Fail Pass
Remarks Depending upon the given command door
latches or unlatches
Tab.No 5.5 Door Page
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 38
CHAPTER 6
RESULTS
In this chapter we have discussed the project results. The results of the work are
viewed through the mobile-app and hence the following pages described the various results.
Home page
Login page
About page
Control page
Robot page
Door page
6.1 SNAP SHOTS OF THE PROJECT
Fig 6.1: Home Page
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 39
This snapshot represents Home Automation system application. By selecting home
automation application we will the Login page and about page containing the information about
project guide and project members.
Fig 6.2 Login page
This snap shot represents the login page which contains the details like Enter pin, and
information about the Guide and the Project members. By entering correct password ,we will get
the control page containing robot page and door page.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 40
.
Fig 6.3 Project member details
This snap shot contains the information about the project guide and project members.
It also contains the Login button. By clicking on Login button the about page is re-directed to
Login page.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 41
Fig 6.4 Error Message for Wrong User Name or Password
If the user enters the wrong password then the following statement will be displayed
in the alert box. By clicking OK button on alert box, then the user can re -enter the password.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 42
Fig 6.5 Correct way of entering Password
This snap shot represents the login page with password and information about the
Guide and the Project members. By entering correct password, we will get the control page
containing robot page and door page.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 43
Fig 6.6 Control Page
This snap shot represents the Control page which consists of Robot control and the Door
control. By clicking the robot page, the controller moves to the robot page where we can move the
robot by sending the directions as commands using the windows mobile phone. By clicking the
door page, the controller moves to the door page where we can latch or unlatch the garage doors
using the windows mobile phone.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 44
Fig 6.7 Robot page
This snap shot represents the Robot page. This snapshot contains the thumb stick. The
user sends the command to the robot by moving the thumb stick in desired direction. So, that the
robot moves in particular direction.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 45
Fig 6.7 Door page
This snap shot represents the Door page which contains open button and close button.
By clicking on open button, the open command is sent to the lock and door lock will get open and
if by clicking on close button, close command is sent to the lock and door lock will get close.
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 46
CHAPTER 7
CONCLUSION
This project provides the most modern and reliable Home Automation System. This work
has a low cost system and is designed to improve the standards of living. The remote control
function by smart phone provides help and assistance especially to disabled and elderly. Moreover,
implementation of wireless Bluetooth connection in control board allows the system install in more
simple way. Furthermore, flexible types of connections are designed as backup connections to the
system. The connected GUIs are synchronized to the control board. They indicate the real-time
switches status. The system is designed in user-friendly interface.
You have to spend lots of your time to learn low level language while here with NETMF
you just need to know C#, then you just be familiar with hardware catalog. NETMF is open
source. Your code can be run on other devices in the range of NETMF compatible device.
Debugging is as easy as .NET debugging.
NETMF works with high level language such as C# or VB.NET so it might be slower than
low level language such as Assembly. If the equipment is not handled & installed safely, this can
lead to the equipment being damaged, and the risk of the system crashing is high.
7.1 SCOPE OF FUTURE WORK
We have planned to implement the following features in our project in the future.
Implementing an camera module to the robot.
Add a colour sensor to detect the ambient colour and make the RGB LEDs match. So we
could position the sensor just in front of the TV, and the LED change to the same color as
what is on-screen.
Add a sensor to determine whether the door is open or closed, and report the result back to
the phone
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 47
REFERENCES
Netduino Home Automation Projects, Matt Cavanagh, Packet Publishing Ltd, ISBN 978-1-
84969-782-8
WEBSITES
http://blog.roguecode.co.za/Windows-Phone-controlled-car-with-Netduino-and Bluetooth
http://projekter.aau.dk/projekter/files/61078036/1275905809.pdf
http://dev.windows.com/en-us/develop/download-phone-sdk
http://www.geekality.net/2013/01/02/netduino-firmware-update/
http://forums.netduino.com/index.php?showtopic=10479
http://PacktLib.PacktPub.com
http://netduino.com/
HOME AUTOMATION USING .NETMF
GMIT, DEPT. OF CS&E, Davangere Page 48
APPENDIX
Abbreviations
CLR Common Language Runtime
GSM Global System for Mobile communication
HAS Home Automation System
HAL Hardware Abstraction Layer
.NETMF .NET Micro Framework
PAL Platform Abstraction Layer
PAN Personal Area Network
PWM Pulse Width Modulation
RCL Runtime Component Layer
SDK Software Development Kit
WCF Windows Communication Foundation
WiFi Wireless Fidelity
WPF Windows Presentation Foundation