Air pressure senor analog read fluctuates

We switched to an MPM281 series pressure sensor from Microsensors (http://www.microsensorcorp.com), as we needed to change supplier in a hurry, and they were willing to quickly customise a sensor to duplicate the Honeywell one we had been using. I think they were slightly cheaper too. So far no issues - with more than 100 sensors deployed in the field for over a year.

float Get_PO2(void) // read cylinder pressure
{
    int i;
    float temp =0;
    double acc=0;
    for (i=0;i<64;i++)  // long mutliread to get rid of noise
    {
        acc+=analogRead(Pcyl);
        delay(i);
    }
    acc=acc/64;
    temp= mapfloat(acc,  cyl_inlo,  cyl_inhi, 0, cyl_outhi);

As you can see I take 64 readings at progressively longer intervals and average the result. The variable delay helps avoid issues with single frequency interference, which could get aliased down to DC if you were really unlucky. If this seems excessive its not, as my system depends heavily on accurate pressure readings.
I use the mapfloat() function to convert to bar using my calibration values.

3 Likes