I am using a Duemilanova to process temperatures from multiple sensors.
I chose the tmp36 at $2 each from LadyAda. The raw output from the AtoDs is variable as another writer suggested - plus/minus 2 degC, but an exponential smoother with a "time constant" of 100 samples reveals the useful accuracy of the TMP36 - to calibrate, I wrapped three sensors together in aluminum foil to keep the temp constant for all three sensors, which shows the inherent accuracy of my three sensors as +0.32 degC, -0.65 degC and +0.10 degC.
The TMP36 needs a 3 wire hookup it's true: but a 50 ft hank of 4-conductor telephone solid wire is like $2 or so, and that's easy to handle.
Because my prime interest is differential temperatures around room temperature, and switching in fans from a warmer attic, or a cooler basement or outside; and running an attic exhaust fan when necessary, it was easy to provide a calibration constant for each sensor so they track within about 40 millidegreesC or better.
Here's the front end code
//TMP36 Pin Variables
/*
- the analog input pin is specified for four TMP36 temp sensors
- the TMP36 resolution is 10 mV / degree centigrade with a
- 500 mV offset to allow for the zero input at -50 degC
/
int sensorPin0 = 0;
int sensorPin1 = 1;
int sensorPin2 = 2;
int sensorPin3 = 3;
float smoothTemp0 = 20.0 ;//starting value for exp smoother 0
float smoothTemp1 = 20.0 ;//starting value for exp smoother 1
float smoothTemp2 = 20.0 ;//starting value for exp smoother 2
float smoothTemp3 = 20.0 ;//starting value for exp smoother 3
float calConst0 = -0.320 ;//cal const for sensor 0
float calConst1 = 0.650 ;//cal const for sensor 1
float calConst2 = -0.100 ;//cal const for sensor 2
float calConst3 = -0.000 ;//cal const for sensor 3
/ - setup() - this function runs once at power up and it is
- used to initialize the serial connection with the development computer
*/
void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
delay(500);
}
void loop() // continuous loop
{
int reading0 = analogRead(sensorPin0);
int reading1 = analogRead(sensorPin1);
int reading2 = analogRead(sensorPin2);
int reading3 = analogRead(sensorPin3);
// convert that 0-1023 reading to a voltage
float voltage0 = reading0 * 4.900 / 1024;
float voltage1 = reading1 * 4.900 / 1024;
float voltage2 = reading2 * 4.900 / 1024;
float voltage3 = reading3 * 4.900 / 1024;
// print out the voltage at sensor0
Serial.print(voltage0); Serial.println("Sensor0 volts");
// now print out the temperature
float temperature0C = (voltage0 - 0.5) * 100 + calConst0 ; //converting from 10 mv per degree with 500 mV offset
//and sensor correction to degrees ((voltage - 500mV) times 100)
float tempout0 = 0.010 * temperature0C + 0.990 * smoothTemp0 ; //exp smooth over 100 samples
Serial.print(tempout0); Serial.println(" Sensor 0 degrees C");
float temperature1C = (voltage1 - 0.5) * 100 + calConst1 ; //converting from 10 mv per degree with 500 mV offset
//to degrees ((voltage - 500mV) times 100)
float tempout1 = 0.010 * temperature1C + 0.990 * smoothTemp1 ; //exp smooth over 100 samples
Serial.print(tempout1); Serial.println(" Sensor 1 degrees C");
float temperature2C = (voltage2 - 0.5) * 100 + calConst2 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((voltage - 500mV) times 100)
float tempout2 = 0.010 * temperature2C + 0.990 * smoothTemp2 ; //exp smooth over 100 samples
Serial.print(tempout2); Serial.println(" Sensor 2 degrees C");
float temperature3C = (voltage3 - 0.5) * 100 + calConst3 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((voltage - 500mV) times 100)
float tempout3 = 0.010 * temperature3C + 0.990 * smoothTemp3 ; //exp smooth over 100 samples
Serial.print(tempout3); Serial.println(" Sensor 3 degrees C");
// now convert to Fahrenheit
float temperatureF = (temperature0C * 9 / 5) + 32;
Serial.print(temperatureF); Serial.println(" Sensor 0 degrees F");
Serial.println(" *** ") ;
smoothTemp0 = tempout0 ; // update smoothing integrators for next pass
smoothTemp1 = tempout1 ;
smoothTemp2 = tempout2 ;
smoothTemp3 = tempout3 ;
delay(5000); //waiting 5 second
}
Regards
Brian Whatcott Altus OK