Certainly! Glad to be an inspiration! I just hope I'm not steering you down the wrong path with the analog sensors, vs. something like the Dallas 1-wire. You may have better luck with those, I'm not sure. I used one a long time ago interfaced to a serial port on a PC, but never have looked into using them with the Arduino. If you do end up tinkering with them, post back on your results!
One thing that will help your accuracy is to use the 3.3V reference. If you fiddle with this, heed the warning at
Arduino - AnalogReference.
If you notice the graph I posted, the values are jumping all over the place - probably similar to what you're experiencing. That's before I slapped myself for not averaging the values more rapidly than I was. More on that below.
One "trick" I'd read about concerns the fact that a single analog-digital converter (ADC) is multiplexed over all of the analog pins, and when you tell the Arduino to change which pin it is to read from, it takes the sensor a little time to change the voltage seen by the ADC. So, in theory, it helps to change the pin (by doing an analogRead() call with the desired pin), wait 10ms, then do another analogRead() call to get the stabilized reading. Something you wouldn't have to do with the Dallas sensors.
In my code I'm doing the pin switch + stabilization, then reading the sensor 20 times (AVGSENSOR = 20) to get an average. After the average value is computed, it does the math to convert the 3.3V referenced value to degrees Fahrenheit, applies a static offset to compensate for inaccuracy, does a sanity check to make sure the value is within 20-100F, and if so, crams it into an array for a running average. I'm doing this once a second and the running average array spans one minute (AVGCOUNT = 60). So the final values I'm using for reference elsewhere in the code are the sum of all values in the running average array, divided by the number of entries. Seems to work pretty well.
I have three sensors, so I stuck them all in close proximity to each other into the center of a glass of ice water along with a thermo-pen and made adjustments to their values until they read 32F. The thermo-pen was to verify that the temperature right where the sensors were was indeed 32F.
Code:
// Ambient air temperature
analogRead(PIN_TMP36_AMBAIR); // Switch pin on ADC
delay(10); // Stabilize
fAvg = 0;
for(int i=0; i<AVGSENSOR; i++)
fAvg += (float)analogRead(PIN_TMP36_AMBAIR);
fAvg /= AVGSENSOR;
fTmp36Volts = fAvg * 3.3; // Converting that reading to voltage, using 3.3v reference
fTmp36Volts /= 1024.0;
fTempC = (fTmp36Volts - 0.5) * 100 ; // Converting from 10mV/degree with 500 mV offset to degrees ((voltage - 500mV) * 100)
fTempF = (fTempC * 9.0 / 5.0) + 32.0;
fTempF += 0.6; // Manual adjustment to match thermo-pen thermometer
if(fTempF >= 20.0 && fTempF <= 100.0)
fAmbAirTemps[nArrayIndex] = fTempF;
fTempTotal = 0;
nTempCount = 0;
for(int i=0; i<AVGCOUNT; i++)
{
if(fAmbAirTemps[i] != 0)
{
fTempTotal += fAmbAirTemps[i];
nTempCount++;
}
}
gfAvgAmbAirTemp = fTempTotal / (float)nTempCount;