mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-20 20:22:08 +02:00
Add PM2.5 correction formula, #182
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user