The precision of ms5611 pressure sensor

Hello everyone,
I use a ms5611 pressure sensor to make an altimeter. In the datasheet I read that this sensor had an accuracy of +/- 10cm. But whatever the tests and the library used, I never reached this precision. I am rather around +/- 1m with my code.

#include <MS5611.h> //https://github.com/gronat/MS5611
#define MOVAVG_SIZE 32

MS5611 baro;
int32_t pressure; // in Pascal

//const float sea_press = 101325; // in Pascal
int32_t QNH; //Calcul du QNH en fonction de l'alti du GPS
int32_t temperature;
float movavg_buff[MOVAVG_SIZE];
int movavg_i=0;

//###################   SETUP  

void setup() {
  // Start barometer
  baro = MS5611();
  baro.begin();
//   populate movavg_buff before starting loop
  for(int i=0; i<MOVAVG_SIZE; i++) {
    movavg_buff[i] = baro.getPressure();
  }
  
  // Start serial (UART)
  Serial.begin(115200);
  delay(2);
  
  // Read pressure pour calculer le QNH (Pascal)
  pressure = (baro.getPressure());
  pushAvg(pressure);
  pressure=getAvg(movavg_buff, MOVAVG_SIZE);
  QNH=sea_pressure(pressure,188);
  return QNH;
}

//###############################    LOOP    

void loop() {
  
  // Read pressure (Pascal)
  pressure = (baro.getPressure());
  pushAvg(pressure);
  pressure=getAvg(movavg_buff, MOVAVG_SIZE);
  
  // Read temperature (°C x100)
  temperature = (baro.getTemperature());



  // Print les data
  
  //Serial.println(pressure);
  //Serial.println(temperature);
  //Serial.println(QNH);

  Serial.println(getAltitude(pressure,temperature,QNH));
}

//#################################    FONCTIONS    

float getAltitude(float press, float temp, float sea_pressure) {
  return ((pow((sea_pressure / press), 1/5.257) - 1.0) * (temp*0.01 + 273.15)) / 0.0065;
}

// Enregistre un echantillon de pression
void pushAvg(float val) {
  movavg_buff[movavg_i] = val;
  movavg_i = (movavg_i + 1) % MOVAVG_SIZE;
}

// Retourne la moyenne des echantillons de pression
float getAvg(float * buff, int size) {
  float sum = 0.0;
  for(int i=0; i<size; i++) {
    sum += buff[i];
  }
  return sum / size;
}
// Calcul le QNH
float sea_pressure (float press, float GPS_alti){
  return (press/pow(1-(GPS_alti/44330.0),5.255));}

Have you already obtained such precision +/-10cm ? Or at least better than +/- 1m?
Thank you very much :slight_smile:

have you soldered the smt chip and routed the traces as instructed in the datasheet? Do you have the 100nF decoupling capacitor (ceramic low ESR) as close to VDD as possible? Are you doing the 1st and 2nd order checks? My bet is that you are using someone's module in a breadboard situation (wire leads) and the ESR is causing the inaccuracy. Also, I haven't looked at the library you are using to see if it follows all the steps spelled out in the datasheet.

Hello, thank you for your answer. The module I use is this one : https://www.ebay.fr/itm/MS5611-High-resolutio-n-atmospheric-pressure-module-height-sensor-DIY-3V-5V/263394814574?hash=item3d538dea6e:g:9PIAAOSwHlRbLiFy.
I plug it into I2C and I use the 3.3V of my arduino card but I do not use any capacitor. If I understand correctly, there is a capacitor on my module that I will have to replace with a 100nF?

clem64000:
Hello, thank you for your answer. The module I use is this one : https://www.ebay.fr/itm/MS5611-High-resolutio-n-atmospheric-pressure-module-height-sensor-DIY-3V-5V/263394814574?hash=item3d538dea6e:g:9PIAAOSwHlRbLiFy.
I plug it into I2C and I use the 3.3V of my arduino card but I do not use any capacitor. If I understand correctly, there is a capacitor on my module that I will have to replace with a 100nF?

It is beyond the spec sheet of the sensor to illustrate how to achieve the high accuracy that is specified from a third party module manufacturer. I cannot tell you how either. A hobby module will rarely be more accurate due to the ESR, inductance and other factors introduced by the wire leads, modularity etc.

Thank you for your answer. So is there a way to increase the accuracy of my sensor? In hardware or software. Or do you know a sensor that can give me a better resolution than +/- 1m ?

clem64000:
Thank you for your answer. So is there a way to increase the accuracy of my sensor? In hardware or software. Or do you know a sensor that can give me a better resolution than +/- 1m ?

If you build the IC into a circuit, that is soldered to a PCB with the rest of the circuit, following the keep out requirements of the IC, making your runs as short as possible, placing your decoupling caps as close to respective pins, mitigating lead inductance, mitigating ESR, etc. You should get pretty close to the datasheet, provided that you also do the first and second order checks in the software.