3. Bluetooth enabled Smart Home Devices

advertisement
BLUE LIte and Blue Heat
Bluetooth enabled Smart Home Devices
Mark Shaw and Giorgio Politano
The Bachelor of Applied Computing/Diploma in Wireless and Telecommunications
Technology
University of Guelph-Humber
Dr. Mieso Denko
Submitted to the University of Guelph-Humber August 2008
Abstract
Home appliances such as security and climate control systems have become more advanced
with the recent improvements in microcontrollers and wireless technologies such as Bluetooth.
Most of these appliances have difficult and complex user interfaces. However, by incorporating
smart phones and other Bluetooth enabled mobile devices, users can connect to the appliances
using their own existing communication device. Although the automotive industry has taken
advantage of this in recent years with the development of Bluetooth enabled appliances in
many higher-end vehicles, such solutions for the home are not commonly found. This thesis will
outline the design and implementation of a system to interface with pre-existing home
appliances and communicate with a mobile device such as a cell phone, laptop or PDA via
Bluetooth. The application relies on the use of cell phones, personal computers and
temperature sensors to collect signals through a wireless network to provide users with a simple
interface to interact with appliances in the home.
2
Contents
Abstract ......................................................................................................................................... 2
Contents .......................................................................................................................................... 3
1. Introduction ................................................................................................................................. 6
1.1
Background ...................................................................................................................... 6
1.2
Motivation ....................................................................................................................... 7
1.3
Contribution .................................................................................................................... 7
1.4
Organization .................................................................................................................... 7
2. Literature Review ........................................................................................................................ 8
3. Bluetooth enabled Smart Home Devices .................................................................................. 10
3.1 Problem Statement ............................................................................................................. 10
3.2 Objectives ............................................................................................................................ 10
3.3 Development Tools.............................................................................................................. 12
3.3.1 Bluetooth development board ..................................................................................... 12
3.3.2 Microchip Inc. MPLAB IDE, ........................................................................................... 12
3.3.3 FlexiPanel Designer ...................................................................................................... 12
3.4 Interface Design................................................................................................................... 13
3.4.1 User Interface Prototype .............................................................................................. 13
3.5 Software .............................................................................................................................. 14
3.5.1 Pre-defined Toothpick Services .................................................................................... 14
3.5.2 Program Flow Charts .................................................................................................... 16
3.6 Hardware ............................................................................................................................. 16
3.6.1 Block Diagram ............................................................................................................... 16
3.6.2 Bluetooth module with microcontroller ...................................................................... 17
3.6.3 Bluetooth enabled smart phone .................................................................................. 17
3
3.6.4 Honeywell CT50 Series analogy Thermostat ................................................................ 18
4. Implementation and Analysis .................................................................................................... 18
4.1 Interface .............................................................................................................................. 18
4.2 Software .............................................................................................................................. 19
4.2.1 Pre-defined Code .......................................................................................................... 19
4.2.2 Blue Heat Code ............................................................................................................. 20
4.2.3 Blue Lite Code ............................................................................................................... 21
4.3 Hardware ............................................................................................................................. 21
4.3.1 Temperature Control Circuit ........................................................................................ 21
4.3.2 Lighting Control Circuit ................................................................................................. 25
4.4 Installing the Application ..................................................................................................... 26
4.5 Running the Application ...................................................................................................... 27
4.5.1 Interacting with the Interfaces ..................................................................................... 27
5. Future Work............................................................................................................................... 28
6. Conclusions ................................................................................................................................ 29
Appendix A – Schematics .............................................................................................................. 30
Appendix B – Code Flow Charts..................................................................................................... 32
Appendix C – Blue Heat Code ........................................................................................................ 34
Appendix D - Cost .......................................................................................................................... 39
4.6.1 Blue Heat ...................................................................................................................... 39
4.6.2 Blue Lite ........................................................................................................................ 39
References ..................................................................................................................................... 40
4
List of Figures
Figure 1 - Blue Lite/ Blue Heat Interface Prototype ...................................................................... 14
Figure 2 – Blue Lite and Blue Heat CPU User Interface ................................................................. 18
Figure 3 - User interface on Java phone ........................................................................................ 19
Figure 4 - Blue Heat Flow Diagram ................................................................................................ 32
Figure 5 - Blue Lite Flow Diagram .................................................................................................. 33
Figure 6 -Hardware Block Diagram................................................................................................ 16
Figure 7 - ToothPick 2.1 mechanical schematic ............................................................................ 17
Figure 8 - Blue Heat Prototype - Circuit......................................................................................... 24
Figure 9 - Blue Heat Prototype - Back ........................................................................................... 24
Figure 10 - Blue Heat Prototype - Front ........................................................................................ 24
Figure 11 - Blue Lite Schematic ......................................................... Error! Bookmark not defined.
Figure 12 - FlexiPanel Architecture ............................................................................................... 26
5
1. Introduction
1.1 Background
Home automation deals with the specific automation requirements of homes and in the
application of automation techniques for the comfort and security of its residents. This can
include controlling the lights, climate control, control of doors and windows, security and
surveillance systems. There are currently several products on the market that allow home
owners to control these devices. This is normally controlled by a handheld remote that
communicates with the devices using a mesh wireless network or a wired network. These types
of devices require a unique and dedicated device to communicate with the automated products.
One of the basic systems on the market is made by iControl [9] and is easy to install and
expandable. The system uses the 802.11 wireless protocols to transmit signals from the various
devices to a control box which is connected to the internet. Some of the devices the company
offers specifically for elderly care include: cameras, window/door sensors, motion sensors,
water sensors, freeze sensors, panic pendants/wristwatches, smoke detectors, carbon
monoxide detectors, lamp modules, and thermostats. All of the devices are connected wirelessly
to the control box which then allows the devices to be monitored and controlled using the
companies website. This system is perfect for the elderly because it is easy to use and it allows
family members to monitor the house to ensure that their relative is safe, it is portable and can
easily be installed in an existing home. The major drawbacks of this system are that it requires
the use of several costly technologies to properly operate. The user must have internet access
available as well as a router to install the control box. The user must also have a mobile device
which has web access to check the status of their home. This can become expensive with the
data plans mobile carriers offer today.
The automotive industry has also taken advantage of short range wireless technologies to
enable users to safely operate their vehicles while still making hands free phone calls. Most
high-end vehicles produced after 2004 now come equipped with Bluetooth. More than 30
automotive brands worldwide, including Audi and Land Rover, offer Bluetooth-compatible cars.
Some cars come with Bluetooth systems as standard equipment while some offer it as an
available option. Chrysler's system, called UConnect, includes a rearview-mirror-mounted
microphone, a dash-mounted control pad and a hidden Bluetooth receiver. Acura's system,
called HandsFreeLink, is voice-activated, and caller, signal and battery strength information
display on the instrument panel. [11]. This system eliminates hard-wired connections or docking
stations and allows drivers to operate their cell phones either through the car's controls or via
hands-free voice activation. The system then communicates back with you through your car’s
stereo and some systems even automatically mute your car's audio when a call is answered.
These systems have proved to be a popular selling point as many countries are making it illegal
to use a cell phone while operating a vehicle. Although the automotive industry has shown a
6
dramatic increase in the use of Bluetooth technologies for ‘smarter’ cars, this implementation is
not widely found within the home.
Another key project is ongoing at The University of Florida [10]. They have built a 500 square
foot smart house that is designed assist and to provide medical care to a user. The house
implements devices including a microwave that recognizes entrees and automatically
determines how long to cook them and devices to track the individuals location within the
home. The house also uses devices to detect water on the floor and a camera that allows the
person to view who is at the door and let them in using a cell phone. The smart house at the
University of Florida relies on a centralized computer network to deliver electronically
coordinated assistance.
1.2 Motivation
The research previously conducted shows the importance of implementing home automation
for the elderly or disabled. Smart homes allow them to stay in their residents where they feel
more comfortable and can prolong the time before having to move into costly health care
facilities. Smart homes will give the disabled an opportunity for independence that they may
not have had before. The goal of this project is to design a system that communicates with a
mobile device such as a cell phone or PDA via Bluetooth. The application relies on the use of cell
phones and inexpensive sensors and is best suited for the elderly and home-bound people. The
main functions of the project are to collect signals through a wireless sensor network using the
protocol Bluetooth and the analysis for data through an adaptive architecture.
1.3 Contribution
Two innovative products were produced called Blue Lite and Blue Heat. Blue Heat is a Bluetooth
enabled thermostat and Blue Lite is a Bluetooth enabled light controller. Both of these
applications rely on the use of cell phones or personal computers, microcontrollers and
temperature control sensors to collect signals through a wireless network to provide users with
a simple interface to interact with appliances in the home.
The devices produced enable the user to control the appliances using pre-existing devices such
as their mobile phone or home computer. The interfaces are intuitive and easy to use and
provide the user with a more accessible interface then those found in the home. The devices are
also very easy to integrate into existing applications and require only a small amount of
expertise to install.
1.4 Organization
This paper is organized as follows. Section 2 is comprised of a literature review which describes
pre-existing solutions. Section 3 describes the prototype and design of the system produced and
section 4 describes the implementation and analysis of these systems. Future work and
expansions are discussed in section 5 and finally, section 6 gives the conclusions.
7
2. Literature Review
The introduction of home automation in the 1970s failed to improve the lifestyles of users for
several reasons. Firstly, determining economic benefits of home automation technologies is
difficult. The costs of implementing smart home technology must be justified by the effects
brought about by their installation [3]. There is a need for home automation technologies to be
cost effective, easy to install and flexible with many network infrastructures and appliances.
In 2003, Housing Learning & Improvement network published a smart home definition offered
by Interetec which states that a smart home is “a dwelling incorporating a communications
network that connects the key electrical appliances and services, and allows them to be
remotely controlled, monitored or accessed” [4]. The following section includes a brief
summary of previous research into smart homes within the past decade.
In 1995, Welfare Techno-Houses were constructed in Japan. [7]. The purpose of these
experiments was to provide health monitoring for elderly and disabled persons at home by
using fully automated measurements to support daily health care and improve quality of life.
The University of Texas at Arlington has conducted the MavHome project over the past 7 years
[8]. The MavHome (Managing an Adaptive Versatile Home) is a home environment that detects
environment states through sensors and intelligently acts upon the environment though
controllers. The sensors in the home form an ad-hoc network with interconnect together to
make appropriate decisions.
SAP laboratories in Canada with researches from the University of McGill [6] present a wireless
solution for monitoring people in need of medical assistance. The application relies on the use
of cell phones and inexpensive sensors and is best suited for the elderly and home-bound
people. The main functions of the project is to collect signals through a wireless sensor network
using protocols like ZigBee and Bluetooth and the analysis for data through an adaptive
architecture that produces real-time heath-monitoring system to improve medical support for
people in their homes and in assisted living environments.
The research highlights a general architecture framework that consists of three major parts.
Firstly, medical data is collected from sensors and transmitted to mobile devices through a
wireless sensor network. Secondly, collected data is processed by a J2ME application running on
mobile devices. Finally, the data collected and combined with data from other sensors to decide
on an appropriate action. The advantages of this approach are that it does not require costly
equipment, specialized infrastructure or a challenging learning curve. It can be deployed in a
short period of time at a very low cost.
Several groups have done extensive research into the use of smart home devices for the support
or elderly and handicap people. The University of Erlangen-Nuremberg, Germany [5] has
described the challenges regarding smart homes, especially for supporting the elderly and
8
handicapped. The purpose is to compensate for handicaps and support the individual in order
to give them a more independent life for as long as possible.
A set of objectives is outlined that are of particular concern to an elderly or handicapped person.
The higher level goal is to compensate any limitations in any part of his life as far as possible and
to enable the patient to live a more independent life as long as possible. Several sub-networks
were used in the implementation which includes Bluetooth, Wireless LAN, Radio Frequency ID
(RFID), Internet (TPC/IP) and the telephone network. A Bluetooth network is used to
interconnect the nodes and to transport sensor data over the network. The RFID system
provides the possibility to transmit data from the RFID tags that are recording occupancy
locations. Their approach sends messages via Bluetooth using the available Bluetooth module
on the nodes. This means no further hardware is required and additionally no further costs
arise.
A Similar system to the one proposed in this thesis includes research conducted by Engineering
students at the University of Bangladesh regarding the control of remote systems using mobile
telephony [15]. The paper focuses on the services provided by mobile phones and how they can
be used to communicate with and control remote systems. A prototype was developed which
involves the use of two mobile phones, a computer and a Bluetooth module or X10 controller as
the hardware components. Software to facilitate the communication among the devices uses
the Java Standard Edition (J2SE) and Micro Addiction (J2ME) and the C programming language.
The system uses a Java enabled mobile phone running their application to send control
messages to the home. A second phone is connected to the home computer using a data cable.
Software running on the home computer monitors the home mobile for incoming control
messages and acts as an interface between the home mobile and the home appliance. When a
message is received, it sends commands via Bluetooth to communicate with the appliances. The
key issue with this approach is that a computer is required to interface between the home
appliance and the phone. The use of a microcontroller would be better suited to this type of
application as many are available with built in USB and Bluetooth support.
The paper does however reinforce the advantages of using a wireless standard. Bluetooth is a
global standard for connecting a wide range of devices, it is available on most handheld devices,
the technology is very easy to use and set up, and it provides security by encrypting data using a
128-bit long shared key.
Radio Frequency (RF) systems have become increasingly popular recently with the
advancements in RF technology such as Bluetooth and Zigbee. These products offer a much
more reliable short range network then previous Infrared devices which had interference and
security issues. This project will also focus on RF systems for the smart home with focus on the
Bluetooth technology. Although many systems have been researched and proposed, very few if
any have been implemented. This project aims to build on the previous research described to
9
implement a wireless sensor network to monitor appliances in the house. These appliances will
be controlled via a mobile device running Bluetooth. This approach provides an easy to operate
and cost effective approach that will benefit the elderly and those with disabilities function as
normally as possible.
3. Bluetooth enabled Smart Home Devices
3.1 Problem Statement
The focus of our research is on helping elderly or handicapped people live a more independent
life as long as possible. The objective of our system is to take care of several domestic systems
that may normally be difficult for those who are handicap or elderly to take care of. The
proposed idea will allow a user with any Bluetooth enabled device to run a piece of
downloadable software on any mobile device such as a cell phone or PDA. This application will
allow the user to control a device that is connected to any home appliance that is Bluetooth
enabled. The focus of this application will be to direct a lighting system and a climate control
system. Sensors will be connected to the home appliances so that they can be monitored and
controlled.
Suppose an elderly person who has gone to bed and during the middle of the night becomes
uncomfortable with the temperature of the house or hears a noise outside. The proposed
system would enable the client to control the temperature by turning on and the heat or turning
on and off the air conditioning. The user can set heat or air to turn on at a specified
temperature.
The user could also check the status of the outside light and turn on and off the light without the
need to get out of bed. These devices would also benefit users with limited mobility that may
have a difficult time getting to or even reaching their light switch or thermostat. These
objectives require a large amount of technology. The user interface must be as simple and
powerful as possible and operate in a self-organized way.
3.2 Objectives
The following lists of objectives must be completed with this in mind:
1. Develop Bluetooth Appliance Controller: A microcontroller will interface with the
Bluetooth module to perform the automation. A simple microcontroller will receive
signals from the cell phone and will be processed.
2. Develop Software for a Bluetooth Enables Mobile Device: An application will need to
be developed using the J2ME java platform for programs running on mobile devices
using the Java APIs for Bluetooth Wireless.
10
3. Integrate the Appliance Controller to a Device: The appliance controller needs to be
integrated with the lighting/climate control systems at a low cost with easy installation.
4. Create a Scatternet with the Appliance Controller Devices: Create ad hoc Bluetooth
network that is formed by interconnecting devices. This allows every Bluetooth device
to be reached by every other device. This is necessary due to Bluetooth’s short
communication range (10m-100m). This will enable the user to connect to all devices
on the network without having to worry about distance form the device.
5. Conduct Experiments and Analyse Data: Using the mobile device and the appliance
controller, conduct tests on usability and product range within a home environment.
The user will require the following components:

