Bonjour à tous ,

j'essaie de faire fonctionner un capteur ZH-03B ( series-laser-dust-module) qui sert à mesurer les particules
et déterminer par calcul la qualité de l'air ambiant
pour ce faire j'utilise un prg trouver sur le net dont voici une partie
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
 
#include "CalculateAQI.h"
 
 
SensorData CalculateAQI::getAveragedData(SensorData data) {
  return {
    PM_AE_UG_1_0: (data.PM_AE_UG_1_0 / data.numReads),
    PM_AE_UG_2_5: (data.PM_AE_UG_2_5 / data.numReads),
    PM_AE_UG_10_0: (data.PM_AE_UG_10_0 / data.numReads),
    AQI: (data.AQI / data.numReads),
    numReads: data.numReads
  };
}
 
 
void CalculateAQI::updateSensorData(SensorData &data, PMS::DATA newData, float AQI) {
  data.PM_AE_UG_1_0 += newData.PM_AE_UG_1_0;
  data.PM_AE_UG_2_5 += newData.PM_AE_UG_2_5;
  data.PM_AE_UG_10_0 += newData.PM_AE_UG_10_0;
  data.AQI += AQI;
  data.numReads++;
}
 
 
float CalculateAQI::getAQI(float I_high, float I_low, float C_high, float C_low, float C) {
  return (I_high - I_low) * (C - C_low) / (C_high - C_low) + I_low;
}
 
float CalculateAQI::getPM25AQI(float cPM25) {
  Breakpoints b = CalculateAQI::getPM25Breakpoints(cPM25);
  return CalculateAQI::getAQI(b.iHi, b.iLo, b.cHi, b.cLo, cPM25);
}
 
Breakpoints CalculateAQI::getPM25Breakpoints(float cPM25) {
  Breakpoints b;
 
  if (cPM25 <= 12) {
    b.iHi = 50;
    b.iLo = 0;
    b.cHi = 12;
    b.cLo = 0;
  } else if (cPM25 > 12 && cPM25 <= 35.4) {
    b.iHi = 100;
    b.iLo = 51;
    b.cHi = 35.4;
    b.cLo = 12.1;
  } else if (cPM25 > 35.4 && cPM25 <= 55.4) {
    b.iHi = 150;
    b.iLo = 101;
    b.cHi = 55.4;
    b.cLo = 35.5;
  } else if (cPM25 > 55.4 && cPM25 <= 150.4) {
    b.iHi = 200;
    b.iLo = 151;
    b.cHi = 150.4;
    b.cLo = 55.5;
  } else if (cPM25 > 150.4 && cPM25 <= 250.4) {
    b.iHi = 300;
    b.iLo = 201;
    b.cHi = 250.4;
    b.cLo = 150.5;
  } else if (cPM25 > 250.4 && cPM25 <= 350.4) {
    b.iHi = 400;
    b.iLo = 301;
    b.cHi = 350.4;
    b.cLo = 250.5;
  } else if (cPM25 > 350.4) {
    b.iHi = 500;
    b.iLo = 401;
    b.cHi = 500.4;
    b.cLo = 350.5;
  }
 
  return b;
}
 
Category CalculateAQI::getCategory(float AQI) {
  Category c;
  c.level = "Unknown";
  c.color = "black";
 
  if (AQI <= 50) {
    c.level = "Good";
    c.color = "green";
  } else if (AQI > 50 && AQI <= 100) {
    c.level = "Moderate";
    c.color = "yellow";
  } else if (AQI > 100 && AQI <= 150) {
    c.level = "Unhealthy for Sensitive Groups";
    c.color = "orange";
  } else if (AQI > 150 && AQI <= 200) {
    c.level = "Unhealthy";
    c.color = "red";
  } else if (AQI > 200 && AQI <= 300) {  
    c.level = "Very Unhealthy";
    c.color = "purple";
  } else if (AQI > 300) {
    c.level = "Hazardous";
    c.color = "maroon";
  }
 
  return c;
}
malheureusement étant débutant sur Arduino , je souhaiterai svp que l'on puisse m'expliquer les lignes suivantes car je ne peux utiliser le prg en l'état ( l'auteur utilisait un autre capteur
symbolisé par <<PMS>> alors que j'utilise moi un capteur de type ZH-03B )
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
void CalculateAQI::updateSensorData(SensorData &data, PMS::DATA newData, float AQI) {
  data.PM_AE_UG_1_0 += newData.PM_AE_UG_1_0;
  data.PM_AE_UG_2_5 += newData.PM_AE_UG_2_5;
  data.PM_AE_UG_10_0 += newData.PM_AE_UG_10_0;
  data.AQI += AQI;
  data.numReads++;
}


merci mille fois
cordialement