Smart Thermostat

Honors Project

HomeAlive

Team – 9

2014-2015

Jeremy Ward

Engineering 325 Honors Project

Calvin College

Professor Mark Michmerhuizen

December 12, 2014

1Introduction

This honors project aimed to coordinate with the HomeAlive senior design (SD) project, while learning about a microcontroller. The HomeAlive senior design project seeks to control electronic devices within a home, through a graphical user interface (GUI), using server which communicates to a hub, which communicates to devices via ZigBee.

The mentioned SD project needs, at minimum, a few devices integrated into the system. To accommodate the mentioned SD project this honors project seeks to have a proof-of-concept smart thermostat. This device will allow for testing the SD project and displaying the end product, in May.

2Objectives & Requirements

It is not an objective for HomeAlive, and thereby inherently this honors project, to design a thermostat device; this may be a later project of the proposed company. The objective for this device, and project, is merely to prove a concept (i.e., a thermostat can be controlled by HomeAlive’s system). The implications of this must be made clear: any limitations of the user interface in controlling of the thermostat, due to not being its designer, should not translate as failing to meet any requirements. (e.g., the temperature, set point of the thermostat, and other signals are not readable because they are encoded in a complex digital pulse wave signal only know to the designer. Also, the program in the thermostat’s on-chip user interface will be simulated in the GUI provided by HomeAlive, but any failures in perfectly simulating that program are not a failure to meet any requirements).

There is one simple overarching requirement for this implementation, the ability to remotely control a thermostat using a Windows PC GUI. Another requirement is to choose a digital thermostat that has multiple controllable features. Eventually, the device must incorporate the wireless communication protocol chosen above, but this is not a requirement for this project, only a desirable feature. Lastly, the thermostat adaptations should not inhibit the original design (i.e., not allowing for a mechanical button to be pressed).

3Procedure

3.1Thermostat Selection

The first task was selecting a thermostat. No decision matrix was used. Thermostats were compared at a local hardware retailer and a suitable one was selected Honeywell RTH6450.

3.2Microcontroller Selection

Next, a microcontroller was chosen. Arduino was picked to be the make. The model was decided upon by viewing Arduino’s microcontroller selection guide. The Arduino Uno was selected. See Figure 9 in Appendix.

3.3Thermostat Button Interface

The next step was figuring out how the thermostat worked before any modifications were made. To do this the thermostat was opened up and examined. The thermostat has six buttons. Each button has a positive and negative terminal (0-3V) which are shorted upon the pressing of the button. Figure 7 in the Appendix shows the mechanical button. See Figure 1 for the mechanical button interface, Figure 2 for the electrical circuit interface, and Figure 3for the preliminary GUI (the GUI for the broader HomeAlive system has not yet been created).

Figure 1. Thermostat Mechanical Interface

Figure 2. Thermostat Circuit

Figure 3. Temporary Thermostat GUI

The objective is to use Arduino to remotely control the thermostat, making it smart. Knowing that the button actuates the terminal by shorting the terminal, mechanically, a way was needed to do this electrically. The following logic was developed to solve this problem. If the Arduino is capable of taking in commands remotely and controlling outputs, and if the thermostat can be connected to the Arduino in a way that allows for this controlling, then this project is feasible. Create a switch. If that switch can be controlled electrically, by the Arduino, then the thermostat can be connected to that switch and the above statement can be made true. This switch needs to be carried out using an analog circuit.

3.4Analog Circuit Design

Each button has a positive and negative terminal (0-3V), and pressing the button shorts this terminal. A transistor is capable of this. Upon applying a voltage to the base (or gate depending on BJT or MOSFET – this design uses BJT) the emitter and collector are almost shorted. This mimics the mechanical button press. Figure 4shows theoriginal circuit developed for the design. The 240 Ω resistor limits the current output of the Arduino.

Figure 4. Original Thermostat Analog Circuit

The Arduino’s outputs were connected to the base of a 2N3904 BJT. The 5V output of the Arduino is enough to forward bias the BJT and connect the buttons terminals. Upon receiving the button press signal from the GUI, the Arduino sends out 5V to the base of a BJT. This shorts the emitter and collector of the BJT and actuates a button press.

One problem arose in the design. The thermostats buttons had three isolated ground terminals. Two of six buttons shared a ground terminal making three pairs. See Figure 5. These ground terminals need to stay isolated for the thermostat to operate, but the Arduino has only one GND for all 13 Digital I/O pins. In order to connect the outputs of the Arduino to the base and back to GND the 0V terminal of the button, its GND, needs to be closely connected to the GND of the Arduino. See Figure 4. Because there is only one Arduino GND this leads to all of the button’s GNDs being virtually connected, with only 480 Ω in between them. This design will not work. Either only two buttons may be connected at once or none will work.

