Docstoc

CELL PHONE CONTROLLED HOUSE AUTOMATION

Document Sample
CELL PHONE CONTROLLED HOUSE AUTOMATION Powered By Docstoc
					CELL PHONE CONTROLLED HOUSE AUTOMATION



                    By

                Hieu Huynh
                Mark Jiang




      ECE 445, SENIOR DESIGN PROJECT
                  FALL 2006




            TA: Pervesh Thakker

             05 December 2006
                Project No. 1
                                      ABSTRACT

We designed and constructed a cell phone controlled house automation system. The
system allows users to send commands from their cell phones to control both a thermostat
and a security camera.

Commands are sent via a cell phone’s text messaging capabilities to a dedicated email
account. The email account is checked by a PC running a Perl script and valid commands
are then parsed and sent out to either the thermostat or the security camera via Bluetooth.
The thermostat or security camera will then send a reply back to the PC, which sends an
email back to the user’s cell phone.

Our designs worked, but improvements can still be made in the areas of camera
compatibility and better user interface.

Overall, the final price of implementation was not as high as anticipated as some parts
were not needed. However, if this product were to be produced and sold, further cuts
would be needed to make the end price competitive. Also, several parts such as the
computer and the video camera can be used if the user has them existing in the house, so
their purchase would not be necessary.
                                              TABLE OF CONTENTS

1.   INTRODUCTION ....................................................................................................................1
     1.1 Purpose ...............................................................................................................................1
     1.2 Specifications ......................................................................................................................1
     1.3 Subprojects .........................................................................................................................1
         1.3.1 Power Supply Module ...............................................................................................1
         1.3.2 Thermostat Module ...................................................................................................1
         1.3.3 PC with Bluetooth Dongle ........................................................................................2
         1.3.4 Email Account ...........................................................................................................2
         1.3.5 Security Camera Module ...........................................................................................2

2.   DESIGN PROCEDURE ...........................................................................................................3
     2.1 Power Supply Design .........................................................................................................3
     2.2 Thermostat Design ..............................................................................................................3
     2.3 PC with Bluetooth Dongle Design .....................................................................................4
     2.4 Email Account ....................................................................................................................4
     2.5 Signal Replication ...............................................................................................................4
     2.6 Signal Reproduction ...........................................................................................................5

3.   DESIGN DETAILS ..................................................................................................................6
     3.1 Power Supply Module ........................................................................................................6
     3.2 Thermostat ..........................................................................................................................6
     3.3 PC with Bluetooth Dongle ..................................................................................................6
     3.4 Security Camera..................................................................................................................7

4.   DESIGN VERIFICATION .......................................................................................................8
     4.1 Power Supply .....................................................................................................................8
     4.2 Bluetooth Communication .................................................................................................8
     4.3 Cell Phone to PC Communication .....................................................................................8
     4.4 PIC to Video Camera .........................................................................................................8
     4.5 Password Verification ........................................................................................................8
     4.6 System Performance ..........................................................................................................9

5.   COST ......................................................................................................................................10
     5.1 Parts ..................................................................................................................................10
     5.2 Labor .................................................................................................................................10

6.   CONCLUSIONS ....................................................................................................................11

     REFERENCES .......................................................................................................................12

     APPENDIX A – BLOCK DIAGRAMS ...............................................................................A.1
APPENDIX B – SCHEMATICS..........................................................................................A.4

APPENDIX C – TEST DATA ............................................................................................. A.6

APPENDIX D – PICTURES ................................................................................................ A.8

APPENDIX E – PARTS AND COST ................................................................................A.10
                                    1. INTRODUCTION

We designed and constructed a cell phone controlled house automation system. The
system allows users to send commands from their cell phones to control both a thermostat
and a security camera. Commands are sent via a cell phone’s text messaging capabilities
to a dedicated email account. The email account is checked by a PC running a Perl script
and valid commands are then parsed and sent out to either the thermostat or the security
camera via Bluetooth. The thermostat or security camera will then send a reply back to
the PC, which sends an email back to the user’s cell phone.

1.1 Purpose

The purpose of this project was to explore the increased functionality of cell phones and
to incorporate the use of a cell phone into the area of home automation. We used our
knowledge of current technology and engineering to design a complete system where the
cell phone would be used as a primary control device.

1.2 Specifications

The Bluetooth module should be able to receive transmissions from the PC from a
distance of at least 70 ft indoors. We wish to be able to transmit this far even with walls
and other obstructions included.