Bluetooth enabled device

Client Software

Bluetooth appliance controller
Two applications will be developed to run the light control ad the climate control devices. The
application should be capable of running on several platforms. An application will be created to
run on devices such as mobile phones, PDA’s and Blackberry devices. To make the software
work on as many devices as possible, applications will also be written to operate on Windows
Mobile clients as well as Bluetooth enabled Windows PCs. The goal for this application is to
make it as robust as possible so that it can be run on many different platforms.
Bluetooth wireless technology will be used which is a short range communications network that
was developed to replace cables that connect portable and fixed devices. Bluetooth is capable
of providing low power, low cost and robust communications between devices. The Bluetooth
standard has been globally accepted which allow almost any Bluetooth enabled device to
communicate with each other seamlessly. This makes the Bluetooth standard best suited for
this type of installation.
A microcontroller will interface with the Bluetooth module to perform the automation.
Bluetooth modules have been developed which combine Bluetooth wireless radios with
programmable integrated controllers that include a full protocol stack that makes interfacing
with the host controller simple, without the need for Bluetooth expertise. A simple
microcontroller will receive signals from the cell phone and will be processed. This will require
both software and hardware development to receive data from the cell phone via Bluetooth to
perform the tasks.
A device that would turn on and off a light will be developed that would use a simple relay to cut
the power to an LED to simulate a light fixture in the home. Another device will be used that
11
has a feedback controller circuit with a small fan and a thermistor. This will simulate a heating
and air conditioning thermostat in the home.
Quantitative results will compare our work with previous work and will highlight how our
application works better. Some key factors for the evaluation will include performance, quality
of service, ease of use, and how the product makes the lives of people easier and better.
Maintaining and enhancing the quality of life for both older people and people with disabilities
involves making independent living as easy as possible.
3.3 Development Tools
The first step in beginning the design and development of our product was to find the tools
necessary to accomplish the tasks. The following is a list and brief description of software used
and why each product was selected.
There are four main components that will be needed to accomplish our project. These include a
Bluetooth module with microcontroller, a Bluetooth development board, a Bluetooth enabled
smart phone and software development tools.
After extensive research into the products and solutions currently available, the following were
chosen to meet our application-specific requirements.
3.3.1 Bluetooth development board
The primary aim of the Bluetooth Evaluation Board is to allow evaluation of Bluetooth products
as easily as possible. The evaluation board can be used during development as a reliable, tested
environment while troubleshooting. This board was selected to help aid in the development of
applications and testing of the device. It was later replaced with custom electronics once the
final device was ready for production.
3.3.2 Microchip Inc. MPLAB IDE,
This development interface is a free, integrated toolset for the development of embedded
applications employing Microchip's PIC microcontrollers. MPLAB IDE runs as a 32-bit application
on MS Windows, is easy to use and includes a host of free software components for fast
application development and debugging. MPLAB IDE also serves as a single, unified graphical
user interface for additional Microchip and third party software and hardware development
tools. Moving between tools and upgrading from the free software simulator to hardware debug
and programming tools is accomplished easily because MPLAB IDE has the same user interface
for all tools. For these reasons, we selected this IDE for the development of the backend code
for the mobile applications. [13]
3.3.3 FlexiPanel Designer,
This graphical user interface design tool is a free is software bundle to aid in the design of
FlexiPanel user interfaces. The user interface may be specified and tested from within the design
tool and then exported to a specific FlexiPanel Server. FlexiPanel is a generic technology for
allowing one device (the FlexiPanel Server) to create a user interface on another device (the
FlexiPanel Client). It provides a wireless universal remote control and monitoring facility for
12
computer software and electronic products, eliminating the need for user interface
components. [14]
These intergraded development environments allow us to design and develop applications to be
used on smart phones which will communicate with the Bluetooth device. There is also
extensive documentation and help guides and examples to help guide us through the
development process.
3.4 Interface Design
Two graphical user interfaces were developed, one called Blue Lite and the other called Blue
Heat. Blue Lite will control the lighting system while Blue Heat will control the climate HVAC
system. The user interface was developed to allow the applications to be run on several
common mobile platforms. The FlexiPanel Designer software was used to create simple yet
intuitive user interfaces. The interface was first developed to produce a more user friendly
product.
3.4.1 Functional Requirements
The goal was to develop a robust application which would allow a user to turn on and off a light
or adjust the climate controls of a thermostat within range of the mobile device. The application
required both user input and feedback which takes user input and sends a signal to the
Bluetooth module. The module then performs the desired action and returns a response to the
application. The applications also needed to be memory and processor conscious as both these
factors are often limited on most mobile devices. Also, the interface is stored in a client/server
architecture where the code for the interface is on the module and is downloaded to the mobile
device when user connects. Creating an interface that is too large results in increased download
time and this needed to be avoided. With these factors in mind, the initial prototype of the
application was produced.
3.4.2 Non-Functional Requirements
The interfaces needed to be simple so that it could still be used by customers that were not
technically savvy. The end user may be someone very familiar with mobile applications or it may
be an elderly person who is new to the technology. The goal was to produce a product that
would be easy to use for all users while still maintaining an atheistically pleasing interface which
was similar to the common look and feel of other mobile applications.
3.4.1 User Interface Prototype
Figure 1 shows the prototype design for both the Blue Lite and Blue Heat user interfaces. The
initial design had to keep in mind the functional and non-functional requirements listed above.
13
Figure 1 - Blue Lite/ Blue Heat Interface Prototype
3.5 Software
As mentioned earlier, the Bluetooth module uses a PIC microcontroller created by Microchip
Technology. They provide a simple development interface called MPLAB which can be used to
write software for the microcontroller. Using the pre-generated code from the design software
which takes the user interface objects and creates C code, the backend code was written to
communicate between the user interface and the electronic devices. All the development was
done using the C programming language.
3.5.1 Pre-defined Toothpick Services
Several Toothpick services are preinstalled in the module in protected memory which helps aid
in programming for the module. Several of these functions were used in generating the
backend code and are explained in detail below:
Digital I/O
The microcontroller allows for all the pins, except for power and ground to be used as single bit
digital input/output pins provided they are not already used for another function. For both
appliance applications, several outputs were used to allow the microcontroller to trigger a relay
which would allow the light and or HVAC to turn on and off. The built in functions provided by
the Toothpick services makes using this pins very simple and only several lines of code are
required.
Analog I/O
The microcontroller supports up to 12 channels of 10-bit and 8-bit analog to digital conversion.
Code definitions provided by the Toothpick services makes using these very simple. The A/D
converter was utilized to enable the Blue Heat application to read an analog temperature value
from a thermistor circuit and convert this value into a temperature reading. The thermistor
circuit provides a value ranging between 0 – 5V which is fed into an input pin on the
microcontroller. The A/D converter then takes this voltage and returns a value to the
application between 0-255 depending on the voltage. The thermistor provides a specific voltage
per degree change and this information was used to then convert this 8 bit number into a
corresponding temperature.
LinkMatik Control
These set of controls lets the program access the LinkMatik Bluetooth radio directly. It is
connected to the universal asynchronous receiver/transmitter port of the PIC microcontroller
which interfaces the radio to the microcontroller. These services pre-installed in the module
allowed us to communicate with the radio easily to perform tasks such as connecting and
disconnecting from the remote device and putting the Bluetooth radio into an aggressive power
saving mode. The radio returns to normal power mode when a command is give or a Bluetooth
event occurs. This state is entered when the module is not connected to a remote device to
help conserve power.
Call back Functions
When an event occurs and the Bluetooth module needs to inform the application that
something has happen, it calls one of the provided call back functions. The cal back functions
provided include the following:

