LM35 thermo sensor

Hi,

I am struggling to get the correct data from LM35 but failed.
I use Arduino Uno with CH340.

It is quite simple but when I try to read the value, it shows 213degree centigrade... where my thermometer says 26degree centigrade.....

I only connected LM35 to A0, 5V+, and GND.
Did i miss something?

When I add analogReference(INTERNAL), it shows much larger numbers....

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
int tempSensor=analogRead(A0);
float airTemp=(5.0tempSensor100)/1024;

Serial.print(tempSensor);
Serial.println("unit");
Serial.print(airTemp);
Serial.println("C");
delay(1000);
}

lm35_error.PNG

How exactly are you wiring your grounds, arduino, supply, LM35 - a star-grounding setup is
required for precision analog sensors like this.

LifeOnJeju:
When I add analogReference(INTERNAL), it shows much larger numbers....

Did you amend your formula for the lower reference voltage? If not you'll see numbers about 4.5x as large.

float airTemp=(5.0tempSensor100)/1024;

Doesn't it need an offset here?

wvmarle:
Doesn't it need an offset here?

An offset is not needed. The LM35 is directly calibrated to oC with 10 mV/0C scale factor.

It appears there are different versions of the LM35. Some of which can do negative temperatures, thus need an offset.

The one's that do negative temperature use a negative voltage rail and a pulldown out the output,
and generate negative voltages, so its more involved than that, but they should all work with non-negative centigrade temperatures the same way if you don't care about negative values and don't use a negative
rail.

Have you checked the output voltage directly on the device, and that it's genuinely getting a 0V
ground connection?

wvmarle:
It appears there are different versions of the LM35. Some of which can do negative temperatures, thus need an offset.

There are:
Type Scale Factor Measurement Range
LM35 10 mV/0C -550C to 1500C

LM35A 10 mV/0C -550C to 1500C

LM35C 10 mV/0C -400C to 1100C

LM35CA 10 mV/0C -400C to 1100C

LM35D 10 mV/0C 00C to 1000C

TMP35 10 mV/0C 100 to 1250C

TMP36 10 mV/0C -400C to 1250C

TMP37 20 mV/0C 50C to 1000C

Finding Response Equation fro LM35
case-1. A(-50, -500 mV); B(50, 500 mV); C(T, V mV)

-0.5 - 0.5/-50 - 50 = 0.5 - V/50 - T
==> -1/-100 = 0.5 - V/50 - T
==> 50 - T = 50 - 100V
==> T = 100*V ---> 100*(5/2024)*analogRead(A0)

Case-2. A(25, 250 mV); B(50, 500 mV); C(T, V mV)

0.25 - 0.5/25 - 50 = 0.5 - V/50 - T
==> -0.25/-25 = 0.5 - V/50 - T
==> 50 - T = 50 - 100V
==> T = 100*V ---> 100*(5/2024)*analogRead(A0)