From 093774f701ecde8a0cae6b761f9abb0c6bf3103a Mon Sep 17 00:00:00 2001 From: Portagoras Date: Wed, 1 Jul 2020 22:57:48 +0200 Subject: [PATCH] Correction The datasheet clearly says that the CO2 level is 2000x(th-2ms)/(th+tl+4ms), so I think here it should say 2000 too. At least that resulted in way better results for me. --- MHZ.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MHZ.cpp b/MHZ.cpp index 43b6bfa..4de8b42 100644 --- a/MHZ.cpp +++ b/MHZ.cpp @@ -243,7 +243,7 @@ int MHZ::readCO2PWM() { if (debug) Serial.print("."); th = pulseIn(_pwmpin, HIGH, 1004000) / 1000; tl = 1004 - th; - ppm_pwm = 5000 * (th - 2) / (th + tl - 4); + ppm_pwm = 2000 * (th - 2) / (th + tl - 4); } while (th == 0); if (debug) { Serial.print(F("\n # PPM PWM: "));