Which clearly isn't right. There is no way, with that much variation between the sample sets, that the sample sets are that rock solid, with Min, Max, and Average being so close to each other.
So, back to the subject, how can I average the data coming from my MQ135?
It has been "on" on my desk for a couple of days. However, that doesn't address the statistics problem. It is extremely unlikely to be rock solid within sets of 1,000 while being wildly variable between sets of 1,000.
This code "averages" just one number (whatever correctedPPM happens to be), so there will be no variation at all.
for (int i = 0; i < sampleSize; i++)
{
Analog = correctedPPM;
Sum = Sum + Analog; //Sum for averaging
if (Analog < Min)
Min = Analog;
if (Analog > Max)
Max = Analog;
}
Consider rearranging the code so that correctedPPM is updated within the for loop.
Unless you have actually calibrated the "burned in" MQ-135 against a known standard, the output units are meaningless.
Those sensors are not stable enough to be quantitative, and are useful only to report that the concentration of one or more of the gases they respond to in the environment has changed.
I definitely get that sensors like this are for personal amusement value. Even if they worked well, there is still no mechanism in them to tell what they are detecting, only that they are detecting something.
Before applying an average filter, get a clean reading...
Get a stable power supply, use short wires. Add a 100nF capacitor from analog pin to ground.
Be aware that you should compare to the sensor power supply voltage (if that is not stable).
The readings should be stable within +/-10 or less...