Figure 5. Connected GND Pairs

The solution to this problem is making it seem as if the grounds are virtually isolated. This was accomplished by increasing the resistance between the Arduino GND and the button’s GND. Figure 6 shows the new design using 70 KΩ in the place of the 240 Ω. Now the button’s GNDs have 140 KΩ between them and are virtually isolated.

Figure 6. Final Thermostat Analog Circuit

Figure 10 in the Appendix shows the circuit wired up.

3.5Graphical User Interface

The final step in meeting the requirement to remotely control the thermostat was accomplished using a GUI. Figure 3 was created using a C# Windows Form Application project in Microsoft Visual Studios.

Clicking a button sends a specific ASCII Character through the specified serial port. Section 3.6 shows how the Arduino program receives the communication from the serial port, then deciphers if it is a certain command. Table 1 shows the message sent when clicking a button and the message, received by the Arduino.

Table 1. GUI Signal Sent

Button Name / Character to Be Sent for Button / ASCII for Character
Up / 0 / 48
Hold / 1 / 49
Down / 2 / 50
Left / 3 / 51
Center / 4 / 52
Right / 5 / 53

3.6Arduino Program

The Arduino Uno is being used to receive the simulated ZigBee communication from the central hub and actuate the button presses. The following program, listed below as Arduino code, is used to control the Arduino. The pin outs are found in Figure 6 above.

#include <Arduino.h>

// Pin Numbers

int Up = 13;

int Hold = 12;

int Down = 11;

int Left = 10;

int Center = 9;

int Right = 8;

int incomingByte = 0;

// This runs when the reset button is pressed

void setup(){

// initialize the ports

pinMode(Up, OUTPUT);

pinMode(Hold, OUTPUT);

pinMode(Down, OUTPUT);

pinMode(Left, OUTPUT);

pinMode(Center, OUTPUT);

pinMode(Right, OUTPUT);

Serial.begin(9600); //Baud rate

}

// Infinite looping program

void loop() {

if (Serial.available() > 0){

incomingByte = Serial.read(); // Read the command from the GUI

Serial.println(incomingByte); // This is for troubleshooting

if (incomingByte == 48) {// Up button actuation for 0.5 seconds

digitalWrite(Up, HIGH);

delay(500);

digitalWrite(Up, LOW);

}

if (incomingByte == 49) {// Hold button actuation for 0.5 seconds

digitalWrite(Hold, HIGH);

delay(500);

digitalWrite(Hold, LOW);

}

if (incomingByte == 50) {// Down button actuation for 0.5 seconds

digitalWrite(Down, HIGH);

delay(500);

digitalWrite(Down, LOW);

}

if (incomingByte == 51) {// Left button actuation for 0.5 seconds

digitalWrite(Left, HIGH);

delay(500);

digitalWrite(Left, LOW);

}

if (incomingByte == 52) {// Center button actuation for 0.5 seconds

digitalWrite(Center, HIGH);

delay(500);

digitalWrite(Center, LOW);

}

if (incomingByte == 53) {// Right button actuation for 0.5 seconds

digitalWrite(Right, HIGH);

delay(500);

digitalWrite(Right, LOW);

}

}

}

Upon seeing communication on the serial port, the Arduino reads the signal and determines if it is one of the six commands: 48-53. If the command is one of these, the Arduino turns the corresponding output High for 500ms, then turns it Low. This turns the BJT on and actuates the button press, then off.

4Results

This project was a success. The thermostat will be displayed with the SD project provided it is successfully integrated with the system.

5Future Work

The next step for this device is to use ZigBee for communication with the central hub. In addition, the analog circuit, which is currently on a breadboard, will need to be constructed on a PCB. A GUI simulating the thermostat’s mechanical interface will need to be developed and incorporated into the HomeAlive system GUI. This GUI may change in appearance to allow for the user to specify the temperature they want without needing to adjust the current by the difference. (e.g., if the temperature is 68⁰ and the user wants 75⁰, then they would currently be required to click up 7 times. Instead of this the future design should take care of this for the user.) Lastly the design should not only write to the thermostat’s controls but also read some signals from it such as the set point, temperature, whether or not the hold is on, etc.

6Appendix

Figure 9. Arduino Uno