Temperature sensor calibration

Hello All, I’m using a AD22100 temperature sensor. Simple little thing, 5vdc, ground, and a dataline out. I’ve got the 1K resistor and .1 cap in the dataline as shown on datasheet.

That’s the code, at 70ºF to 110ºF it tracks a thermometer nicely, but as the temperature rises above 120ºF it keeps reading lower and lower. By 150ºF it’s 5ºF low, and by 250ºF the sensor is 25ºF low.

I think the following is the code concerning the calculations.

// in the declarations section
int temp_pin = 5;
int temp = 0.0;
int span = 20;

void loop(){

int tempraw = 0;
float tempV = 0;
float tempC = 0;
int tempF = 0;

// read the value on analog input span times then divide by the number of span for average.
for (int i = 0; i < span; i++)

tempraw = tempraw+analogRead(temp_pin);
tempraw = tempraw / span;
tempV = ((tempraw * 5.02) / 1024.0); //using 5.02 since analogReference is set to Default of 5
tempC = ((tempV-1.375) / .0225); //Seems to be a 1.375 offset and a 22.5mV/C from spec sheet.
tempF = ((tempC*1.8)+32); //convert to F.


is the datasheet from DigiKey - can anyone help me get the code so the temperature will read more correct at higher temperatures? As long as it’s only ±3 to 5ºF off would be great.

Thanks to all for their help,

Ken H>

How about....

a) Run a series of tests... to see if error is consistent, and to build table of sensor's true, vs theoretical, performance.

Then, if performance is consistent even if not strictly according to the datasheet's promises, just build some correction in via software....

//fill TtureRaw from sensor...

TtureRaw=(whatever you need to do to read it);

//and then "build" TtureToDisplay...

TtureToDisplay=TtureRaw; if (TtureRaw > 100){TtureToDisplay=TtureToDisplay+1;}; if (TtureRaw > 130){TtureToDisplay=TtureToDisplay+3;}; if (TtureRaw > 180){TtureToDisplay=TtureToDisplay+5;};

Crude.. but do you need elegance, or the job done?

Thanks for the input - that was something along the lines of what I was considering, but wished to make sure I wasn't missing something that prevented the sensor from reading correctly - maybe I had the formula wrong or something.

Thanks for the input.

Ken H>

The accuracy of the sensor is +-2% so you should be able to meet your spec.

I think your problem is the setup you are using to heat the temperature sensor. Since the error is increasing and going more negative I suspect that the sensor is not at the temperature you believe it is.

An easy way to test and calibrate the sensor is to do a freezing point and boiling point calibration. Place the sensor in an ice-water bath, let the temperature reading stabilize and take your reading. Place the sensor in a boiling water bath, let the temperature stabilize and take your reading. I would do the measurements with a multimeter. (we are assuming boiling is 212degF and freezing is 32degF). Make sure the sensor leads are insulated from the water. You could use distilled water.

This will verify your sensor is working. Since the accuracy is within your requirements you shouldn't need to apply a correction equation. If you want additional accuracy do a linear correction y=mx+b

In your application you need to make sure you have allowed sufficient time for the temperature sensor to reach equilibrium. The amount of time depends on the thermal mass of the sensor and the manner in which it interfaces to the device you are trying to measure. Higher temperatures require longer times.

If the sensor is not thermally insulated you can get a thermal gradient. This will make your readings lower than the actual reading.

(* jcl *)

www: http://www.wiblocks.com twitter: http://twitter.com/wiblocks blog: http://luciani.org

Thank you for the comment - I'm checking temperature of the sensor with a digital thermometer that has been checked just as you mention - boiling water and ice bath.

I am not able to get the probe right next to the sensor, but close. This is in a laminator - the sensor is screwed to the aluminum frame that contains the heat strip, the thermometer tip is checking the temp of the rollers - I would have expected the rollers to be a bit less - not more - than the sensor temp.

I really think I have the wrong formula for converting the temperature from volts to degrees C.

