Needing better averaging code for pressure sensor

Koepel:
That is a huge improvement !
I have a damper after the pump, the polyester fibers that I use let the air go through freely.

Koepel:
When you use the Nano with 9V and the onboard voltage regulator of 5V is used, then it is a steady 5.0 V. Then the RC filter is okay. But I still prefer to keep the ratiometric match between the sensor and the Arduino to be able to use the USB cable to power the Arduino Nano.

Do you know what kind of pulsation the pump creates in the air pressure ? What is the frequency range and the amplitude of the pulsation ?

A ratiometric sensor does not output a voltage, but a voltage relative to the 5V.
The default setting for the Arduino is the analog reference set to VCC, so that is also relative to the 5V.
When the sensor outputs 20% of 5V, then the arduino reads 20% of 5V. When the 5V changes, both the sensor and the Arduino will still be at 20%. When that 20% is calculated into the pressure in kPa, then it will be same pressure, even when the 5V changes.

Common average:

// Without average

int value = analogRead( A0);

// With average
unsigned int total = 0;    // reset
for( int x = 0; x < 64; x++)
{
  total += analogRead( A0);
}
int value = total / 64;



That is reduce the noise. I would also use a moving average smoothing to reduce the pulsation from the pumps.

Koepel,

What is int x in the code? I somewhat understand the code but what is x in reference to?