Reading an LM35 with default Aref and powering other devices (display) from the 5volt pin can result in jumping temp readings. Switching Aref to internal will fix that.
You must give the LM35 it's own ground wire.
Sharing ground with the display or breadboard won't do.
Internal 1.1volt Aref gives more stable readings and a higher 0.1C resolution.
Try this test sketch, Ignore the TMP36 lines.
Leo..
// LM35_TMP36 temp
// works on 5volt and 3.3volt Arduinos
// connect LM35 to 5volt A0 and ground
// or connect TPM36 to 3.3volt 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
}
void loop() {
tempC = analogRead(tempPin) * calibration; // use this line for an LM35
//tempC = (analogRead(tempPin) * calibration) - 50.0; // use this line for a TMP36
tempF = tempC * 1.8 + 32.0; // C to F
Serial.print("Temperature is ");
Serial.print(tempC, 1); // one decimal place is all you get with a 10-bit A/D
Serial.print(" Celcius ");
Serial.print(tempF, 1);
Serial.println(" Fahrenheit");
delay(1000); // use a non-blocking delay when combined with other code
}
AI advises to create an average of values. That seems to me the best. When changing AREF, the extent of the sensor is likely to change, or it would be necessary to create further wiring. But I am glad for notifying this. Thank you for your answers.
It is with default Aref. But with 1.1volt internal Aref you can increase that to a 0.1C readout.
Oversampling (post@23) could further stabilise that.
The downside with 1.1volt Aref is the reduced temp range of about +55C.
Four digits would only makre sense for a Fahrenheit display (~130.9F max)
Celcius would only fill three digits sensibly.
Leo..