As mentioned before, I "could" do a correction table and keep it pretty close, but darn - it just seems like I should be able to get a ±3 to 5ºF reading from the sensor without a "fudge" factor. I guess "fudge" does work :)

Thanks for the suggestions and help - I'm new at this coding stuff and just learning. If someone can look at the datasheet and give me the correct formula would be GREAT!!

73 de Ken H>

The error table on page eight shows a worst case error of ±4degC (uncalibrated).

The problem is in the mounting of the sensor. You either have a thermal gradient
across the sensor or you are not giving the sensor enough time to reach equilibrium.
The higher the temperature the larger the error. The sensor will always be below
the actual value.

How is the sensor thermally fastened to the frame? Is there thermal grease or epoxy
between the sensor and the frame? Without good thermal conduction you will
read low. I do not recall which side of the case the die is on.

If you have an additional AD22100 you could verify it in the baths. I would guess
that the sensor is good and it is an application problem.

The formula is on page seven.

(* jcl *)

I think I don't fully understand the formula:

VOUT = (V+/5 V) × (1.375 V + 22.5 mV/°C × TA)

The (V+/5V) - is that the supply voltage to the sensor? then divided by 5V- so if +5vdc is supply to the sensor, that that would be "1"? then multiply by (1.375 V + 22.5 mV/°C x Ta) - is that 1.375 vdc? I'm not sure exactly what I should be doing with this. I saw it before and didn't understand it at all. From this I got the 1.375 offset, and 22.5mV/ºC.

Just what do I do with this? Remember I came up with; (tempV-1.375) / .0225) and it's not just exactly correct.

Thank you for taking the time to look at this and share your knowledge.

Ken H>

V+ is the power supply voltage. For a 5V system (V+/5V) does equal one.

Vout = (V+/5V) * (1.375V + 22.5mV / degC * T) Vout - 1.375V = 22.5mV/degC * T . . T = (Vout - 1.375V) / 0.0225V/degC

Your formula looks correct to me. You also said the temperature tracks from 70-110degF. I am guessing your temperature sensor is at a lower temperature than you think as the temperature increases. Either a thermal capacitance or thermal resistance issue.

(* jcl *)

You could use distilled water.

Just thought I'd add that true distilled water doesn't boil, as there are no imperfections. You could still measure it with a thermometer though.

Thanks for the confirmation of my formula for calculating temperature. I “though” it was valid, but wasn’t sure. Thanks.

You could well be correct the sensor is not at the temp I am expecting. The sensor is a TO-92 package with the flat side clamped to the same aluminum frame where the factory temperature switch was clamped. I’m checking the temperature of the rollers with the digital thermometer. I’d expect the aluminum frame about the same temperature as the rollers. Reason: when power is removed from heat strips the frame temperature continunes to increase another 5 to 8ºF - the rollers track this same temperature increase nicely leading me to think the frame and rollers are about the same temperature.

I was surprised the amount of temperature increase after power was removed - I expect it is due to mass of the aluminum frame.

Good comment on distilled water - while I knew that on a theory level, I’ve never tried it - need to try that sometime. I wonder if a gallon of distilled water is “pure” enought for the test?

Again, thanks for the help.

Ken H>

What kind of thermal compound do you have between the flat side of the TO-92 and the plate? If you have nothing there it could explain all of the error. Thermally conductive epoxy is recommended in the datasheet.

I do not recall which side of the case the sensor is mounted on. I would assume the flat side too. I always liked the small metal cans. Good thermal conduction and a reasonable small mass. Unfortunately they probably aren't made anymore.

(* jcl *)

I used that white paste used on heat sink for transistors and stuff. I wasn't really sure it was needed, but had it on hand and figured "what the heck".

Thanks for all your help,

Ken H>

The greese may not work since I doubt the sensor flat surface is flat. The datasheet recommends thermal epoxy or glue. Unfortunately that make replacement more difficult.

(* jcl *)