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.0tempSensor 100)/1024;
Serial.print(tempSensor);
Serial.println("unit");
Serial.print(airTemp);
Serial.println("C");
delay(1000);
}
MarkT
November 26, 2018, 1:39pm
2
How exactly are you wiring your grounds, arduino, supply, LM35 - a star-grounding setup is
required for precision analog sensors like this.
wvmarle
November 26, 2018, 3:35pm
3
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.0tempSensor 100)/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 o C with 10 mV/0 C scale factor.
wvmarle
November 26, 2018, 6:08pm
5
It appears there are different versions of the LM35. Some of which can do negative temperatures, thus need an offset.
MarkT
November 26, 2018, 6:39pm
6
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/0 C -550 C to 1500 C
LM35A 10 mV/0 C -550 C to 1500 C
LM35C 10 mV/0 C -400 C to 1100 C
LM35CA 10 mV/0 C -400 C to 1100 C
LM35D 10 mV/0 C 00 C to 1000 C
TMP35 10 mV/0 C 100 to 1250 C
TMP36 10 mV/0 C -400 C to 1250 C
TMP37 20 mV/0 C 50 C to 1000 C
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)