PDA

View Full Version : Arduino Tutorial: 2 Sensor Temperature Display



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

Fuganater
07-13-2011, 09:25 AM
Oneslowz... how much to make me one? :D

SXRguyinMA
07-13-2011, 12:06 PM
I can make you one, they're cake :D what color LCD do you want? I'll get you a price

Fuganater
07-13-2011, 05:43 PM
Orange would be amazing... hopefully its not too expensive?

Fuganater
07-13-2011, 05:48 PM
And can you use inline sensors?

SXRguyinMA
07-13-2011, 06:31 PM
Red on Black:
http://www.sparkfun.com/products/791

Amber on Black:
http://www.sparkfun.com/products/9054

The sensors would be any standard 2-wire 10k thermistor, which most in-line watercooling temp probes are (I testes the Koolance one I got for Maximum Security, and it is). Alternatively, I've got a ton of the ones from the NZXT Sentry 2 fan controller you can use just as well.

PM me if you're serious about me making one for you :)

crenn
07-13-2011, 06:37 PM
Maybe you should check some of these out: http://www.maxim-ic.com/datasheet/index.mvp/id/2812

Kayin
07-20-2011, 11:33 PM
Dallas one-wires, the industry standard for temp sensors. I need to get me a couple...

CorsePerVita
07-21-2011, 04:08 AM
Curious... anyway to adapt something like this into a standalone setup, say, not attached to a computer?

SXRguyinMA
07-21-2011, 10:05 AM
it is standalone. once you program the arduino that's it, just needs a power source :D

CorsePerVita
07-21-2011, 10:15 AM
That's it? HMMMMmmmmmmmm

SXRguyinMA
07-21-2011, 06:50 PM
yessssir that's it :D

CorsePerVita
07-22-2011, 08:13 AM
So how could I adapt a power source for something like this in say... a setup for a car?

Here's the deal... I really have a specific set of things I want to check on and monitor, however, my challenge is that the "universal" sets that I have found area not only stupid expensive, but aren't really what I'm after. These appear to be programmable, small and compact and easy to do.

How much would it be to make one and how could I go about adapting this into something like a 12v setup even though these appear to be 5v? The other reason these are super appealing is because the little displays are small (which is all I really need) and easy to customize which would be.... tada... awesome for a small dash.

SXRguyinMA
07-22-2011, 02:14 PM
http://hackaday.com/2011/04/26/enhance-your-key-fob-via-can-bus-hacking/

You can make something up and use a 5v regulator :D

CorsePerVita
07-24-2011, 06:07 PM
http://hackaday.com/2011/04/26/enhance-your-key-fob-via-can-bus-hacking/

You can make something up and use a 5v regulator :D

THAT is pretty cool! You guys are awesome. I think i need to order one of these kits and play around. I wonder if you can make a half accurate speedometer out of them.