0

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
1

The Arduino uses an analog voltage as reference. It is default set to the Vcc of the microcontroller, which is about 5 V for an Arduino Uno. The function analogReference can be used to set something else as reference.

When that reference is not precisely 5.0 V, it is impossible to measure a voltage in a accurate way. It is almost never precisely 5.0 V. When using the USB connector to power the Arduino board, it might be somewhere between 4.5 and 5.0 V.

The Arduino Uno has an internal voltage reference of 1.1 V. That is better than using the default 5 V. The actual voltage can be 1.0 to 1.2 V, you have to put the actual value in your sketch.

The LMT84 has an output of 1034 mV at 0°C and 476 mV at 100°C. That means your calculation is not correct. In the datasheet are two ways to calculate the temperature, an accurate formula and a simple calculation.

You can avoid all these problems with a temperature sensor that has a digital interface to the Arduino board. For example the DS18B20. That is a cheap and accurate temperature sensor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.