I am measuring temperature with NTC10k thermistor and writting it on LCD. I am reading values of sensor for 10 times and than calculating average for better accuracy. I am writing this value to LCD with delay of one second.
I noticed that in some occasions temperature is jumping up and down (for example 35 and 36) every second. I would like to eliminate this jumping because it's very annoying.
Since I am already calculating average and writing values to LCD every second my qustion is, what approach should I use to eliminate this jumping.
int sum = 0;
for (int i = 0; i < N_SAMPLE; i++) // where N_SAMPLE <= 32
{
sum += analogRead (sensorPin);
}
int avg = sum / N_SAMPLES;
try
int sum = N_SAMPLES / 2; // pre-round result
for (int i = 0; i < N_SAMPLES; i++) // where N_SAMPLE <= 32
{
sum += analogRead (sensorPin);
}
int avg = sum / N_SAMPLES;
Or, just post your code, so that we can look over it.
AWOL:
I don't understand the reason for the array of readings - do you use the values elsewhere?
Before that I was making bubble sort. I took 10 samples, arrange them from min to max, took away the biggest and the smallest value and than calculated average of the values in array from 1 to 8 (so without 0 and 9).
But it doesn't help, temperature is still jumping from time to time.