Hey there,
I have a tmp36 interfaced to a Duemilanove. I’m sending the tempF to the serialPort and I’m not sure that it is very accurate.
Is there a way to calibrate this?
#include <LED.h>
int sensorPin = 0;
int greenPin = 2;
int redPin = 3;
//the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
void setup()
{
LED.create(greenPin);
LED.create(redPin);
//LED.create(2);
Serial.begin(9600); //Start the serial connection with the computer
}
void loop()
{
int reading = analogRead(sensorPin);
float voltage = reading * 5.0 / 1024;
Serial.println(voltage);
float temperatureC = (voltage - 0.5) * 100 ;
//converting from 10 mv per degree wit 500 mV offset to degrees ((volatge - 500mV) times 100)
//convert to Fahrenheight
float tempF = (temperatureC * 9 / 5) + 32;
Serial.print(tempF); Serial.println(" degress F");
if(tempF > 70 && tempF < 80 ){
LED.on(greenPin);
LED.off(redPin);
}
if(tempF < 70 | tempF > 80){
LED.on(redPin);
LED.off(greenPin);
}
delay(1000);
}