Fluctuating readings of LM35 temperature sensor (+- 5°C) with Arduino UNO I am trying to read a LM35 temperature sensor with Arduino UNO which I got as a gift.
The issue is the fact, that my readings of sensor are, well, suspicious at least - they jump with each reading some 5 °C up or down.

I had used several posts how to wire  the thing to Arduino board and for and program the reading (1, 2, 3) and produced the code posted below. The sensor reading fluctuates really a lot - it jumps by some 3 to 7 °C after  each reading regardless of reading frequency (tested with reading each 0.5 s, 1.0 s or 2.5 s). (Unfortunately I do not own a multi-meter to check actual values.) To mitigate the issue I implemented an averager, but underlying problem stays. Expected values are something like 23 or 24 °C as measured by digital weather station and bimetallic thermometer respectively.

Have you met this before ? Do you have any ideas what might be source of this ? I am beginner to electronics as well as to Arduino, trying to learn and mainly understand it.

The complete code:

#include &lt;WString.h&gt;

//Stores read analog values 
int readLM35;
const int sensorAnalogPin = 0;
const float voltsToTemperature = 1.1 / 1023 * 100; // (1.1V supply / 10bit resolution) * (10 mV/°C = 1 V / 100 °C)
//Stores the temperature in °C
float temp;
//Averager
float temps[8];
byte position = 0;
float averageTemp;

void setup() {
    Serial.begin(9600);
    pinMode(LED_BUILTIN, OUTPUT);

    //For setting internal analog reference voltage to 1.1V
    analogReference(INTERNAL);
}

void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(50);
    digitalWrite(LED_BUILTIN, LOW);

    //Measure temperature
    readLM35 = analogRead(sensorAnalogPin);
    temp = readLM35  * voltsToTemperature;

    //Save it
    temps[position] = temp;
    if (position == 7) {
        position = 0;
    } else {
        position++;
    }

    //Get average
    averageTemp = 0;
    for (byte i = 0; i &lt; 8; i++) {
        averageTemp += temps[i] / 8;
    }

    //Write
    Serial.println(String(readLM35) + " =&gt; " + String(temp, 1) + " deg. C, avg. " + String(averageTemp, 1));
    delay(2500);
}


Example of output (note the first numbers - actual reading):

211 =&gt; 22.7 deg. C, avg. 22.5
186 =&gt; 20.0 deg. C, avg. 21.9
234 =&gt; 25.2 deg. C, avg. 22.7
173 =&gt; 18.6 deg. C, avg. 21.9
237 =&gt; 25.5 deg. C, avg. 22.6
185 =&gt; 19.9 deg. C, avg. 21.9
231 =&gt; 24.8 deg. C, avg. 22.4
193 =&gt; 20.8 deg. C, avg. 22.2
223 =&gt; 24.0 deg. C, avg. 22.3
206 =&gt; 22.2 deg. C, avg. 22.6
197 =&gt; 21.2 deg. C, avg. 22.1
225 =&gt; 24.2 deg. C, avg. 22.8
183 =&gt; 19.7 deg. C, avg. 22.1
240 =&gt; 25.8 deg. C, avg. 22.8
The cause is the low sinking capabilities of LM35 output. This makes the output sensitive to EMI. Yes, the output output impedance is stated as 0.5 ohms but only for sourcing current. The sinking current is limited to 1uA which is easily achieved by the environment noise. 


You need to add a low impedance load between LM35 output and ground, can be 200 ohm as the data sheet recommends for heavy capacitive loads but I wouldn't go that far, might be 1k or 2k to avoid self heating errors. 

No software only solution can solve this error.