Hi,
I have 3 LM35DTs hooked up to my arduino inputs A0-A2. When I go to read their values I get significantly different results for each sensor (example: 16, 26, 21), even though their touching each other, meaning their temperatures should be identical. Interestingly, even if I move a sensor from one input to anther, the values don't change, suggesting that it's not a variation in the sensors. Any ideas of what could be causing these issues?
Here is the code I use to read the sensors:
I just call it 3 times with a different sensor_pin value.
float readTemp(int sensor_pin){
// set reference voltage to 1.1V
analogReference(INTERNAL);
// make sure it had enough time to switch
delay(10);
float refV = 1.1;
// take 100 readings and get the average
float accumulatorRaw = 0;
for (int i = 0; i < 100; i++){
accumulatorRaw += analogRead(sensor_pin);
}
float averageRaw = accumulatorRaw / float(100);
// LM35DT sensor: 0.01V per 1 degree centigrade
float tempValue = ((averageRaw * refV ) / 1024) / 0.01;
return tempValue;
}