We decided that the time between sending a command and receiving a response should
be kept as low as possible. An instant response from the security camera or the thermostat
would not be necessary, but some sort of feedback should be sent in a timely matter so
that the user can confirm that the command was received properly. The cycle time for
sending a command and receiving some sort of feedback should be kept below 2 minutes.
The largest variable that will affect this will be the response time of the POP3 mail
account.

1.3 Subprojects

Our system is divided into several modules which perform different tasks.

1.3.1 Power Supply

The power supply takes a 9V DC source and outputs a +3.3V line and a +5.0V line with
respect to ground.

1.3.2 Thermostat Module

The thermostat module receives commands from the PC via Bluetooth and then interprets
and executes these commands. The thermostat is able to check the ambient temperature




                                              1
and also control the relays which switch on and off the heating and cooling devices in the
house.
 1.3.3 PC with Bluetooth Dongle

The PC will download messages from the email server and parse them for commands.
The commands will then be sent via Bluetooth to the thermostat and/or the security
camera. Any response from the thermostat or the security camera will then be replied
back to the sender of the email.

1.3.4 Email Account

The email account will be a freely available, POP3 enabled account which will be able to
receive email messages from the cell phone. Any responses from the thermostat or the
security camera would also be sent from the email account back to the cell phone.

1.3.5 Security Camera Module

The security camera module needed to have stored combinations of signals that could
control the security camera. The module would also need to have its own internal 40
KHz clock to account for the modulation frequency that security camera demands. This
module can be controlled through the cell phone or on-site given the use possesses the
password

The module also contained a controller that acts as the on-site communicator between the
user and many of the peripherals, such as security camera. The controller hardware has a
stored 8 bit password that must be unlocked in order for the peripherals to be enabled.




                                            2
                               2. DESIGN PROCEDURE

2.1 Power Supply Design

Our power supply was designed to take a 9V DC source and provide a stable +5V, +3.3V
and ground terminals to the thermostat and security camera circuits. In our power supply,
we chose to use the LM317T variable voltage regulator to take as input the 9V source.
We needed two voltage regulators for each circuit. One regulator would provide the
+3.3V output to the Bluetooth module, and the other would provide the +5V output to the
PIC microcontrollers and other hardware.

2.2 Thermostat Module Design

The thermostat consists of a BlueRadios BR-C40 Bluetooth module, a PIC 16F877
microcontroller, and a LM34 temperature sensor. We originally planned to use the
DS1820 digital temperature sensor, but the main drawback was programming the
P16F877 to follow the timing diagrams needed to communicate with the DS1820. We
decided to use the LM34 in conjunction with the P16F877’s A/D converters to measure
temperature, because there would be less timing issues. The LM34 features a terminal
which outputs a temperature dependant voltage.

Commands from the PC would be sent serially through the BR-C40 to the P16F877. The
PIC would interpret the commands and either set the temperature for temperature
regulation or return the value of the current temperature back to the PC. Since no
sensitive timing operations are required, we decided to not use assembly to code the
temperature regulation and PC communication routines. We decided to use the PicBasic
Pro compiler because of the included serial functions and because of the familiarity with
the BASIC programming language.

We decided to not include the LCD panel in our design mainly because the user would
not benefit from its inclusion for normal use. Since the primary purpose of the system
would be to give the user feedback and control from out of the home, an LCD panel
would not give any additional benefits to the user. If the user wished to install a serial
LCD onto the thermostat, an output was provided which would send the current
temperature and the status of the heating and cooling relays in ASCII serially.

The goal of the temperature regulation logic was to keep the ambient temperature of the
room within a designated temperature zone. Consideration of whether the heater or cooler
was currently turned on or off was taken into account. We also did not want the
thermostat to overcompensate for temperature changes, that is, fluctuate between turning
on the heater and then turning on the cooler immediately afterwards to keep the
temperature within the target zone.




                                              3
2.3 PC with Bluetooth Dongle Design

The PC consists of a desktop or laptop computer running Windows XP and a Bluetooth
Dongle running BlueSoleil software. Additional software that is needed is ActiveState
Perl 5.8, and the modules POP3Client, SendMail, and GuiTest. The primary goal of the
PC is to download messages from the email server, interact with the devices, and then
send a reply back to the sender.

The Perl scripting language was chosen as the main programming language primarily
because of its expandability with a wide range of freely available modules from
www.CPAN.org, and also because of its powerful text manipulation capabilities. The Perl
script would be responsible for routing commands from the email server to the thermostat
or security camera, and then package the response from the device into an email that
would be replied back to the sender.

