From 8ec01498795bcbb69fc137532c12719d10bee35d Mon Sep 17 00:00:00 2001 From: balk77 Date: Thu, 17 Nov 2016 20:25:24 +0100 Subject: [PATCH 1/4] Update MQ135.cpp Alternative approach to estimate the temperature and humidity correction factor. Above and below 20degC, a linear relation has been defined, instead of quadratic. --- MQ135.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MQ135.cpp b/MQ135.cpp index 676ed31..6c07b4a 100755 --- a/MQ135.cpp +++ b/MQ135.cpp @@ -40,7 +40,15 @@ MQ135::MQ135(uint8_t pin) { */ /**************************************************************************/ float MQ135::getCorrectionFactor(float t, float h) { - return CORA * t * t - CORB * t + CORC - (h-33.)*CORD; + // Linearization of the temperature dependency curve under and above 20 degree C + // below 20degC: fact = (a * h + b) * t + c * h + d + // above 20degC: fact = a * t + b * h + c + // this assumes a linear dependency on humidity + if(t < 20){ + return (CORE * h + CORF) * t + CORG * h + CORH; + } else { + return CORI * t + CORJ * h + CORK; + } } /**************************************************************************/ From fa69afee8b18f0f21344cf2b3290914ed78dd2a8 Mon Sep 17 00:00:00 2001 From: balk77 Date: Thu, 17 Nov 2016 20:26:44 +0100 Subject: [PATCH 2/4] Update MQ135.h coefficients for new linearisation of correction factor --- MQ135.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MQ135.h b/MQ135.h index 22cefec..3f618e7 100755 --- a/MQ135.h +++ b/MQ135.h @@ -34,6 +34,13 @@ v1.0 - First release #define CORB 0.02718 #define CORC 1.39538 #define CORD 0.0018 +#define CORE 3.20513E-05 +#define CORF -0.024391026 +#define CORG -0.002403846 +#define CORH 1.512660256 +#define CORI -0.003333333 +#define CORJ -0.001923077 +#define CORK 1.130128205 /// Atmospheric CO2 level for calibration purposes #define ATMOCO2 397.13 From cd1206e7aae8d77cdac84296ee9ed645b1a320ef Mon Sep 17 00:00:00 2001 From: balk77 Date: Thu, 17 Nov 2016 20:36:22 +0100 Subject: [PATCH 3/4] Update MQ135.cpp --- MQ135.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MQ135.cpp b/MQ135.cpp index 6c07b4a..ce6af65 100755 --- a/MQ135.cpp +++ b/MQ135.cpp @@ -41,13 +41,13 @@ MQ135::MQ135(uint8_t pin) { /**************************************************************************/ float MQ135::getCorrectionFactor(float t, float h) { // Linearization of the temperature dependency curve under and above 20 degree C - // below 20degC: fact = (a * h + b) * t + c * h + d + // below 20degC: fact = a * t * t - b * t - (h - 33) * d // above 20degC: fact = a * t + b * h + c // this assumes a linear dependency on humidity if(t < 20){ - return (CORE * h + CORF) * t + CORG * h + CORH; + return CORA * t * t - CORB * t + CORC - (h-33.)*CORD; } else { - return CORI * t + CORJ * h + CORK; + return CORE * t + CORF * h + CORG; } } From 65b7bcf8667340ab7d1000dfa77e4ca92fee9a90 Mon Sep 17 00:00:00 2001 From: balk77 Date: Thu, 17 Nov 2016 20:37:04 +0100 Subject: [PATCH 4/4] Update MQ135.h --- MQ135.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/MQ135.h b/MQ135.h index 3f618e7..7fb03b2 100755 --- a/MQ135.h +++ b/MQ135.h @@ -34,13 +34,9 @@ v1.0 - First release #define CORB 0.02718 #define CORC 1.39538 #define CORD 0.0018 -#define CORE 3.20513E-05 -#define CORF -0.024391026 -#define CORG -0.002403846 -#define CORH 1.512660256 -#define CORI -0.003333333 -#define CORJ -0.001923077 -#define CORK 1.130128205 +#define CORE -0.003333333 +#define CORF -0.001923077 +#define CORG 1.130128205 /// Atmospheric CO2 level for calibration purposes #define ATMOCO2 397.13