• Music
  • Hardware
  • Photography
  • Web
  • Story

Thermometer

PreviousPauseNext

Parts

Arduino Experimentation Kit:
http://www.adafruit.com/products/170

LCD Screen:
http://www.adafruit.com/products/399

How To

Temperature Sensor: project 10 in the kit

LCD Screen: http://www.ladyada.net/learn/lcd/charlcd.html

Notes

This arduino-based prototype reads ambient temperature and displays it onto an LCD screen. A basic proof of concept.

The temperature sensor is a transistor that outputs tiny variations in voltage based on temperature, as highlighted in the second photo.

The code below demonstrates how to link between the sensor and the display.

/*
 
 The circuit:
 * LCD RS pin to digital pin 7
 * LCD Enable pin to digital pin 8
 * LCD D4 pin to digital pin 9
 * LCD D5 pin to digital pin 10
 * LCD D6 pin to digital pin 11
 * LCD D7 pin to digital pin 12
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe 
 modified 22 Nov 2010
 by Tom Igoe
 
 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

//TMP36 Pin Variables
int temperaturePin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
                        //the resolution is 10 mV / degree centigrade 
                        //(500 mV offset) to make negative temperatures an option


// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16,2);
}

void loop() {
  float temperature = getVoltage(temperaturePin);  //getting the voltage reading from the temp sensor
  temperature = (temperature - .5) * 100;          //converting from 10 mv per degree wit 500 mV offset
  float fraction = 1.8;                            //conversion fraction from celsius to fahrenheit

  //display celsius temperature on the top line  
  lcd.setCursor(0, 0);
  lcd.print(temperature);
  lcd.print("C");
  
  //display fahrenheit temperature on the bottom line
  lcd.setCursor(0, 1);
  lcd.print((fraction*temperature)+32);
  lcd.print("F");
  
  delay(500);  
  
  // clear screen for the next loop:
  lcd.clear();
}

/*
 * getVoltage() - returns the voltage on the analog input defined by
 * pin
 */
float getVoltage(int pin){
 return (analogRead(pin) * .004882814); //converting from a 0 to 1024 digital range
                                        // to 0 to 5 volts (each 1 reading equals ~ 5 millivolts
}

kai @ think in 3d.net