Thermistors are inexpensive and easy to use for temperature measurement. The only complicated part is the math used to translate the voltage output level to the measured temperature, but we have provided that for you in the Arduino sketch below. Software used in this tutorial can be downloaded here: Arduino Thermistor Software
Hardware used in this tutorial: - Thermistor temperature Sensor (you also need a 10k resistor). - Arduino board (Uno, Mega, Duemilanove, etc.) Instructions: ----- If this is your first Arduino project, first go through our “Arduino: Getting Started” tutorial. ----- We will use an LCD to read the temperature from the thermistor. Follow our Arduino LCD tutorial to get the LCD working with your Arduino. If you don't want to use an LCD to get the temperature readings, you can always just change the sketch to use the Arduino's serial connection to your computer to read the temperature from the serial monitor. Use your solderless breadboard to make the thermistor connections: Software:
Download the example Arduino thermistor software here, and unzip the file. You will now have a folder called “arduino_thermistor” Start the Arduino software and load the Arduino thermistor example program by clicking File->Sketchbook->Open Navigate to the arduino_thermistor folder and select the “arduino_thermistor.pde” file. Transfer the Arduino thermistor sketch to your Arduino board by clicking the “Upload to I/O board” button. After uploading, you should see the current temperature displayed on the LCD. Here is the code:
/* Arduino thermistor example software Tutorial: http://www.hacktronics.com/Tutorials/arduino-thermistor-tutorial Copyright (c) 2010 Mark McComb, hacktronics LLC License: http://www.opensource.org/licenses/mit-license.php (Go crazy) */
#include <LiquidCrystal.h> #include <math.h>
/*
LCD Connections: rs (LCD pin 4) to Arduino pin 12 rw (LCD pin 5) to Arduino pin 11 enable (LCD pin 6) to Arduino pin 10 LCD pin 15 to Arduino pin 13 LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2 */
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); int backLight = 13; // pin 13 will control the backlight
void setup(void) { pinMode(backLight, OUTPUT); digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off. lcd.begin(20, 4); // rows, columns. use 16,2 for a 16x2 LCD, etc. lcd.clear(); // start with a blank screen lcd.setCursor(0,0); // set cursor to column 0, row 0 }
double Thermister(int RawADC) { double Temp; // See http://en.wikipedia.org/wiki/Thermistor for explanation of formula Temp = log(((10240000/RawADC) - 10000)); Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp)); Temp = Temp - 273.15; // Convert Kelvin to Celcius return Temp; }
void printTemp(void) { double fTemp; double temp = Thermister(analogRead(0)); // Read sensor lcd.clear(); lcd.setCursor(0,0); lcd.print("Temperature is:"); lcd.setCursor(0,1); lcd.print(temp); lcd.print(" C / "); fTemp = (temp * 1.8) + 32.0; // Convert to USA lcd.print(fTemp); lcd.print(" F"); if (fTemp > 68 && fTemp < 78) { lcd.setCursor(0,3); lcd.print("Very comfortable"); } }
void loop(void) { printTemp(); delay(1000); }
Happy hacking! Send feedback on this tutorial here.
|