From 45d730d85cddecf9d5ea462bbe65f79cc8369d0d Mon Sep 17 00:00:00 2001 From: Dmitry Frolov Date: Thu, 9 Jul 2015 22:20:55 +0600 Subject: [PATCH] Change correction formula --- MQ135.cpp | 7 ++++++- MQ135.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/MQ135.cpp b/MQ135.cpp index d565072..b0814d1 100755 --- a/MQ135.cpp +++ b/MQ135.cpp @@ -50,7 +50,12 @@ MQ135::MQ135(uint8_t pin, float rload, float rzero, float atmoco2, float vref, f */ /**************************************************************************/ float MQ135::getCorrectionFactor(float t, float h) { - return CORA * t * t - CORB * t + CORC - (h-33.)*CORD; + //return CORA * t * t - CORB * t + CORC - (h-33.)*CORD; + + // This formula is reduced from temperature and humidity dependency graph, + // found in this datasheet: + // http://china-total.com/Product/meter/gas-sensor/MQ135.pdf + return (1.30732 - 0.0116044 * t) * (2.20591 - 0.296456 * log(h)); } /**************************************************************************/ diff --git a/MQ135.h b/MQ135.h index a18beec..50a1315 100755 --- a/MQ135.h +++ b/MQ135.h @@ -31,11 +31,13 @@ v1.0 - First release #define PARA 117.185 #define PARB 2.65797 +/* /// Parameters to model temperature and humidity dependence #define CORA 0.00035 #define CORB 0.02718 #define CORC 1.39538 #define CORD 0.0018 +*/ /// Atmospheric CO2 level for calibration purposes, in PPM. /// See http://co2now.org/