BioBoard/Documentation/Temperature

From Noisebridge
< BioBoard | Documentation(Difference between revisions)
Jump to: navigation, search
m (Interfacing and measuring)
m (Calibrating a home-built thermometer)
Line 55: Line 55:
  
 
=Calibrating a home-built thermometer=
 
=Calibrating a home-built thermometer=
Everybody needs to be convinced that your homemade instrument is reading what it should - it must be checked for calibration.  Most of us only have two easily accessible, well known, temperatures in the biological region of interest that we can produce - the melting point of ice (0 C) and the boiling point of water (100 C), at sea level - and these are good places to start.  It can be helpful to use another reference temperature measurement technique which has already been calibrated, such as a commercial digital thermometer or thermocouple (plus a reader for it).  If we need to investigate the calibration over a narrower range we can play tricks like add ice to hot water and watch the temperature on both our Arduino output and our reference thermometer slowly drift down together - to see how your DIY measurements compare with the calibrated ones.
+
 
 +
Everybody needs to be convinced that your homemade instrument is reading what it should - it must be checked for calibration.  Most of us only have two easily accessible, well known, temperatures in the biological region of interest that we can produce - the melting point of ice (0°C) and the boiling point of water (100°C), at sea level - and these are good places to start.  It can be helpful to use another reference temperature measurement technique which has already been calibrated, such as a commercial digital thermometer or thermocouple (plus a reader for it).  If we need to investigate the calibration over a narrower range we can play tricks like add ice to hot water and watch the temperature on both our Arduino output and our reference thermometer slowly drift down together - to see how your DIY measurements compare with the calibrated ones.
 +
 
 
=Making it cooler=
 
=Making it cooler=
  

Revision as of 23:38, 29 April 2011

Contents

Introduction to temperature measurements

We are all familiar with the classic simple analog thermometer - the one with the resevoir of mercury or alcohol at the bottom. Unfortunately it is not very easy to convert the (optical) readings from this into a digital format so that we can datalog the information from our experiments. But with the Arduino we can take an analog electrical signal and turn it into a digital one that we can use. We have a number of choices so we need to choose the best ones for the BioBoard, where we'll be doing measurements on biological systems so the temperature range is generally the same as the one for liquid water. We want inexpensive, readily available, sensors that are easy to implement with the Arduino - and have the appropriate range, precision, and accuracy.

Some of the basic types of electronic temperature sensors include:

  • thermocouple - excellent for very wide temperature ranges, up to 2300 C
  • resistance temperature detector (RTD) - used up to 600 C, for industrial application
  • thermistor - generally limited to <150 C, but inexpensive
  • digital temperature sensor (DTS) - the output is linearly proportional to the temperature

The thermocouple may be seem to be the most versatile - the individual sensors can be quite inexpensive (but to make your own can mean buying enough materials for many probes) and the range large - but the millivolt output requires an amplifier (~$18) to make them compatible with the Arduino, and they have a greater range than we need. RTDs are becoming increasingly common for some applications but require a bridge circuit, and are not as inexpensive or commonly available as we would like. We chose to focus on both the thermistor and the DTS because they cover the temperature range of choice well, they are inexpensive, and they can be implemented on the Arduino easily - you get two choices, just in case you have a preference, or one is more easily available than the other..

Building a thermometer

Is this the place where we describe the whole waterproof probe construction - aspects besides the basic sensor?

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 traditional thermometers, and so 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

On a breadboard build your simple resistive divider circuit, which looks like this:


Since your temperature probe will be exposed to moisture or liquid water, it is best to encase it in a waterproof sheath - a good way to do it might be to place it in a plastic tube and seal both the thermistor's active portion and the wires coming out the far end with silicone aquarium sealant. Leave the tip of the thermistor exposed, so that you will have a good response time.

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

Remember that the Arduino has a digital output with 10 bit (1024) resolution so 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, so we can expect the digital output to be 1024/2 or 512. 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 most general equation is:

1/T= A + B*ln(R/Rt) + C*ln(R/Rt)2 + D*ln(R/Rt)3

but check which one is appropriate for the material constants on your datasheet (the one above is the right one for Vishay thermistors).

Calibrating a home-built thermometer

Everybody needs to be convinced that your homemade instrument is reading what it should - it must be checked for calibration. Most of us only have two easily accessible, well known, temperatures in the biological region of interest that we can produce - the melting point of ice (0°C) and the boiling point of water (100°C), at sea level - and these are good places to start. It can be helpful to use another reference temperature measurement technique which has already been calibrated, such as a commercial digital thermometer or thermocouple (plus a reader for it). If we need to investigate the calibration over a narrower range we can play tricks like add ice to hot water and watch the temperature on both our Arduino output and our reference thermometer slowly drift down together - to see how your DIY measurements compare with the calibrated ones.

Making it cooler

Geeking out

Links

[1] general thermistor reference

Personal tools