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;
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,