Skip to content

Commit

Permalink
Accounts for SCD4x conversion rounding errors in temperature offset
Browse files Browse the repository at this point in the history
  • Loading branch information
melkati committed Nov 30, 2021
1 parent a8a60a1 commit ec02fe2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ void Sensors::setSCD30AltitudeOffset(float offset) {
}

void Sensors::CO2scd4xInit() {
float tTemperatureOffset;
float tTemperatureOffset, offsetDifference;
uint16_t tSensorAltitude;
uint16_t error;
char errorMessage[256];
Expand Down Expand Up @@ -1085,7 +1085,8 @@ void Sensors::CO2scd4xInit() {
delay(1);
}

if (tTemperatureOffset != toffset) {
offsetDifference = abs((toffset*100) - (tTemperatureOffset*100));
if(offsetDifference > 0.5) { // Accounts for SCD4x conversion rounding errors in temperature offset
Serial.println("-->[SLIB] SCD4x setting new temp offset: " + String(toffset));
setSCD4xTempOffset(toffset);
delay(1);
Expand Down

0 comments on commit ec02fe2

Please sign in to comment.