Hyperterminal was chosen was the terminal emulation program which would
communicate serially with the BR-C40 Bluetooth module. The Perl SerialPort and
Device::Modem modules did not work correctly with the virtual COM ports created by
the Bluetooth Dongle software. In order to interact with Hyperterminal, the keystroke
simulation module GuiTest was used. Hyperterminal’s Text Capture functions were used
to interpret the response from the thermostat and the security camera. Responses from the
devices would be outputted to a text file which then would be read by Perl.

2.4 Email Account Decision

The email account chosen was the free 10 MB account from www.bluebottle.com. The
BlueBottle account featured standard POP3 access for checking mail, and SMTP protocol
for sending messages. The Bluebottle account did not have SSL encryption, which was
necessary because we found that Perl had compatibility problems with SSL encrypted
POP3 servers.

2.5 Signal Replication Decision

The first idea was actually to break open the remote control and place a switch that could
mechanically control the outputs. However, the decision was made to try and manually
recreate the signals and use an infrared LED to communicate with the video camera. The
first circuit that was made included a photo LED and comparator. The circuit’s purpose
was to clearly output the messages stored in the remote control to be analyzed and
eventually reproduced. The photo LED only passes current when it detects an infrared
light signal. That signal would be compared to half of Vcc and the output would be a
much clearer representation of the desired signal.

2.6 Signal Reproduction Decision

The PIC 18F2520 was chosen because of the expanded instruction set and multiple I/O
ports available. The original choice was PIC 16F84a was not sufficient enough in either



                                            4
of these two areas. The specific instruction that was needed was the compare functions.
In the module, the password protection function needed to compare whether the inputted
function matched with the stored password. The compare instruction also made
navigating the menu internally much easier

Assembly level programming was chosen as opposed to C level because of the delicate
timing issues. The output signal to the video camera has delicate timing as the output is
toggled thousands of time within a fraction of a second. Assembly allow for maximum
control as each line of instruction only takes on fixed amount of time.




                                            5
                                 3. DESIGN DETAILS

3.1 Power Supply

The power supply uses two LM317T voltage regulators to deliver +5V and +3.3V
outputs from a standard 9V input from a wall outlet. The LM317T output voltage is
adjusted by changing the ratio of resistors connected to the output and ADJ terminals.
The governing equation for output voltage is

                      Vout = VRef(1 + R2 / R1) + Iadj(R2)                         3.1.1

where VRef =1.25V, R1 is the resistor across Vout and ADJ, and R2 is the resistor across
ADJ and GND [1].

1 uF capacitors are added to the input and output voltage terminals to decrease any
fluctuations in voltage. Also, protection diodes are added so that the LM317T does not
get damaged in the event that the input power and ground are reversed.

3.2 Thermostat Module

The thermostat uses a PIC 16F877 to communicate to a LM34 temperature sensor. The
LM34 outputs 0.01 V per degree Fahrenheit. To measure this voltage, the P16F877’s A/D
converter is used. The equation for each A/D unit in terms of voltage is

                      A/D Unit= (VRef)/(A/D Resolution)                           3.2.1

With an 8-bit A/D resolution and VRef =2.55 V, each A/D unit will equal 0.01V, or 1
degree Fahrenheit.

The link between the P16F877 and the Bluetooth module is through serial
communication. The settings are for 9600 baud, no parity, and 1 stop bit. The Bluetooth
module must be first set to Data Mode in order for serial communication to occur
between the P16F877 and the PC.

3.3 PC with Bluetooth Dongle

The Perl script downloads messages from the BlueBottle mail server by setting up a
POP3 object with host set to mail.bluebottle.com and port set to 110. The SMTP settings
must allow for user authentication, and port 25 is used for communication.

The sender’s email address is parsed from the header, which is used to set up the reply
email. All emails are parsed for valid commands, which must be spelled correctly, but is
case insensitive. The POP3 server is polled every 30 seconds for new messages.

Hyperterminal is set to 9600 baud with no parity, 1 stop bit, and hardware flow control.
Also, typed characters are echoed locally, and incoming data is forced into 7-bit ASCII.



                                             6
Two second pauses were inserted before every command sent by GuiTest to ensure that
the proper windows are in focus and that the Text Capturing is done at the right time.

3.4 Security Camera

When powered, the controller, PIC 18F2520, sits idly waiting for an input to start an
interrupt-driven set of instructions. There are two interrupt-driven input options. The
first is that an input is being summoned by the cell-phone and in this case the PIC would
just read the input and output the desired signal. The second input would be someone
typing in the password. In this case, the keystroke would be stored. The keystroke in
concatenated with the previous 7 keystrokes would be compared to an 8-bit password that
has been hard-coded into memory. If the password does not match, then the interrupt set
of instructions is done.

