Add PM2.5 correction formula, #182

This commit is contained in:
Phat Nguyen
2024-07-21 07:13:34 +07:00
parent e58ce1cbea
commit 4b2a5f5540
8 changed files with 90 additions and 4 deletions

View File

@ -50,6 +50,13 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
}
}
if (config->hasSensorSHT && config->hasSensorPMS1) {
int pm25 = ag->pms5003.pm25Compensated(this->pm25_1, this->Humidity);
if (pm25 >= 0) {
root["pm02Compensated"] = pm25;
}
}
} else {
if (config->hasSensorPMS1 && config->hasSensorPMS2) {
root["pm01"] = ag->round2((this->pm01_1 + this->pm01_2) / 2.0);
@ -66,6 +73,11 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["rhumCompensated"] = (int)ag->pms5003t_2.humidityCompensated(
(this->hum_1 + this->hum_2) / 2.0f);
}
int pm25 = (ag->pms5003t_1.pm25Compensated(this->pm25_1, this->temp_1) +
ag->pms5003t_2.pm25Compensated(this->pm25_2, this->temp_2)) /
2;
root["pm02Compensated"] = pm25;
}
if (fwMode == FW_MODE_O_1PS || fwMode == FW_MODE_O_1PST) {
@ -82,6 +94,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
}
root["pm02Compensated"] = ag->pms5003t_1.pm25Compensated(this->pm25_1, this->temp_1);
}
if (config->hasSensorPMS2) {
root["pm01"] = this->pm01_2;
@ -96,6 +109,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["rhumCompensated"] =
(int)ag->pms5003t_2.humidityCompensated(this->hum_2);
}
root["pm02Compensated"] = ag->pms5003t_2.pm25Compensated(this->pm25_2, this->temp_2);
}
} else {
if (fwMode == FW_MODE_O_1P) {
@ -112,6 +126,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
}
root["pm02Compensated"] = ag->pms5003t_1.pm25Compensated(this->pm25_1, this->temp_1);
} else if (config->hasSensorPMS2) {
root["pm01"] = this->pm01_2;
root["pm02"] = this->pm25_2;
@ -125,6 +140,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_2);
}
root["pm02Compensated"] = ag->pms5003t_1.pm25Compensated(this->pm25_1, this->temp_1);
}
} else {
if (config->hasSensorPMS1) {
@ -140,6 +156,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["channels"]["1"]["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
}
root["channels"]["1"]["pm02Compensated"] = ag->pms5003t_1.pm25Compensated(this->pm25_1, this->temp_1);
}
if (config->hasSensorPMS2) {
root["channels"]["2"]["pm01"] = this->pm01_2;
@ -154,6 +171,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
root["channels"]["2"]["rhumCompensated"] =
(int)ag->pms5003t_1.humidityCompensated(this->hum_2);
}
root["channels"]["2"]["pm02Compensated"] = ag->pms5003t_2.pm25Compensated(this->pm25_2, this->temp_2);
}
}
}