I played with LM35 5 years ago, without success. Now i have time again, so i bought 30 pieces of this sensor from 3 different places, and my problem is the same as 5 years ago.
The values are fluctating, in that way above (the list is long, buit shows how fluctating).
Is it possible that the more than 50 pcs of this sensors are bad (the new the old, both) ? I tried using arduino uno, nano leonardo, the problem is the same. I read many articles how to use this sensor. So i put resistor
Yes, i know using dallas 18b20 solves this problem, i'm using it, but i want to know what i do wrong.
Could you show a schematic, the sketch and perhaps a photo ?
If you changed the Arduino board and the LM35, did you also change the breadboard, the wires and the USB cable ?
It is a analog sensor with a voltage output.
The Arduino measures a voltage relative to the 5V. That 5V fluctuates when the Arduino board is powered with 5V from a USB cable. You can set the reference to the internal 1.1V, but that is not enough range for the LM35.
The LM35 needs at least 4V, so you can power it with 5V, but still connect 3.3V to AREF.
By the way, if you bought 30 pieces in the same order from AliExpress/Ebay/Amazon, then they could be counterfeit or they might be from a batch that was rejected by the manufacturer, or something else could be wrong with them.
Fine if you don't have to measure more than about 110 degrees C.
The LM35 outputs 1volt at 100C.
You might have to use 3.3volt Aref if you use a TMP36,
because that one only has a top range of 55C on 1.1volt Aref.
Default Aref (potentially unstable 5volt supply) is a poor choice for the LM35.
1.1volt Aref is the way to go,
but don't expect a higher resolution than one decimal place with a 10-bit A/D.
is 2734 A/D steps. 100.00 degrees C would be 10000 steps.
10x the capability of a 10-bit common Arduino.
Leo..
Basic Uno test sketch for the LM35.
Do not share LM35 ground with other devices (direct ground, not via breadboard).
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
}
Finally.. It looks like all of them counterfeit, doesnt matter if its 5 years old and new.
I disassembled my sons slightly burnt skyrc charger, and inside found an lm35 which worked well.
I agree with you if you do the following final test with few of the supposed to be bad LM35s.
Solder nicely (no cold solder or solder bridge) three wires with the three legs of a suspected LM35 sensor. Solder other ends of the three wires with 5V (Pin-1), A0 (Pin-2), and GND (Pin-3). Now, report that the temperature readings are still fluctuating. (Breadboard testing of the LM35 is a bad experience.)
The values become different, but it doesnt seem to following the temperature..
(without touching the sensor it starts 27c, (21 in this room but ok, i can correct it via software) if i touch the top of sensor the value goes down to 23C after release slowly goes up to 33-34, if i heat up with a hair dryer is goes down to 24, so nowhere near to the real values.
If this is the case, and the LM35 works in the same circuit, this means likely you have another component marked as an LM35. I would guess a MosFet as it would appear to be an open circuit.
You have your solution so additional testing does not matter, however it would be interesting to see if you measurement go to zero if you put a 10k from the signal pin to ground.