Otherwise, four addition inputs are enabled on-site. The user now has the option of
controlling the video camera, or any other hypothetical peripheral, on-site. In code, the
PIC will parse through these four inputs while waiting for the next interrupt.




                                             7
                             4. DESIGN VERIFICATION

Each module of the project was tested to ensure that the module worked as expected.
Most of the modules did not involve any sort of quantitative data, but rather was tested to
see if the module was fully functional or not. Once each individual module was tested,
the modules were pieced together and the whole system was tested for functionality.

4.1 Power Supply

The power supply was tested by connecting a multimeter to the output and measuring the
output voltage. The ripple from both the 5V and 3.3V outputs did not stray more than 5%
from the target voltages.

4.2 Bluetooth Communication

The Bluetooth module was tested by powering up the module and then attempting to
communicate with it through the PC with an attached Bluetooth dongle. Commands were
then sent via Hyperterminal to switch the logic levels of the I/O pins on the Bluetooth
module. The I/O pins were connected to a voltmeter, and were checked to see if any
changes sent were successfully received by the module. We were able to successfully
send commands from the PC to the Bluetooth module and adjust the logic levels of all
available I/O pins.

4.3 Cell Phone to PC Communication

To test the communication between the Cell Phone and the PC, we sent test messages
from the cell phone to the Bluebottle mail account, and waited to see if the PC was able
to successfully download the message and reply back to the cell phone. Using a test Perl
script, we were able to successfully send a text message from the cell phone, have it
downloaded by the PC, and have a confirmation email sent back to the cell phone.

4.4 PIC to Video Camera

To test the communication from the PIC to the video camera, we outputted the signals we
had constructed and checked to see if the video camera was actually responded correctly.
After accounting for the modulation frequency and repeating signals, we were able to
successfully control the video camera from the signals we generating through the PIC

4.5 Password Verification

To test the password verification, a desired password was inputted and the controller was
checked to see if on-site controls were enabled. The compiler’s timer functions were
used to account for mechanical bouncing issues. Bouncing within input buttons made the
PIC record multiple inputs when only one keystroke was pressed. The compiler and an
ICD 2 kit were used to make sure keystrokes were correctly recorded.




                                             8
4.6 System Performance

For the entire system, we wanted to make sure that the cycle time between a sent
command and a received response was under two minutes. We ran some tests where we
measured the times between sending a command and receiving a response, and the
average turnaround time was 1:26 (complete test results in Table C.1).

Another metric we wanted to test was the distance between the PC and the Bluetooth
module. We wanted to see how far we could still successfully send a command to the
Bluetooth module. Our goal was at least 70 ft indoors, and through testing, our Bluetooth
connection was still active up to about 90 ft.




                                            9
                                          5. COSTS

5.1 Parts

The total cost for the power supply comes out to $14.59. The thermostat parts totaled
$108.06, and the cost of the cheapest Dell computer with the Bluetooth Dongle came out
to $394.95. The total cost for the security camera came out to $378.31. These costs were
determined using the minimum amount of parts.

5.2 Labor

Our ideal salary comes out to $65/hour. From our lab notebooks, we spent roughly 140
hours working as a group on this project including research and design time. With this
formula:

       Total Cost = Parts + (Ideal Hourly Salary  (Hours Spent)  2.5)            (5.1)

we estimate that the total labor amounts to $22,750. The total cost for both labor and
parts comes out to $24,024.22.




                                            10
                                6. CONCLUSIONS

Overall we are very satisfied with the results from our project. We were able to
successfully control the thermostat and the security camera remotely using a cell
phone. The effective indoor range for Bluetooth connections was more than 70 feet,
and we were also able to keep the time between sending commands and receiving a
response below two minutes.

In future designs of our system we can improve upon several areas. We can update
the user interface so that it could be more accessible for all users. Also, better
compatibility in security camera makes and models could be made. Our designs could
also be manufactured on PCB to keep things uncluttered, and our circuits can be
enclosed to provide outside protection.

Our project took into account the ethical consideration of user safety. The email
account used featured an email address white list which prevents addresses which
were not approved from reaching the inbox. The thermostat logic prevents the user
from inadvertently setting the temperature to extremely hot or cold temperatures.
Also, the security camera requires password authentication in order to be used.




                                       11
                            REFERENCES
[1]   National Semiconductor, “Data Sheet LM317T 3-Terminal Adjustable
      Regulator”, [Online Document], September 2001 (cited October 2006),
      Available HTTP: http://cache.national.com/ds/LM/LM117.pdf




                                 12

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:70
posted:3/4/2010
language:English
pages:16