Difference between revisions of "BioBoard/Documentation/Temperature"

From Noisebridge
Jump to: navigation, search
Line 14: Line 14:
 
A thermistor is a type of resistor which has a very well known dependence of the resistance on temperature, and the change is quite steep so that we can resolve small differences in temperature. We are using them in place of thermometers, and they are sometimes referred to a "resistance thermometers" - they are inexpensive, easy to find, and are '''very''' easy to interface to the Arduino.  They are specified mainly by their room temperature (25 C) resistance and a common value is 10 kOhms.  If many models are available, like from a major electronics supply house, you can also specify the tolerance and you can choose from different shapes and sizes (the size of a match head is good for starters).  As well, there are two general types of thermistors - ones that increase in resistance with increasing temperature (PTC) and those that decrease in temperature with increasing temperature (NTC).
 
A thermistor is a type of resistor which has a very well known dependence of the resistance on temperature, and the change is quite steep so that we can resolve small differences in temperature. We are using them in place of thermometers, and they are sometimes referred to a "resistance thermometers" - they are inexpensive, easy to find, and are '''very''' easy to interface to the Arduino.  They are specified mainly by their room temperature (25 C) resistance and a common value is 10 kOhms.  If many models are available, like from a major electronics supply house, you can also specify the tolerance and you can choose from different shapes and sizes (the size of a match head is good for starters).  As well, there are two general types of thermistors - ones that increase in resistance with increasing temperature (PTC) and those that decrease in temperature with increasing temperature (NTC).
 
===What you need===
 
===What you need===
Besides your Arduino, all you need is a standard resistor with a value that is the same as the room temperature resistance of your thermistor.  You'll be building a "voltage divider" so that you can use the 5 VDC output of the Arduino and have good resolution over the full temperature range of the thermistor (usually something like -40 C to +125 C, perfect for biological experiments).  For our examples we'll be using a 10 kOhm NTC thermistor (Sparkfun and Hacktronics carry these) with a 10 kOhm resistor for the bridge.  
+
Besides your thermistor, all you need is a standard resistor with a value that is the same as the room temperature resistance of your thermistor.  You'll be using the standard one to build a "resistive divider" so that you can use the 5 VDC output of the Arduino and have good resolution over the full temperature range of the thermistor (usually something like -40 C to +125 C, perfect for biological experiments).  For our examples we'll be using a 10 kOhm NTC thermistor (Sparkfun and Hacktronics carry these) with a 10 kOhm resistor for the bridge.  
 
===How to build it===
 
===How to build it===
 +
A simple resistive divider circuit looks like this:
  
 +
For the special case where R1 is the same as R2 (that's our situation at room temperature), the voltage will be half of the Arduino's 5 VDC, and since the Arduino has 10 bit (1024) resolution we can expect the digital output to be 1024/2 or 512.
 
===Things to keep in mind===
 
===Things to keep in mind===
 +
R1 is the thermistor in the circuit, so your standard resistor (R2) is the one tied to the Arduino ground.
 +
=Interfacing and measuring=
 +
The code looks like this:
  
=Interfacing and measuring=
+
double Thermistor(int RawADC) {
 +
double Temp;
 +
float resistance = (10240000/RawADC) - 10000;    //calculate from voltage divider, for 10k resistor
 +
Temp = log(resistance/10000);
 +
// calculate the temperature, in K, using 4 thermistor model/material specific parameters A, B, C, D
 +
// here we use the values for the Sparkfun/Hacktronics version of the Vishay 10k NTC thermistor (from datasheet)
 +
Temp = 1 / (0.003354016 + 0.0002569850 * Temp + 0.000002620131 * Temp * Temp + 0.00000006383091 * Temp * Temp * Temp);
 +
Temp = Temp - 273.15;            // Convert Kelvin to Celsius
 +
// Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celsius to Fahrenheit
 +
return Temp;
 +
}
 +
 
 +
and the math part is the Steinhart-Hart equation, which is the relationship between the resistance and the temperature for a thermistor with certain materials properties.  On the manufacturer's datasheet for your specific resistor you will find a list of 4 constants - usually A, B, C, and D - that go with it.  The equation is:
 +
1/T= A + B*ln(R/Rt) + C*ln(R/Rt)2 + D*ln(R/Rt)3
  
 
=Calibrating a home-built thermometer=
 
=Calibrating a home-built thermometer=

Revision as of 05:04, 29 April 2011

Introduction to temperature

Building a thermometer

Digital thermometer

What you need

How to build it

Things to keep in mind

Thermistor

A thermistor is a type of resistor which has a very well known dependence of the resistance on temperature, and the change is quite steep so that we can resolve small differences in temperature. We are using them in place of thermometers, and they are sometimes referred to a "resistance thermometers" - they are inexpensive, easy to find, and are very easy to interface to the Arduino. They are specified mainly by their room temperature (25 C) resistance and a common value is 10 kOhms. If many models are available, like from a major electronics supply house, you can also specify the tolerance and you can choose from different shapes and sizes (the size of a match head is good for starters). As well, there are two general types of thermistors - ones that increase in resistance with increasing temperature (PTC) and those that decrease in temperature with increasing temperature (NTC).

What you need

Besides your thermistor, all you need is a standard resistor with a value that is the same as the room temperature resistance of your thermistor. You'll be using the standard one to build a "resistive divider" so that you can use the 5 VDC output of the Arduino and have good resolution over the full temperature range of the thermistor (usually something like -40 C to +125 C, perfect for biological experiments). For our examples we'll be using a 10 kOhm NTC thermistor (Sparkfun and Hacktronics carry these) with a 10 kOhm resistor for the bridge.

How to build it

A simple resistive divider circuit looks like this:

For the special case where R1 is the same as R2 (that's our situation at room temperature), the voltage will be half of the Arduino's 5 VDC, and since the Arduino has 10 bit (1024) resolution we can expect the digital output to be 1024/2 or 512.

Things to keep in mind

R1 is the thermistor in the circuit, so your standard resistor (R2) is the one tied to the Arduino ground.

Interfacing and measuring

The code looks like this:

double Thermistor(int RawADC) {

double Temp;
float resistance = (10240000/RawADC) - 10000;    //calculate from voltage divider, for 10k resistor
Temp = log(resistance/10000);

// calculate the temperature, in K, using 4 thermistor model/material specific parameters A, B, C, D // here we use the values for the Sparkfun/Hacktronics version of the Vishay 10k NTC thermistor (from datasheet)

Temp = 1 / (0.003354016 + 0.0002569850 * Temp + 0.000002620131 * Temp * Temp + 0.00000006383091 * Temp * Temp * Temp);
Temp = Temp - 273.15;            // Convert Kelvin to Celsius

// Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celsius to Fahrenheit

return Temp;

}

and the math part is the Steinhart-Hart equation, which is the relationship between the resistance and the temperature for a thermistor with certain materials properties. On the manufacturer's datasheet for your specific resistor you will find a list of 4 constants - usually A, B, C, and D - that go with it. The equation is: 1/T= A + B*ln(R/Rt) + C*ln(R/Rt)2 + D*ln(R/Rt)3

Calibrating a home-built thermometer

Making it cooler

Geeking out

Links