Thermometer Project

Our ongoing project is to build a weather center.  We have discussed the many components involved with creating a weather center.  Now let’s start experimenting with the components we already have available to us.

Using our Sparkfun Inventors Toolkit we will use our potentiometer, LCD Display, and the TMP36 to build a thermometer.

Here are the parts and their use:

  • The TMP36 is used to measure the temperature.  Read more about the TMP36
  • The LCD Will be used to display the temperature in both Celsius and Fahrenheit.
  • The potentiometer is used to control the contrast of the LCD

The first step is to set up your RedBoard and breadboard (note: the Redboard is equivalent to the Arduino UNO for our purposes).  Please use the following diagram to help you connect your components.  Click on the picture to open a larger copy:

Connections for Thermometer Project

Connections for Thermometer Project

Next copy the following code into a new Arduino sketch.  (hint: highlight code from the bottom up to prevent the line number from being copied)

/*Kellenberg Memorial High School Computer Club
 * TMP36 and LCD 
 * The following code is used to read the temperature using the TMP36 sensor
 * and display it on an Liquid Crystal (LCD) display
// include the Liquid Crystal (LCD) library code:
#include <LiquidCrystal.h>

//TMP36 on Analog pin 0
int tmp36=0;

// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
 // set up the LCD's number of columns and rows:
 //Our LCD has is 2 rows of 16 characters
 //lcd.begin initializes the library for our LCD
 lcd.begin(16, 2);

void loop() {

 //First we will read voltage the tmp36 sensor. the 
 //variable tmp36 = 0 for the analog pin it is
 //connected to. 
 int input0=analogRead(tmp36);

 //convert the reading to voltage 
 //This formula converts the number 0-1023 from the ADC into 0-5000mV (= 5V)
 //voltage = (input*5.0)/1024
 float voltage=input0*5.0;

 //converting from 10 mv per degree with 500 mV offset
 //to degrees ((voltage - 500mV) times 100)
 float tempCel=(voltage -.5) * 100;

//now we can convert celcius to fahrenheit
 float tempFar = (tempCel * 9.0 / 5.0) + 32.0;

//Set the LCD to the top line first position (0,0)
// (position,line)
//display the temperature in degrees centigrade
 lcd.print("Temp (c) = ");
//set the LCD cursor to the next line first position (0,1) 
// (position,line)
 lcd.setCursor(0, 1);
//display the temperature in degrees fahrenheit 
 lcd.print("Temp (f) = ");
//wait for one second to keep the display from flashing
 delay (1000*1);

Once you have copied and pasted the code, compile it and upload it to your RedBoard.

mrcampbell / February 15, 2016 / Computer Club, Computer Club Projects