Skip to content

Commit 7b829a8

Browse files
committed
Fix environmental asjustment based on datasheet
1 parent 01c06c6 commit 7b829a8

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/MQ131.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ MQ131Class::~MQ131Class() {
9090
delay(1000);
9191
}
9292
lastValueRs = readRs();
93-
correctedLastValueRs = lastValueRs / getEnvCorrectRatio();
9493
stopHeater();
9594
}
9695

@@ -204,13 +203,13 @@ MQ131Class::~MQ131Class() {
204203
// Use the equation to compute the O3 concentration in ppm
205204
// R^2 = 0.9987
206205
// Compute the ratio Rs/R0 and apply the environmental correction
207-
ratio = correctedLastValueRs / correctedValueR0;
206+
ratio = lastValueRs / valueR0 * getEnvCorrectRatio();
208207
return convert((10.66435681 * pow(ratio, 2.25889394) - 10.66435681), PPB, unit);
209208
case HIGH_CONCENTRATION :
210209
// Use the equation to compute the O3 concentration in ppm
211210
// R^2 = 0.99
212211
// Compute the ratio Rs/R0 and apply the environmental correction
213-
ratio = correctedLastValueRs / correctedValueR0;
212+
ratio = lastValueRs / valueR0 * getEnvCorrectRatio();
214213
return convert((8.37768358 * pow(ratio, 2.30375446) - 8.37768358), PPM, unit);
215214
default :
216215
return 0.0;
@@ -324,7 +323,6 @@ void MQ131Class::calibrate() {
324323
*/
325324
void MQ131Class::setR0(float _valueR0) {
326325
valueR0 = _valueR0;
327-
correctedValueR0 = _valueR0 / getEnvCorrectRatio();
328326
}
329327

330328
/**

src/MQ131.h

-2
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,9 @@ class MQ131Class {
123123

124124
// Calibration of R0
125125
float valueR0 = -1;
126-
float correctedValueR0 = -1;
127126

128127
// Last value for sensor resistance
129128
float lastValueRs = -1;
130-
float correctedLastValueRs = -1;
131129

132130
// Parameters for environment
133131
int8_t temperatureCelsuis = MQ131_DEFAULT_TEMPERATURE_CELSIUS;

0 commit comments

Comments
 (0)