How can I do it?
I tried to write double objTem=mlx90615.getTemperature(MLX90615_OBJECT_TEMPERATURE); in the for loop but it didn't work
If you correct the code I would be gratefull
Stick some print statements in your code so that you can see where the program is going and how variables like counter av and sum are changing - then look at the output and think about what is happening.
sum = ( sum + mlx90615.getTemperature(MLX90615_OBJECT_TEMPERATURE)) /2; makes a continuous rolling average; with no need to manage a variable holding a count.
Idahowalker:
sum = ( sum + mlx90615.getTemperature(MLX90615_OBJECT_TEMPERATURE)) /2; makes a continuous rolling average; with no need to manage a variable holding a count.
This is an exponential moving average with a coefficient of 0.5. It doesn't behave like the original simple moving average, and won't do a very good job smoothing out the measurements.