BioBoard/Documentation/Temperature

From Noisebridge
Jump to navigation Jump to search

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

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 equation is: 1/T= A + B*ln(R/Rt) + C*ln(R/Rt)2 + D*ln(R/Rt)3

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