Error Status – this is called if an error occurs and several error codes are provided by the
modules services. These error codes were used extensively to de-bug the application
and code has been written to halt the application if an error has occurred.

LMTEvent – called when an event occurs on the LinkMatik module. These events are
described above in the LinkMatik control section and deal with connecting and
disconnecting the remote devices.

FXPEvent - called when a FlexiPanel interface event occurs, such as a button being
pressed. This event handler was used to trigger the application that the user had
interacted with the interface and the appropriate action is taken based on the input.
The module provides many other services and pre-written functions including pulse width
modulation, parallel communication protocols and many others but these were utilized for our
application.
15
3.5.2 Program Flow Charts
Two program flow charts were created for both the Blue Heat and Blue Lite applications main
code. These flow charts explain the logic of the code and how each component interacts with
the others. Please see Appendix B.
3.6 Hardware
The following is a block diagram of the components used and a detailed description each block
used and why each product was selected. The diagram shows the 3 major components used for
the project. Those items in yellow were purchased and those in red were designed and created
to work with the off the shelf components.
3.6.1 Block Diagram
Figure 2 -Hardware Block Diagram
16
3.6.2 Bluetooth module with microcontroller
The ToothPick 2.0 Bluetooth Transceiver combines the PIC 18LF67J10 programmable interface
controlled microcontroller and the LinkMatik (Bluetooth 2.0) radio device and was purchased for
this project. The microcontroller comes preloaded with Toothpick Services firmware which
includes FlexiPanel user interface server which allows the developer to create intuitive graphical
interfaces to communicate with the Bluetooth module. It also comes packaged with a wireless
field programming tool which allows the software to be electronically distributed and uploaded
to the microcontroller using the Bluetooth protocol.
Figure 3 - ToothPick 2.1 mechanical schematic
This device was chosen because of several key features. This module provides a FCC/CE certified
2.4GHz Class 1.0 Bluetooth radio which provides a free space operating range of 100 meters
with an integral antenna. The device is very small in size with the L x W x H measuring 51mm ×
22mm × 10mm and requires a low regulated voltage of only 5 volts. It draws a limited current of
30mA during transmission and is capable of going into sleep mode where it only draws several
hundred micro Amps. These features make it the ideal solution to easily integrate into existing
home appliances.
3.6.3 Bluetooth enabled smart phone
There are several phones on the market currently that employ Bluetooth technology. Most
major high and low end phones are capable of working with this type of application. For the
17
testing and implementation, the Nokia 6265i handset was used. This phone provides Bluetooth
wireless technology support with an integrated class 2 radio with a transmission range of 30
meters. This device is compliant with Bluetooth Specification 1.2 and it supports several profiles
for communication [12]. This phone was chosen because it provides the tools needed to load
and test our mobile application.
3.6.4 Honeywell CT50 Series analogy Thermostat
In order to test the temperature control circuit, we required the use of a commercially sold
thermostat. We choose the Honeywell CT50 because it provides a simple analog interface
which we were capable of manipulating in order to connect and test our Blue Heat temperature
control system.
4. Implementation and Analysis
4.1 Interface
Once the template was produced, it was time to use the FlexiPanel development tool to
generate the interface. FlexiPanel Designer manages the list of controls that are to be displayed
to the user. The software package provides various views to control different aspects of the
controls, such as how they are managed and how they appear on specific client software. The
application was written to work across several clients including a Windows PC and a mobile
phone running java and the interface was modified for each type of client.
For the Windows PC client, once you connect the computer to the module, the user interface is
displayed as shown in the development tool. Since a Windows PC can provide more processing
power, a more advanced user interface was created and shown below.
Figure 4 – Blue Lite and Blue Heat CPU User Interface
18
The Java phone user interface is greatly limited to the graphics and processing power of the
phone being used. For this reason, the interface is displayed as a simple list of controls which
can be modified by the user. The client can use the scroll functions of their phone to traverse
through the list and use a select button to interact with the controls. This interface resembles
common applications for mobile devices which should be very familiar to the user. The
following image shows how the user interface appears on a mobile phone.
Figure 5 - User interface on Java phone
Once the user interface was designed, it can be programmed into the Bluetooth module but the
controls are not yet interactive because only the interface is generated at this point. The
Toothpick MPLAB modules are automatically generated by the designer software which
produces .C and .H files. These files provide code which enables the use of the controls on the
interface. An application was then generated using MP LAB to interact with the application. The
following section outlines the backend code that was written.
4.2 Software
The backend code that we produced for the applications is explained in the next section. The
code flow charts will help describe the flow of the code. Both the applications for the Blue Lite
and Blue Heat modules were written in C using the MPLAB IDE. The software produced utilizes
many of the built in functions described above as well user defined methods.
The application consists of several classes which will be discussed in detail in this section. The
first section describes the code produced by the interface design software and several header
files which must be included. The second section describes code we produced.
4.2.1 Pre-defined Code
There are two files called Blueheat.c and Blueheat.h that is produced by the FlexiPanel design
software for the user interface. A custom application was being developed using MPLAB C18 so
the user interface is transferred to the Bluetooth module as computer-generated C files which
are included during compilation. This takes the interface that was designed for the applications
and converts it into C so that it may be stored on the Bluetooth module. There was no need to
modify the C code. The BlueHeat.h file is also generated and gives access to several predefined
methods which allow the user interface to be controlled and manipulated. This includes
19
methods to get values from text boxes, set values in number fields and retrieve alerts when the
interface is modified by a user.
Two other files that are utilized are called Toothpick.h and PIC18F6720.h. The first file is a
header file provided by FlexiPanel and is specially written for the Bluetooth module used for this
project. It was not modified and must be included in the project package. The second file is a
header file which is included in the MPLAB C18 compiler and is specifically written for the PIC
microcontroller and is written and supplied by Microchip Technology. It must be included in
order to use the microcontroller and includes methods to perform low-level tasks. This code was
not modified and must be included in the project package.
4.2.2 Blue Heat Code
The main application called main.c starts by waiting for a client to connect. It will continue to
loop through a while loop waiting until a client has connected. During this time, the green LED
on the Bluetooth module is set to flash every 250ms to indicate that it is ready and waiting for a
connection. When a connection is made by a remote device, a high-level interrupt is thrown
and the user is connected to the module. When this occurs, the red LED on the module is set on
to indicate a user has connected.
Once a user has connected the main loop continues by reading a value from one of the analog
inputs and setting up the Analog to digital converter. The value from the input is fed into the 8
bit A to D converter which then returns a value between 0 and 255. This is a digital
representation of the value being fed into the microcontroller by the thermistor. This number is
then converted into a temperature value in degrees Celsius.
The value from the user interface is then read into memory which represents the desired
temperature. A get method is provided in the BlueHeat.h file to get this information from the
textbox. The code then checks to see if the user has selected the heat and AC buttons on the
user interface. When the user clicks on one of the buttons in the interface, a low level event is
triggered. Within this interrupt handler, a value called SetH or SetAC is set to 1 depending on
which button was selected and the code returns from the interrupt handler.
If the heat button was pressed, setH will be set to high. IF this condition is true, a specific pin on
the microcontroller is set to high which triggers the relay to switch to activate the heat control
and another pin is set to low which deactivates the AC control. This is done because the Heat
and AC cannot be turned on at the same time. The opposite occurs if the AC condition is true. A
pin on the microcontroller is set to high to activate the AC control and the heat control is
deactivated. This process simulates the user manually switching the AC or Heat on using the
thermostat.
Next, the value read from the analogue to digital converter which represents the rooms current
temperature is compared against the desired room temperature inputted by the user. If the
heat has been activated and the desired room temperature is greater than the current room
20
temperature, a pin is set to high on the microcontroller which will trigger a relay to turn the heat
unit on and start heating the room. If the desired room temperature is less than the current
room temperature, the heat is turned off. If the AC has been activated and the desired room
temperature is greater than the current room temperature, the AC is turned ON by setting on of
the microcontrollers pins to high. If the desired room temperature is less than the current room
temperature, the AC is turned off.
This process is continually repeated to cycle on and off the HVAC unit as the room temperature
changes. A temperature threshold of 1 degree Celsius is used to keep the current room
temperature within 1 degree of the user’s desired temperature. This means if the user has
selected 25 degrees, the room would heat until it reached 26, shut off and naturally cool until
the temperature reached 24 degrees. The heat would then be activated again and the process
continues.
4.2.3 Blue Lite Code
The code starts by waiting for a client to connect. It will continue to loop through a while loop
waiting until a client has connected. During this time, the green LED on the Bluetooth module is
set to flash every 250ms to indicate that it is ready and waiting for a connection. When a
connection is made by a remote device, a high-level interrupt is thrown and the user is
connected to the module. When this occurs, the red LED on the module is set on to indicate a
user has connected.
Once a user has connected the main loop continues by monitoring the on off button provided in
the user interface. When the user selects the button, a low level interrupt is triggered. In this
event handler, a value called setLight is set to 1 which indicates the button has been pressed
and the interrupt returns back to the main code. If the value is set to 1 then one of the output
pins of the microcontroller is set to high to switch on the light. If the value is set to 0 then the
output is set to low to switch off the light. The source code for both applications is included in
the appendix.
4.3 Hardware
The next step was the development of the electronic components for both of our products. Two
separate components were created for each of the devices and are described in detail below.
Please see Appendix A for the schematics of both this devices.
4.3.1 Temperature Control Circuit
The temperature control circuit is designed to be interfaced with any existing analog thermostat
with very little modification. The control circuit replaces the functionality of the thermostat by
mimicking the same functionality but using digital signals. The Blue Heat module can be placed
near the existing thermostat to work with it or is capable of completely replacing your analog
device.
21
The Bluetooth module is mounted on a circuit board inside the protective casing and is powered
by a single 9V battery. Since standard manual thermostats do not receive any power, an external
power source was needed. This means the battery will need to be replaced periodically by the
user. The LM7805 5 volt power regulator is used to regulate the 9 volts being supplied by the
battery to a 5 volt DC input required by the microcontroller.
Temperature Sensor
A typical analog thermostat uses two different thermometers. One on the front cover to display
the temperature and the other in the thermostat controls the heating and cooling systems. These
thermometers are simply coiled bimetallic strips that consist of two materials with different rate of
expansion and when they heat and cool they expand and contract. To replace this mechanism, a
thermistor was used to read the temperature. A thermistor is a type of resistor with varying
resistance according to temperature. The sensor uses a platinum material which has a
predicable electrical resistant change with varying temperature. The advantages of this type of
temperature sensor are its low cost, compact size and fast response time to vary temperatures.
A single thermostat can be used to control the HVAC system as well as to display the current
temperature to the user.
A voltage divider circuit was created which is a simple linear circuit that produces a portion of the
input voltage across the component. The termistor produces a resistance of 4.7K ohms at 100
degrees Celsius so it was paired with a 4.7K resistor in series to create the voltage divider. The
voltage reading being dropped across the circuit is directly proportional to the current temperature
and produces a value between 0 and 5 volts. One of the major problems with a thermistor is the
variation in measured temperature over the temperature range. This means the resistance vs.
temperature curve is not non-linear which made it very difficult to convert the reading from the
temperature sensor to a temperature. Usually the resolution is good at lower temperatures but
becomes very poor at higher temperatures. To fix this problem a resistor was placed in parallel
with the thermistor. The resistors value is equal to the thermistor's resistance at the mid-range
temperature. This resulted in a significant reduction in non-linearity. This means that there is now
a consistent voltage change vs. temperature curve. This value is then fed into the analog to digital
convertor on the microcontroller where it is changed into a digital reading.
Internal Operation
There are several situations when switching done by the thermostat. Switching occurs when the
user turns on or off the heat and air conditioning and when the HVAC cycles on and off
depending on what the room’s ambient temperature is. Several relays are used to replace these
switching capabilities. There are four terminals on a thermostat that need to be connected and
disconnected. The transformer on the heating and air conditioning unit provides 24V AC from a
transformer. This is then carried through the thermostat and depending on the settings and
temperature conditions; the voltage is carried to the relay on the HVAC unit to turn on and off the
system.
The Omron G5V-2 relay was selected that is capable of switching up to 125VAC with a load up to
2 amps. This is more than what is required as it will be used to switch the 24VAC coming from the
transformer. The relay is capable of being triggered with 5V which will be provided by one of the
microcontrollers outputs. Some other benefits of the relay are that it provides a fully-sealed case,
22
has an operation response time of only 7ms and has a life expectancy of over 15 million
operations. In order to protect the microcontroller, a diode was placed in series with the switching
voltage line from the microcontroller to the relay. Current flowing through a relay coil creates a
magnetic field which collapses suddenly when the current is switched off. The sudden collapse of
the magnetic field induces a brief high voltage across the relay coil which is very likely to damage
the microcontroller over time.
Interfacing with Thermostat
The unit will work with a typical thermostat that is designed for a system with four wires. The wire
terminations from the control circuit are marked as follows:




