Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion MQ135.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 * 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 CORA * t * t - CORB * t + CORC - (h-33.)*CORD;
} else {
return CORE * t + CORF * h + CORG;
}
}

/**************************************************************************/
Expand Down
3 changes: 3 additions & 0 deletions MQ135.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ v1.0 - First release
#define CORB 0.02718
#define CORC 1.39538
#define CORD 0.0018
#define CORE -0.003333333
#define CORF -0.001923077
#define CORG 1.130128205

/// Atmospheric CO2 level for calibration purposes
#define ATMOCO2 397.13
Expand Down