What's Wrong With LM35 Temperature Sensors

I have purchased off different ebay sites LM35 sensors but none ever work correctly when connected to the 5V supply off a UNO and with the centre sensor tin connected to A0. The connections can't get much simpler and comply with the manufacturer's data.

This connection should output 10mV / degree celcius above 0C.
For example at 23C the TM35 should output 230mV and this should be measurable with a multimeter even without a UNO connected.

There are numerous similar posts complaining about these devices generally being higher than expected voltages that swing widely.

comments?

Typical core of the problem: absolute output vs. ratiometric ADC.

5V from the USB Is often lower than that, so values are miscalculated. Power draw from other peripherals gives fluctuations in Vcc thus fluctuations in the measurement.

They're best read against the internal 1.1V reference - do remember to calibrate that 1.1V.

Basic (no smoothing/averaging) and correct (1.1voltAref instead of default) LM35 example sketch.
Give the LM35 it's own ground wire (not shared).
Leo..

// connect LM35 to 5volt A0 and ground
// calibrate temp by changing the last digit(s) of "0.1039"

const byte tempPin = A0;
float calibration = 0.1039;
float tempC; // Celcius
float tempF; // Fahrenheit

void setup() {
  Serial.begin(9600);
  analogReference(INTERNAL); // use internal 1.1volt Aref
  // change INTERNAL to INTERNAL1V1 for a Mega
}

void loop() {
  tempC = analogRead(tempPin) * calibration; // get temp

  tempF = tempC * 1.8 + 32.0; // C to F
  Serial.print("Temperature is  ");
  Serial.print(tempC, 1); // one decimal place resolution is all you get
  Serial.print(" Celcius  ");
  Serial.print(tempF, 1);
  Serial.println(" Fahrenheit");

  delay(1000); // use a non-blocking delay when combined with other code
}

Read this Reading LM34, LM35, LM335 (LM3x) Temperature Sensors Accurately – Arduino++

@marco_c
"Use the supply voltage for the DAC reference, but measure the supply voltage accurately against the internal reference voltage."
That implies that you could also measure an LM35 with default Aref (and compensate for Aref errors).
That technique might be needed for temp ranges and sensors that produce an output voltage outside the 1.1volt Aref limits, but shouldn't be used for an LM35/0 to 100C or a TMP36/-50C to 50C.
Primary reason not to use default Aref is that it lowers resolution about 5 times (assuming 5volt Arduino).
Leo..

Wawa:
float calibration = 0.1039;

I can't get the figure 0.1039.

calibration factor/gain factor = 100*(1.1/1023.0) = 0.1075

or

calibration factor/gain factor = 100*(1.1/1024.0) = 0.1074

Have you used different value other than 1.1V, which is equal to the DVM reading at the AREF-pin?

GolamMostafa:
I can't get the figure 0.1039.
Have you used different value other than 1.1V, which is equal to the DVM reading at the AREF-pin?

Yes.
1.1volt Aref is never exactly 1.1volt, and is different between boards.
0.1039 works out to about 1.064volt.

I don't measure Aref, but calibrate against a known temperature.
That way you eliminate the 1.1volt error as well as the (0.5C) LM35 factory calibration error.
Leo..

Don't forget about the self-heating aspect of the LM34/35. That is presuming the LM 34/35 purchased from eBay are actually LM34/35 and not just transistors with counterfeit markings.

1 Like

rbright:
comments?

Show your schematic or tell us which page of which datasheet you copied the schematic from. You need a resistor to power the sensor. Power requires two connections and you don't describe two connections.

Unlike a thermocouple, the LM35 does not generate voltage. An unpowered sensor will always read zero volts.