I want to measure atomospheric temperature with arduino sensor i am using is LMT84. data sheet :http://www.ti.com/lit/ds/symlink/lmt84.pdf After uploading following code to arduino board i am getting very high temperature in serial window .I m new in electronics field so i am unable to understand what is error in my code .Ive connected0.1uf cap between vcc and ground,data pin is connected toA1 of arduino.
Plz check following code:
const int sensor = A1; // Assigning analog pin A1 to variable 'sensor'
float tempc; //variable to store temperature in degree Celsius
float vout; //temporary variable to hold sensor reading
float vout1; //temporary variable to hold sensor reading
void setup()
{
Serial.begin(9600);
pinMode(sensor, INPUT); // Configuring pin A1 as input
}
void loop()
{
vout = analogRead(sensor);
vout1 = (vout * 500) / 1023;
tempc = vout1; // Storing value in Degree Celsius
Serial.print("LMT84 temp=");
Serial.print(tempc);
Serial.println();
delay(1000);
}
Serial window showing this values::
LMT84 temp=168.13
LMT84 temp=168.13
LMT84 temp=168.64
LMT84 temp=168.89
LMT84 temp=168.13