Oneslowz28
06-11-2010, 11:45 PM
Using your Arduino to read and display temperature is quite simple. For my Arduino Controlled PC Watercooling Information Center I needed to be able to read the temperature from 2 Bitspower Temperature Stop Fittings. After probing the temp sensors with my multi-meter I was able to tell that they were simple 10k thermistors. A quick search on the Arduino site gave me a starting point and below is the finished product.
http://thebestcasescenario.com/oneslowz28/personal/workingtempsensors.jpg
You need:
1x Arduino (http://www.seeedstudio.com/depot/seeeduino-v212-fully-assembled-arduino-compatible-p-389.html?cPath=27) or Arduino compatible dev board.
2x 10k resistors (http://www.protostack.com/index.php?main_page=product_info&cPath=14_31&products_id=37)
2x 10k thermistors (http://www.sparkfun.com/commerce/product_info.php?products_id=250)
1x 16x2 parallel LCD (http://www.seeedstudio.com/depot/lcd-162-characters-green-yellow-back-light-p-62.html?cPath=8)
1x 10k trim pot (http://www.goldmine-elec-products.com/prodinfo.asp?number=G9041)
30x jumper wires (http://www.satistronics.com/solderless-breadboard-jumper-cable-wires-kit-qty70_p2176.html).
1x Bread Board (http://www.satistronics.com/2860-tiepoint-solderless-breadboard-includes-jumpwires-syb500_p2074.html)
http://thebestcasescenario.com/oneslowz28/personal/Arduino_temp_display_layout.jpg
Connecting the Temperature sensors.
Lets start by connecting the 2 temperature sensors. To do this we need to connect 1 leg of each temperature sensor (or thermistor) to analog pins 0 and 1. Then you must connect each remaining leg to a 10k resistor and then to one of the arduinos ground pins.
Connecting the LCD to the Arduino.
Lets start by connecting power to the backlight. The 10k trimpot will be used to control the LCD's contrast.
1.Connect LCD pin 16 to the Arduino's ground pin.
2.Connect LCD pin 15 to the Arduino's 5v pin.
3.Connect the 10K trimpots wiper (center pin) to LCD pin 3.
4.Connect one of the remaining 2 legs of the trimpot to the Arduino's 5v pin.
5.Conned the last remaining leg of the trim pot to the Arduino's ground pin.
Now we can connect the data lines from the LCD to the Arduino.
1.Connect LCD pin 1 to the Arduino's ground pin.
2.Connect LCD pin 2 to the Arduino's 5V pin.
3.Connect LCD pin 4 RS to Arduino digital pin 7.
4.Connect LCD pin 5 RW to the Arduino's ground pin. (This is tied to ground because we are not reading any information from the LCD)
5.Connect LCD pin 6 EN to Arduino digital pin 8
6.Connect LCD pin 11 DB4 to Arduino digital pin 9
7.Connect LCD pin 12 DB5 to Arduino digital pin 10
8.Connect LCD pin 13 DB6 to Arduino digital pin 11
9.Connect LCD pin 14 BD7 to Arduino digital pin 12
Here is the the code. Thanks to OvRiDe for helping me with this.
//Arduino Controlled 2 sensor Temp Display. Uses 2 10k thermistors and a 10k pull up resistor.
//Code By Charles Gantt http://themakersworkbench.com
//Code based on Thermistor2 Elaborate code found here http://www.arduino.cc/playground/ComponentLib/Thermistor2
//This code was developed as a side project to my Call of Duty Modern Warfare 2 Case mod found at http://www.thebestcasescenario.com/forum/showthread.php?t=21320
#include <LiquidCrystal.h>
#include <math.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
double Thermistor(int RawADC) {
long Resistance;
double Temp;
Resistance=((10240000/RawADC) - 10000);
Temp = log(Resistance);
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15;
return Temp;
}
void printDouble(double val, byte precision) {
lcd.print (int(val));
if( precision > 0) {
lcd.print(".");
unsigned long frac, mult = 1;
byte padding = precision -1;
while(precision--) mult *=10;
if(val >= 0) frac = (val - int(val)) * mult;
else frac = (int(val) - val) * mult;
unsigned long frac1 = frac;
while(frac1 /= 10) padding--;
while(padding--) Serial.print("0");
lcd.print(frac,DEC) ;
}
}
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
}
#define ThermistorPIN 0
#define Thermistor2PIN 1
double temp;
void loop() {
lcd.setCursor(0, 0);
temp=Thermistor(analogRead(ThermistorPIN));
lcd.print("Sensor 1 ");
printDouble(temp,2);
lcd.print((char)223);
lcd.print("C ");
lcd.setCursor(0, 1);
temp=Thermistor(analogRead(Thermistor2PIN));
lcd.print("Sensor 2 ");
printDouble(temp,2);
lcd.print((char)223);
lcd.print("C ");
delay(100);
}
Code sources
http://www.arduino.cc/playground/ComponentLib/Thermistor2
http://www.arduino.cc/en/Reference/LiquidCrystal
http://thebestcasescenario.com/oneslowz28/personal/workingtempsensors.jpg
You need:
1x Arduino (http://www.seeedstudio.com/depot/seeeduino-v212-fully-assembled-arduino-compatible-p-389.html?cPath=27) or Arduino compatible dev board.
2x 10k resistors (http://www.protostack.com/index.php?main_page=product_info&cPath=14_31&products_id=37)
2x 10k thermistors (http://www.sparkfun.com/commerce/product_info.php?products_id=250)
1x 16x2 parallel LCD (http://www.seeedstudio.com/depot/lcd-162-characters-green-yellow-back-light-p-62.html?cPath=8)
1x 10k trim pot (http://www.goldmine-elec-products.com/prodinfo.asp?number=G9041)
30x jumper wires (http://www.satistronics.com/solderless-breadboard-jumper-cable-wires-kit-qty70_p2176.html).
1x Bread Board (http://www.satistronics.com/2860-tiepoint-solderless-breadboard-includes-jumpwires-syb500_p2074.html)
http://thebestcasescenario.com/oneslowz28/personal/Arduino_temp_display_layout.jpg
Connecting the Temperature sensors.
Lets start by connecting the 2 temperature sensors. To do this we need to connect 1 leg of each temperature sensor (or thermistor) to analog pins 0 and 1. Then you must connect each remaining leg to a 10k resistor and then to one of the arduinos ground pins.
Connecting the LCD to the Arduino.
Lets start by connecting power to the backlight. The 10k trimpot will be used to control the LCD's contrast.
1.Connect LCD pin 16 to the Arduino's ground pin.
2.Connect LCD pin 15 to the Arduino's 5v pin.
3.Connect the 10K trimpots wiper (center pin) to LCD pin 3.
4.Connect one of the remaining 2 legs of the trimpot to the Arduino's 5v pin.
5.Conned the last remaining leg of the trim pot to the Arduino's ground pin.
Now we can connect the data lines from the LCD to the Arduino.
1.Connect LCD pin 1 to the Arduino's ground pin.
2.Connect LCD pin 2 to the Arduino's 5V pin.
3.Connect LCD pin 4 RS to Arduino digital pin 7.
4.Connect LCD pin 5 RW to the Arduino's ground pin. (This is tied to ground because we are not reading any information from the LCD)
5.Connect LCD pin 6 EN to Arduino digital pin 8
6.Connect LCD pin 11 DB4 to Arduino digital pin 9
7.Connect LCD pin 12 DB5 to Arduino digital pin 10
8.Connect LCD pin 13 DB6 to Arduino digital pin 11
9.Connect LCD pin 14 BD7 to Arduino digital pin 12
Here is the the code. Thanks to OvRiDe for helping me with this.
//Arduino Controlled 2 sensor Temp Display. Uses 2 10k thermistors and a 10k pull up resistor.
//Code By Charles Gantt http://themakersworkbench.com
//Code based on Thermistor2 Elaborate code found here http://www.arduino.cc/playground/ComponentLib/Thermistor2
//This code was developed as a side project to my Call of Duty Modern Warfare 2 Case mod found at http://www.thebestcasescenario.com/forum/showthread.php?t=21320
#include <LiquidCrystal.h>
#include <math.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
double Thermistor(int RawADC) {
long Resistance;
double Temp;
Resistance=((10240000/RawADC) - 10000);
Temp = log(Resistance);
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp - 273.15;
return Temp;
}
void printDouble(double val, byte precision) {
lcd.print (int(val));
if( precision > 0) {
lcd.print(".");
unsigned long frac, mult = 1;
byte padding = precision -1;
while(precision--) mult *=10;
if(val >= 0) frac = (val - int(val)) * mult;
else frac = (int(val) - val) * mult;
unsigned long frac1 = frac;
while(frac1 /= 10) padding--;
while(padding--) Serial.print("0");
lcd.print(frac,DEC) ;
}
}
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
}
#define ThermistorPIN 0
#define Thermistor2PIN 1
double temp;
void loop() {
lcd.setCursor(0, 0);
temp=Thermistor(analogRead(ThermistorPIN));
lcd.print("Sensor 1 ");
printDouble(temp,2);
lcd.print((char)223);
lcd.print("C ");
lcd.setCursor(0, 1);
temp=Thermistor(analogRead(Thermistor2PIN));
lcd.print("Sensor 2 ");
printDouble(temp,2);
lcd.print((char)223);
lcd.print("C ");
delay(100);
}
Code sources
http://www.arduino.cc/playground/ComponentLib/Thermistor2
http://www.arduino.cc/en/Reference/LiquidCrystal