You are on page 1of 7

Arduino Project: Thermostat

Keve Hughes
EE 285/Section D
Gary Tuttle
April 26, 2018

1
Introduction

Thermistors are temperature sensing elements made of semiconductor material that has been
sintered in order to display large changes in resistance in proportion to small changes in
temperature. Therefore, the thermistor sensor module measures temperature sensitively though it
can output only analog signals. The module is often used to detect the temperature changes in
ambient environment.

Components
• Crystal LCD Screen

• Arduino Uno

• Thermistor module

• 4 Pin anti reverse cable

• 3 Pin anti reverse cable

• USB data cable

• 5 connection wires

Crystal LCD
screen,
thermistor
schematic, what’s
on the Arduino
uno board, and
the thermistor
sensor.
- figure 1

2
figure 2: Arduino Pinout Diagram

Procedure
The thermistor will detect surrounding temperature changes in a real-time manner and send the
temperature data to an analog I/O port on the Arduino Uno board. The output is then needs to be
converted to Celsius temperatures via a program and displayed onto the LCD screen.

1. Build a circuit using the available components:

• Connect the 3 pin anti reverse cable to thermistor module, then connect the vcc cable to
the power pin on the Arduino uno marked vcc.

• Then connect the ground cable from the 3 pin anti reverse cable to the ground pin on the
Arduino.

• Next connect the 3 pin anti reverse cable marked SIG to the analog input pin marked A0.

3
2. Connect the crystal LCD to the Arduino

• Use the 4 pin anti reverse cable and connect it to the crystal LCD

• Then on the reverse side of the LCD connect the cable that coincides with the pin marked
ground to the ground pin on the Arduino board.

• Connect the VCC pin from the LCD to the ICSP pin on the Arduino board.

• Connect the SDA pin on the LCD to the analog-in pin on the Arduino labelled A4

• Connect the SCL pin on the LCD to the analog-in pin on the Arduino labelled A5

3. Connect the USB data cable to the Arduino and the other end to your computer.

4. Open the Arduino software on the computer

5. An Arduino IDE will open next, once opened select Tools/Port/Arduino Uno this is
important because this selection allows your program to be uploaded to the Arduino Uno

6. Next write a program that converts the analog data thats read from the thermistor module to
Celsius. Compile the program and then upload it the Arduino Uno.

7. You will now see the temperature displayed on the LCD screen.

8. To demonstrate the thermostat connection to a furnace and cooling system I built three
separate simple circuits with an LED and a resistor for each on a bread board. Using the
Arduino digital PWM pins 13,12, and 11 along with a ground cable connected to the bread
board I am able via the program turn on the blue LED if its to cold, a red LED if its to hot
and a green LED if the temperature is perfect. If the temperature is to hot or cold the user
would adjust the thermostat.

4
Program

Below you will find a complete copy of my Arduino Uno program. Lines 1 is the function for
wire library of the Arduino, this library allows you to communicate with I2C / TWI devices.
Line 2 is the function for the LCD library and line 3 sets the address for crystal LCD. Below is a
reference table that shows where the TWI pins are located on various Arduino boards.

Board I2C / TWI pins


Uno, Ethernet A4 (SDA), A5 (SCL)
Mega2560 20 (SDA), 21 (SCL)
Leonardo 2 (SDA), 3 (SCL)
Due 20 (SDA), 21 (SCL), SDA1, SCL1

Next I defined the thermistor connection to Arduino pin A0 as analogPin and the beta of the
thermistor 3950 which is defined as beta. Line 7 declares and initializes the red, green and blue
LED’s to the digital PWM (pulse width modulation) values 12, 11 and 13 respectively.

Within the void setup I initialized the LCD and open the backlight of it. The following lines
shows the data rate in bits per second as 9600 for serial data transmission and initializing the
digital pins of the LED’s as outputs.

In the void loop, line 21 shows the initialization of the variable ‘a’ which reads the thermistor
value. I was able to locate the calculation to convert the thermistor value to celsius, and then I
initialized tempC with value from that calculation. I then used the conversion of Celsius to
Fahrenheit and initialized tempF with the calculations for that conversion.

Next I set the LCD cursor for lines one and two using “lcd.setCursor( value, value)”. Now for
each line of the LCD screen I created several print out statements for both the Celsius and
Fahrenheit values, I also was able to find out that lcd.print(char(223)) will print out the degree
symbol. Once completed the LCD now displays the temperature reads for the environment in
both Celsius and Fahrenheit.

The following if statements where created to flash the different LED’s at specified temperatures
to demonstrate the moments when the furnace would turn on if its to cold (redLED), when the
cooling system would power on if its to hot (blueLED) and the final LED shows when the
temperature is optimal (greenLED).

5
#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line
display

#define analogPin A0 //thermistor attach to pin

#define beta 3950 //beta of thermistor

int redLED = 12, greenLED = 11, blueLED = 13;

void setup() {

lcd.init(); //initialize the lcd lcd.backlight(); //open the backlight Serial.begin(9600);



pinMode(redLED, OUTPUT);

pinMode(blueLED, OUTPUT);

pinMode(greenLED, OUTPUT);

void loop() {

long a = 1023 - analogRead(analogPin); //read thermistor value



double tempC = beta / (log((1025.0 * 10 / a - 10) / 10) + beta / 298.0) - 273.0;

double tempF = 1.8 * tempC + 32.0;

lcd.setCursor(0, 0);// set the cursor to column 0, line 0

lcd.print("Cels: ");

lcd.print(tempC);

lcd.print(char(223));//Prints the symbol o for the temperature to the LCD

lcd.print("C");

lcd.setCursor(0, 1);// set the cursor to column 0, line 1

lcd.print("Fahr: ");

lcd.print(tempF);

lcd.print(char(223));//Prints the symbol o for the temperature to the LCD

lcd.print("F");

if(tempF >= 78){

digitalWrite(redLED, HIGH);

6
delay(500);

digitalWrite(redLED, LOW);

delay(500);

}

if(tempF <= 55){

digitalWrite(blueLED, HIGH);

delay(500);

digitalWrite(blueLED, LOW);

delay(500);

}

if(tempF >= 65 && tempF <= 78 ){

digitalWrite(greenLED, HIGH);

delay(500);

digitalWrite(greenLED, LOW);

delay(500);

delay(200);

You might also like