#include #include const int nEchantillons = 20; // ------------ N ombre d'échantillons --------------------------- MS5837 sensor; float echantillon[nEchantillons]; // un tableau pour stocker les échantillons lus int indice = 0; // l'indice de l'échantillon courant float total = 0; // la somme des échantillons mémorisés float moyenne; // la moyenne des échantillons mémorisés float pression; float P1; float P2; float P3; float temp; void setup() { Serial.begin(9600); Wire.begin(); while (!sensor.init()) { Serial.println("Init failed!"); delay(3000); } sensor.setModel(MS5837::MS5837_02BA); //sensor.setFluidDensity(100); // kg/m^3 (freshwater, 1029 for seawater) for (int i = 0; i < nEchantillons; i++) { //echantillon[i] =0; } } void loop() { sensor.read(); delay(10); //total = total - echantillon[indice]; // Soustraction de l'echantillon précédent pression=0; // echantillon[indice] = sensor.pressure();// Lecture du capteur temp = sensor.temperature(); P1 = sensor.pressure(); delay(300); P2 = sensor.pressure(); delay(300); P3 = sensor.pressure(); delay(300); pression=(P1+P2+P3)/3; pression=pression-0; pression=pression*1.0; //total = total + echantillon[indice];// Ajout du dernier echantillon //indice++; // ------------------- Incrémentation de l'indice ---------------------- //if (indice target="1">= nEchantillons) // si on est à la fin du tableau ... { indice = 0; // ...retour au début Wire.write(0x1E); //Serial.print("Temperature: "); //Serial.print(sensor.temperature(),1); //Serial.println(" deg C"); delay (10); Serial.print ("Pression : "); //Serial.println(moyenne,1); Serial.println(pression,1); Serial.println (" hPa"); } //moyenne = (total / nEchantillons);// calcul de la moyenne delay(50); }