RH - This wire comes from the 24VAC transformer on the heating system.
RC - This wire comes from the 24VAC transformer on the air-conditioning system.
W - This wire comes from the relay that turns on the heating system.
Y - This wire comes from the relay that turns on the cooling system.
To integrate the Blue Heat control unit with an existing thermostat, the user must connect the
clearly labeled wires from the control unit to the matching connectors inside the thermostat. This
will enable the user to control the HVAC unit using the thermostat as well as the Blue Heat
device. The Blue Heat circuit is wired in series with the existing thermostat. The thermostat can
be used normally at any time while the Blue Heat device is in the off state. If the Blue Heat
device is in the on state, and left in this state, the user will not be able to manually shut it off until
the state is changed to off.
The entire unit is housed inside an atheistically pleasing plastic housing which is made by Pactec
Enclosures. It was chosen because it can be mounted on the wall under an existing thermostat
or in place of an existing one. The housing is completely sealed and all the electronics are
hidden inside the casing which is held together using 4 screws. The unit can be easily serviced
and the entire control circuit inside can be removed if need be. Also, a small door on the back of
the unit provides easy access to the battery for when it needs to be replaced. A blue and red led
are located on the front of the unit to indicate to the user the current state of the HVAC unit. The
red LED is used to indicate if the heat is on and the blue LED is used to indicate if the air
conditioning is on.
Product Results
The next section shows the final product for the Blue Heat device which is illustrated in several
pictures. Figure 8 shows a top view of the prototypes circuitry inside the housing. You can see the
battery compartment on the left which holds a standard 9V battery. This is accessible though a
small removable door on the back of the enclosure as shown in figure 9. The right side of the
housing holds the circuitry and is isolated from the battery compartment.
23
Figure 6 - Blue Heat Prototype - Circuit
Figure 7 - Blue Heat Prototype - Back
Figure 8 - Blue Heat Prototype – Front
24
4.3.2 Lighting Control Circuit
The lighting control circuit is designed to be interfaced with an existing light switch within the
wall electrical box unit. The circuit can easily be wired into a switch box to allow both your light
switch and your Bluetooth enabled device to control the operation of the light. In order to
simulate the mechanical switching of a light switch, a special type of relay was needed. The
relay needed to be capable of switching 110VAC power source found in North American homes
as well as handle up to 10A of current. The relay also needed to be triggered with a 5V input
from the microcontroller but still protect it from power spikes and surges which may occur on
the power lines.
Internal Operation
In order to accomplish this, the Omron G3NE solid state relay was used. A solid state relay
(SRS) acts as an electronic switch but contains no moving parts. The relay we chose is a photocoupled which means it uses a light emitting diode (LED) to activate a photosensitive transistor to
switch the load. They key benefits to this type of relay are that it can be controlled by a low
voltage signal from the microcontroller and physically isolates the controller from the load
optically. It also has built in protection against external surges.
A 9V battery is used to power the microcontroller which is converted to 5V using another LM7805
voltage regulator. The idea setup would use an AC transformer to convert the 110VAC coming
from the power lines to a manageable 6VDC supply to run the microcontroller. This was not
chosen because it requires a much more complex system but will be discussed in the future work
section.
The lighting control circuit is wired in series with the existing light switch to enable them both to
operate at the same time. In order for either one of the two switches to operate, the other switch
needs to be in the on position. The user can leave the Bluetooth control operating as on and still
manually switch on and off the light using the physical switch. Likewise, the user can leave the
switch in the on position and switch the light on and off using the mobile device. Below is a
detailed schematic of the light controller circuit.
Product Results
25
4.4 Installing the Application
The FlexiPanel server which is installed on the module allows remote devices such as Windows
PCs, handheld devices and cell phones to display user interfaces that are stored on the server. It
uses the FlexiPanel Bluetooth Protocol to transmit the user interface to the remote device. The
remote device needs to run the FlexiPanel Client software which is freely available for both
pocket PCs and Windows operating systems. The Client software does not require
customization, since the user interface specifications are stored on the Bluetooth module and
transmitted to the mobile client when it connects. The module is not concerned about the type
of client which connects and it treats them equally. The user interface is compiled using
FlexiPanel Designer software.
Figure 9 - FlexiPanel Architecture
FlexiPanel Clients connect to FlexiPanel servers and a client may connect to a server at any time.
The client is the module installed in the home appliance controller and the client is a remote
device such as a pocket PC or PDA. Once the client has made connection to the server via
Bluetooth, the server tells the client to display the desired user interface on its display. The
server may modify the contents and appearance of the controls at any time, and even replace
the entire ‘dialog’ with another. If the client modifies a control, for example pressing a button, it
sends a message to the FlexiPanel Server. Either the server or the client may choose to
disconnect at any time.
Additionally, the link may be dropped if the devices go out of range of each other. The state of
the controls is retained by the server so that if the client reconnects, or another client connects,
the user interface will be in the same state as it was when it was last modified. The application
was designed taking into account the possibility of a dropped connection. This was
accomplished by making sure that no action would be taken which relies on a client’s ability to
maintain a connection. If the connection is dropped, the application will store the current values
and continue to operate.
26
Wireless field programming (WFP) was used which is a service that allows the developer to
program Toothpick via Bluetooth. A separate Windows software application is used for wireless
field programming. The program is also able to create Service Packs which are specialized
executable files for either Windows and/or Pocket PC which can be distributed to allow
customers to upgrade the application themselves. This application is used to pair with the
Bluetooth module and transmit the application via the Bluetooth wireless protocol to the
module to be stored in memory.
4.5 Running the Application
To run the application, the user must download the client software on the mobile device or PC.
To install the application on a java phone follow the steps below:
1. Download FlexiPanel.jar from http://www.flexipanel.com/WirelessSoftware.htm.
2. Transfer the file to the phone using Bluetooth file transfer, infrared or your sync cradle.
You need consult your computer and/or phone manual to find out how to do this. Try
right clicking on the FlexiPanel.jar and choosing one of the Send To options.
3. The phone should automatically detect that the file is a Java application and install it
automatically. Depending on the phone you have, you may be warned that the software
is not certified. Acknowledge this and continue.
On start-up, the client application will automatically search for devices to connect to. After a few
seconds, a list of available Bluetooth devices will be shown. The applications will be labelled
‘Blue Heat’ and ‘Blue Lite’ on your phone. Select the device you wish to connect to. If the
expected device is not displayed, scan again by selecting Options > Refresh from the menu.
The client application for Windows requires a built in Bluetooth radio or external dongle to
operate. To install the application on a Windows PC, follow the steps below:
1. Download the Windows Remote Client FlexiPanelWin30.exe from
http://www.flexipanel.com/WirelessSoftware.htm.
2. The client software is a standalone application and requires no additional installation.
Simply click on the saved file to begin using it.
4.5.1 Interacting with the Interfaces
When you connect to one of the devices using a phone or pocket PC, the controls are displayed
on the screen in a list. Once a connection is established, the controls will be displayed and can
be used by the client. Depending on the phone being used, the application will appear slightly
different. To interact with the button controls, simply scroll to the button icon using your
mobile phones navigation keys and select the button using the designated button on your
phone. To interact with text controls, scroll to the text icon using your mobile phones
27
navigation keys and select the text control. Then us the mobiles keypad to enter the value and
press select.
To interact with the interface using a Windows personal computer, use the mouse pointer to
hover over the desired buttons and left click on the button icons to activate the controls. To use
the text box control, select the text box with the mouse, use the keyboard to input the value,
and press the OK button to update the field.
5. Future Work
Although the final products were very successful at accomplishing the objectives, it must be
kept in mind that the products produced are simple prototypes and much more work would
need to be done to create a marketable product. Several areas that need to be improved are
the size of the devices, the cost of the devices, the power sources used and the range of
communication.
Currently, the Blue Lite device is too large to fit easily into a pre-existing wall switch electrical
box. There are several ways this could be improved in future work. The use of surface mount
components would dramatically decrease the overall size of the components. Surface mount
components are also often less expensive as they require less material to produce. For example
FlexiPanel offers the Toothpick microcontroller in a surface mount package for $91.50. This
would help reduce the overall cost of the devices as well as the size. Another area to help
improve the size is the circuit board that is used. Currently for the prototype, a generic
breadboard style board was used. If this device were to be commercially produced, a more
compact circuit board could be designed.
The overall cost of the devices is also a major area of concern. One of the key reasons that
smart home technology has failed to be implemented in the home is the cost to benefit ratio.
Currently, with each devices prototype costing over $150, it is difficult to justify the cost to the
end user. There are several reasons for the high cost of the devices but the main reason is that
every one of the components used was purchased through a middle supplier in limited
quantities. The cost would be dramatically reduced if the components were purchased through
the manufacture in higher quantities. Cost savings of over 400 percent can be made simply by
purchasing in bulk. For example, the LM7805 voltage regulator used in both applications was
purchased for 47 cents each. If the order was increased to 10,000 components, the unit price
drops to only 11 cents.
The power sources used for both applications rely on batteries to power the devices. This is a
major issue for two reasons. Firstly, the running costs of both devices increases as the user
must purchase and replace batteries to keep the device operational. Secondly, the device is not
always easily accessible, especially for those users with impairments. This could be improved by
using the existing power source, especially with the Blue Lite device which could use the 110V
28
AC source already being used to power the device. Several digital thermostats also have a power
source being provided that could be tapped into to power the device.
The last area of improvement is in regards to the range of the devices. The radio being used by
the devices is a Class 1 Bluetooth radio which has a rage of up to 100ft. However, most mobile
phones today us a Class 2 Bluetooth radio which has an operational range of only 30ft. This
limits the users range and requires that, if a mobile device is used, you must be within line of
sight of the appliance. A solution is to use a home computer with a Class 1 Bluetooth dongle to
access the devices that are at a farther distance. Test results indicated that the user had a range
of over 80ft in this type of application and could easily control devices in other rooms and on
other floors of the house.
6. Conclusions
The goal of this paper was to outline the design and implementation of a system to interface
easily with pre-existing home appliances and communicate with a mobile device such as a cell
phone, laptop or PDA via Bluetooth using a simple interface. Two innovative products were
produced called Blue Lite and Blue Heat. Blue Heat is a Bluetooth enabled thermostat and Blue
Lite is a Bluetooth enabled light controller. Both of these applications rely on the use of cell
phones and personal computers and inexpensive sensors to collect signals through a wireless
network to provide users with a simple interface to interact with appliances in the home.
The devices produced enable the user to control the appliances using pre-existing devices such
as their mobile phone or home computer. The interfaces are intuitive and easy to use and
provide the user with a more accessible interface then those found in the home. The devices are
also very easy to integrate into existing applications and require only a small amount of
expertise to install.
Our research shows the many types of applications for implementing home automation and the
applications are not limited to those discussed in this paper. The technology used could be
implemented in a wide variety of applications that require the use of sensors and appliances.
This project successfully designed a system that communicates with a mobile device such as a
cell phone or laptop via Bluetooth to control a thermostat and a light switch but has many
possible applications that could benefit from this work.
29
Appendix A – Schematics
Blue Heat Schematic Diagram
Blue Lite Schematic Diagram
Appendix B – Code Flow Charts
Blue Heat
Figure 10 - Blue Heat Flow Diagram
32
Blue Lite
Figure 11 - Blue Lite Flow Diagram
33
Appendix C –Code
Main.c
#include "Toothpick.h"
#include <p18f6720.h>
#include "BlueLite.h"
rom unsigned char * szOn = "ON\r\n";
rom unsigned char * szOff = "OF\r\n";
unsigned char * zero = 0;
int set = 0;
void main( void )
{
//if no BlueMatik, flash red led rapidly
while ((ToothpickSemaphores&TPSF_LMTEXISTS)==0)
{
LedRed = ~LedRed;
msDelay(50);
}
FxPCommand( FxPC_Start, 0, 0 );
AwaitLMTComplete();
// main loop
while ( 1 )
{
// Flash LED to show we're alive
LedGreen = ~LedGreen;
msDelay( 250 );
}
// end of while ( 1 )
}
// HighInterrupt handler - nothing needs to be done
void HighInterrupt (void)
{
}
// LowInterrupt handler - only thing to do is clear the once-per-second clock tick
interrupt
void LowInterrupt (void)
{
if (IsSWI( SWI_Tick ) )
{
ClearSWI( SWI_Tick );
return;
}
// Clear clock interrupt flag
}
// Error event handler
void ErrorStatus( unsigned char ErrNum )
{
// Flash error number for diagnositic purposes
// For product releases, a Reset() is better for unanticipated errors
Breakpoint( ErrNum );
}
34
// LinkMatik Event handler
void LMTEvent( unsigned char EventID, void *pData1, void *pData2 )
{
if ( EventID==LMTE_Syntax )
{
// Flash error number for diagnositic purposes
// For product releases, a Reset() is better for unanticipated errors
Breakpoint( ((unsigned char*)pData1)[0] );
}
}
// FxPEvent handler
void FxPEvent( unsigned char EventID, void *pData )
{
if ( EventID==FxPE_Connect )
{
// turn off red led during connection
LedRed = LedRedOn;
}
else if ( EventID==FxPE_Disco )
{
// turn off red led after disconnection
LedRed = LedRedOff;
}
// Check for control events
else if ( EventID==FxPE_ClntUpdate )
{
// If the button was pressed...
if (*((unsigned short*) pData) == ID_On_Off_3)
{
//LedRed = LedRedOff;
//LedGreen = LedGreenOn;
// Is the current text value F or O?
if (set == 0) //turn light off
{
//LedRed = LedRedOff;
set = 1;
DirAN9 = DirOutput; //setting the the direct out put to
AN9Pin
AN9Pin = 1; //setting the pin to high -
light on
// set the text value to O and update the client
//Set_Result_1( szOff, zero );
//FxPCommand( FxPC_CtlUpdate, ID_Result_1, 0 );
//Set_Result_1( szOn, 0 ) ;
}
else //turn light on
{
//LedRed = LedRedOn;
set = 0;
DirAN9 = DirOutput; //setting the the direct out put to
AN9Pin
AN9Pin = 0; //setting the pin to high -
light on
// set the text value to O and update the client
//Set_Result_1( szOn, 0 ) ;
//Set_Result_1( szOn, zero );
//FxPCommand( FxPC_CtlUpdate, ID_Result_1, 0 );
}
}
}
}
35
BlueLite.c
#include "Toothpick.h"
#include <p18f6720.h>
#include "BlueHeat.h"
int setH = 0;
int setF = 0;
int Channel = 0;
unsigned long ADResult = 0;
ram signed long setTempResult = 0;
signed long curTempResult = 0;
void main( void )
{
SetAnalogAD0; //Sets AD0 as an analog input and all other ADx pins as digital I/O
ADConverterOn8bit; //Turn on A to D converter for 10-bit data conversion
VRefNegIsVss; //Sets negative voltage reference to Vss ground
VRefPosIsVdd; //Sets positive voltage reference to Vdd 5V
//if no BlueMatik, flash red led rapidly
while ((ToothpickSemaphores&TPSF_LMTEXISTS)==0)
{
LedRed = ~LedRed;
msDelay(50);
}
FxPCommand( FxPC_Start, 0, 0 );
AwaitLMTComplete();
// main loop
while ( 1 )
{
// Flash LED to show we're alive
LedGreen = ~LedGreen;
msDelay( 250 );
SetADChan( Channel ); // select a to d channel
CyclesDelay3p2plus3p2times(4);
StartAtoD; // start a to d conversion
AwaitAtoDComplete; // await end of conversion
GetADResult8bit( ADResult ); // get result
curTempResult = (ADResult/5);
//Set_curTemp_13(0,&curTempResult);
//get the desired temp and convert to AtoD value assing to setTempResult
Get_setTemp_16(&setTempResult);
setTempResult = (255 - (setTempResult * 5));
if (setH == 1)
{
//if the heat button is turned on
// set AN5 to low to turn AC off and disconnect RC and O
DirAN5 = DirOutput;
AN5Pin = 0;
//set AN11 high to connect RH and B
DirAN11 = DirOutput;
AN11Pin = 1;
// if the heat is on and its temp is below desired temp by 1
degree, start heating
if(ADResult > (setTempResult+5) )
{
DirAN10 = DirOutput;
AN10Pin = 1;
36
}
// when the temp reaches above the desired temp by 1 degree, turn
the heat off
else if (ADResult < (setTempResult -5))
{
DirAN10 = DirOutput;
AN10Pin = 0;
}
}
// if the heat is turned off, shut down connection between RH and B
else if (setH ==0)
{
DirAN11 = DirOutput;
AN11Pin = 0;
}
if (setF == 1)
{
//if the ac is on, set AN5 high to make connection between Rc and O
DirAN5 = DirOutput;
AN5Pin = 1;
// if the temperature is below desired temp plus 1 degree, turn off
the AC
if(ADResult >(setTempResult+5) )
{
DirAN3 = DirOutput;
AN3Pin = 0;
}
// if the temp is above the desired temp by one degree turn off AC
else if(ADResult < (setTempResult-5))
{
DirAN3 = DirOutput;
AN3Pin = 1;
}
}
// if the AC is turned off, set AN5 to low to disconnect RC and 0
else if (setF ==0)
{
DirAN5 = DirOutput;
AN5Pin = 0;
}
}
// end of while ( 1 )
}
// HighInterrupt handler - nothing needs to be done
void HighInterrupt (void)
{
}
// LowInterrupt handler - only thing to do is clear the once-per-second clock tick
interrupt
void LowInterrupt (void)
{
if (IsSWI( SWI_Tick ) )
{
ClearSWI( SWI_Tick );
return;
}
// Clear clock interrupt flag
}
37
// Error event handler
void ErrorStatus( unsigned char ErrNum )
{
// Flash error number for diagnositic purposes
// For product releases, a Reset() is better for unanticipated errors
Breakpoint( ErrNum );
}
// LinkMatik Event handler
void LMTEvent( unsigned char EventID, void *pData1, void *pData2 )
{
if ( EventID==LMTE_Syntax )
{
// Flash error number for diagnositic purposes
// For product releases, a Reset() is better for unanticipated errors
Breakpoint( ((unsigned char*)pData1)[0] );
}
}
// FxPEvent handler
void FxPEvent( unsigned char EventID, void *pData )
{
if ( EventID==FxPE_Connect )
{
// turn off red led during connection
LedRed = LedRedOn;
}
else if ( EventID==FxPE_Disco )
{
// turn off red led after disconnection
LedRed = LedRedOff;
}
// Check for control events
else if ( EventID==FxPE_ClntUpdate )
{
// If the button was pressed...
if (*((unsigned short*) pData) == ID_Heat_10)
{
if (setH == 0) //turn light off
{
setH = 1;
setF = 0;
}
else //turn light on
{
setH = 0;
}
}
if (*((unsigned short*) pData) == ID_Cool_E)
{
if (setF == 0) //turn light off
{
setF = 1;
setH = 0;
}
else //turn light on
{
setF = 0;
}
}
}
}
38
Appendix D - Cost
The table below is a summary of the total cost of the products used for this project. These costs
show the total amount for the creation of the prototypes used for this project. It does not
accurately reflect the true cost to build these devices if they were to be mass produced.
4.6.1 Blue Heat
Materials
Cost
Toothpick Module
$145.92
Prototype Board
$3.50
Relays x4
$11.20
Thermistor
$0.75
Voltage Regulator
$0.47
Enclosure
$7.50
TOTAL:
$169.34
4.6.2 Blue Lite
Materials
Cost
Toothpick Module
$145.92
Prototype Board
$3.50
Solid State Relay
$26.00
Voltage Regulator
$0.47
TOTAL:
$175.89
39
References
[1] Jiang, Li, Da-You Liu, and Bo Yang. "Smart Home Research." Machine Learning and Cybernetics
(2004). 15 Oct. 2007
<http://ieeexplore.ieee.org.cerberus.lib.uoguelph.ca/iel5/9459/30108/01382266.pdf?tp=&arnu
mber=1382266&isnumber=30108>.
[2] Shepherd, R. "BIuetooth Wireless Technology in the Home." Electronics & Communication
Engineering Journal 13 (2001): 195-203. IEEE/IEE Electronic Library. 15 Oct. 2007.
[3] Beyond the Smart Home, Yamazaki, T.; Hybrid Information Technology, 2006. ICHIT'06. Vol 2.
International Conference on, Volume 2, Nov. 2006 Page(s):350 – 355
[4] “Smart Home Research” , Li Jiang; Da-You Liu; Bo Yang; Machine Learning and Cybernetics, 2004.
Proceedings of 2004 International Conference on, Volume 2, 26-29 Aug. 2004 Page(s):659 - 663
vol.2
[5] Sensor/Actuator Networks in Smart Homes for Supporting Elderly and Handicapped People
Dengler, Sebastian; Awad, Abdalkarim; Dressler, Falko; Advanced Information Networking and
Applications Workshops, 2007, AINAW '07. 21st International Conference on, Volume 2, 21-23
May 2007 Page(s):863 – 868
[6] Dagtas, S, Y Natchetoi, and H Wu. "An Integrated Wireless Sensing and Mobile Processing
Architecture for Assisted Living and Healthcare Applications." An Integrated Wireless Sensing
and Mobile Processing Architecture for Assisted Living and Healthcare Applications (2007): 7072. ACM.
[7] T. Tamura, T. Togawa, M. Ogawa, and M. Yoda, “Fully automated health monitoring system in
the home,” Med. Eng. Physics, 20, pp. 573–579, 1998.
[8] S. K. Das, D. J. Cook, A. Bhattacharya, E. O. Heierman, III, and T.-Y. Lin, “The Role of Prediction
Algorithms on the MavHome Smart Home Architectures,” IEEE Wireless Communications
(Special Issue on Smart Homes), Vol. 9, No. 6, pp. 77–84, Dec. 2002.
[9] "IControl." IControl Networks Inc. 2007. 27 Nov. 2007 <www.icontrol.com>.
[10] Ascribe Newswire. “University of Florida ‘Smart Home’ Demonstrates Concept of Automated
Elderly Help and Care”. Ascribe Newswire: Health. 2003 29 November: 1-2.
[11] Kim, Nina. "Car Gadgets: Bluetooth Wireless Communication." Cars.Com. 31 Aug. 2006. 6 July
2008<http://www.cars.com/go/advice/Story.jsp?section=gdgt&subject=comm&story=blTooth&
referer=&aff=national>.
[12] http://www.telusmobility.com/content/clientcare/pcs_east/guides/nokia_6265i/nokia_6265i_u
ser_guide.pdf
[13] http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocNam
e=en019469&part=SW007002
40
[14] http://www.flexipanel.com/Docs/Designer.pdf
[15] Shahriyar, Rifat, Enamul Hogue, Iftekhair Naim, S. M. Sohan, and Mostofa Akbar. "Controlling
remote system using mobile telephony." ACM International Conference Proceeding Series Proceedings of the 1st international conference on MOBILe Wireless MiddleWARE, Operating
Systems, and Applications 278 Article 36(2008).
41
Download