|
|
@ -27,12 +27,14 @@
|
|
|
|
#define json_prop_noxRaw "noxRaw"
|
|
|
|
#define json_prop_noxRaw "noxRaw"
|
|
|
|
#define json_prop_co2 "rco2"
|
|
|
|
#define json_prop_co2 "rco2"
|
|
|
|
|
|
|
|
|
|
|
|
Measurements::Measurements() {
|
|
|
|
Measurements::Measurements(Configuration &config) : config(config) {
|
|
|
|
#ifndef ESP8266
|
|
|
|
#ifndef ESP8266
|
|
|
|
_resetReason = (int)ESP_RST_UNKNOWN;
|
|
|
|
_resetReason = (int)ESP_RST_UNKNOWN;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Measurements::setAirGradient(AirGradient *ag) { this->ag = ag; }
|
|
|
|
|
|
|
|
|
|
|
|
void Measurements::maxPeriod(MeasurementType type, int max) {
|
|
|
|
void Measurements::maxPeriod(MeasurementType type, int max) {
|
|
|
|
switch (type) {
|
|
|
|
switch (type) {
|
|
|
|
case Temperature:
|
|
|
|
case Temperature:
|
|
|
@ -535,8 +537,7 @@ void Measurements::validateChannel(int ch) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float Measurements::getCorrectedTempHum(AirGradient &ag, Configuration &config,
|
|
|
|
float Measurements::getCorrectedTempHum(MeasurementType type, int ch, bool forceCorrection) {
|
|
|
|
MeasurementType type, int ch, bool forceCorrection) {
|
|
|
|
|
|
|
|
// Sanity check to validate channel, assert if invalid
|
|
|
|
// Sanity check to validate channel, assert if invalid
|
|
|
|
validateChannel(ch);
|
|
|
|
validateChannel(ch);
|
|
|
|
|
|
|
|
|
|
|
@ -553,7 +554,7 @@ float Measurements::getCorrectedTempHum(AirGradient &ag, Configuration &config,
|
|
|
|
|
|
|
|
|
|
|
|
Configuration::TempHumCorrection tmp = config.getTempCorrection();
|
|
|
|
Configuration::TempHumCorrection tmp = config.getTempCorrection();
|
|
|
|
if (tmp.algorithm == TempHumCorrectionAlgorithm::CA_TH_AG_PMS5003T_2024 || forceCorrection) {
|
|
|
|
if (tmp.algorithm == TempHumCorrectionAlgorithm::CA_TH_AG_PMS5003T_2024 || forceCorrection) {
|
|
|
|
return ag.pms5003t_1.compensateTemp(rawValue);
|
|
|
|
return ag->pms5003t_1.compensateTemp(rawValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
correction.algorithm = tmp.algorithm;
|
|
|
|
correction.algorithm = tmp.algorithm;
|
|
|
@ -566,7 +567,7 @@ float Measurements::getCorrectedTempHum(AirGradient &ag, Configuration &config,
|
|
|
|
|
|
|
|
|
|
|
|
Configuration::TempHumCorrection tmp = config.getHumCorrection();
|
|
|
|
Configuration::TempHumCorrection tmp = config.getHumCorrection();
|
|
|
|
if (tmp.algorithm == TempHumCorrectionAlgorithm::CA_TH_AG_PMS5003T_2024 || forceCorrection) {
|
|
|
|
if (tmp.algorithm == TempHumCorrectionAlgorithm::CA_TH_AG_PMS5003T_2024 || forceCorrection) {
|
|
|
|
return ag.pms5003t_1.compensateHum(rawValue);
|
|
|
|
return ag->pms5003t_1.compensateHum(rawValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
correction.algorithm = tmp.algorithm;
|
|
|
|
correction.algorithm = tmp.algorithm;
|
|
|
@ -592,7 +593,7 @@ float Measurements::getCorrectedTempHum(AirGradient &ag, Configuration &config,
|
|
|
|
return corrected;
|
|
|
|
return corrected;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float Measurements::getCorrectedPM25(AirGradient &ag, Configuration &config, bool useAvg, int ch) {
|
|
|
|
float Measurements::getCorrectedPM25(bool useAvg, int ch) {
|
|
|
|
float pm25;
|
|
|
|
float pm25;
|
|
|
|
float corrected;
|
|
|
|
float corrected;
|
|
|
|
float humidity;
|
|
|
|
float humidity;
|
|
|
@ -617,15 +618,15 @@ float Measurements::getCorrectedPM25(AirGradient &ag, Configuration &config, boo
|
|
|
|
corrected = pm25;
|
|
|
|
corrected = pm25;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PMCorrectionAlgorithm::EPA_2021:
|
|
|
|
case PMCorrectionAlgorithm::EPA_2021:
|
|
|
|
corrected = ag.pms5003.compensate(pm25, humidity);
|
|
|
|
corrected = ag->pms5003.compensate(pm25, humidity);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default: {
|
|
|
|
default: {
|
|
|
|
// All SLR correction using the same flow, hence default condition
|
|
|
|
// All SLR correction using the same flow, hence default condition
|
|
|
|
corrected = ag.pms5003.slrCorrection(pm25, pm003Count, pmCorrection.scalingFactor,
|
|
|
|
corrected = ag->pms5003.slrCorrection(pm25, pm003Count, pmCorrection.scalingFactor,
|
|
|
|
pmCorrection.intercept);
|
|
|
|
pmCorrection.intercept);
|
|
|
|
if (pmCorrection.useEPA) {
|
|
|
|
if (pmCorrection.useEPA) {
|
|
|
|
// Add EPA compensation on top of SLR
|
|
|
|
// Add EPA compensation on top of SLR
|
|
|
|
corrected = ag.pms5003.compensate(corrected, humidity);
|
|
|
|
corrected = ag->pms5003.compensate(corrected, humidity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -633,34 +634,33 @@ float Measurements::getCorrectedPM25(AirGradient &ag, Configuration &config, boo
|
|
|
|
return corrected;
|
|
|
|
return corrected;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi, AirGradient &ag,
|
|
|
|
String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi) {
|
|
|
|
Configuration &config) {
|
|
|
|
|
|
|
|
JSONVar root;
|
|
|
|
JSONVar root;
|
|
|
|
|
|
|
|
|
|
|
|
if (ag.isOne() || (ag.isPro4_2()) || ag.isPro3_3() || ag.isBasic()) {
|
|
|
|
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_3() || ag->isBasic()) {
|
|
|
|
root = buildIndoor(localServer, ag, config);
|
|
|
|
root = buildIndoor(localServer);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
root = buildOutdoor(localServer, fwMode, ag, config);
|
|
|
|
root = buildOutdoor(localServer, fwMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// CO2
|
|
|
|
// CO2
|
|
|
|
if (config.hasSensorS8 && utils::isValidCO2(_co2.update.avg)) {
|
|
|
|
if (config.hasSensorS8 && utils::isValidCO2(_co2.update.avg)) {
|
|
|
|
root[json_prop_co2] = ag.round2(_co2.update.avg);
|
|
|
|
root[json_prop_co2] = ag->round2(_co2.update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// TVOx and NOx
|
|
|
|
/// TVOx and NOx
|
|
|
|
if (config.hasSensorSGP) {
|
|
|
|
if (config.hasSensorSGP) {
|
|
|
|
if (utils::isValidVOC(_tvoc.update.avg)) {
|
|
|
|
if (utils::isValidVOC(_tvoc.update.avg)) {
|
|
|
|
root[json_prop_tvoc] = ag.round2(_tvoc.update.avg);
|
|
|
|
root[json_prop_tvoc] = ag->round2(_tvoc.update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidVOC(_tvoc_raw.update.avg)) {
|
|
|
|
if (utils::isValidVOC(_tvoc_raw.update.avg)) {
|
|
|
|
root[json_prop_tvocRaw] = ag.round2(_tvoc_raw.update.avg);
|
|
|
|
root[json_prop_tvocRaw] = ag->round2(_tvoc_raw.update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidNOx(_nox.update.avg)) {
|
|
|
|
if (utils::isValidNOx(_nox.update.avg)) {
|
|
|
|
root[json_prop_nox] = ag.round2(_nox.update.avg);
|
|
|
|
root[json_prop_nox] = ag->round2(_nox.update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidNOx(_nox_raw.update.avg)) {
|
|
|
|
if (utils::isValidNOx(_nox_raw.update.avg)) {
|
|
|
|
root[json_prop_noxRaw] = ag.round2(_nox_raw.update.avg);
|
|
|
|
root[json_prop_noxRaw] = ag->round2(_nox_raw.update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -669,11 +669,11 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|
|
|
root["wifi"] = rssi;
|
|
|
|
root["wifi"] = rssi;
|
|
|
|
|
|
|
|
|
|
|
|
if (localServer) {
|
|
|
|
if (localServer) {
|
|
|
|
if (ag.isOne()) {
|
|
|
|
if (ag->isOne()) {
|
|
|
|
root["ledMode"] = config.getLedBarModeName();
|
|
|
|
root["ledMode"] = config.getLedBarModeName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
root["serialno"] = ag.deviceId();
|
|
|
|
root["serialno"] = ag->deviceId();
|
|
|
|
root["firmware"] = ag.getVersion();
|
|
|
|
root["firmware"] = ag->getVersion();
|
|
|
|
root["model"] = AgFirmwareModeName(fwMode);
|
|
|
|
root["model"] = AgFirmwareModeName(fwMode);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
#ifndef ESP8266
|
|
|
|
#ifndef ESP8266
|
|
|
@ -687,8 +687,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JSONVar Measurements::buildOutdoor(bool localServer, AgFirmwareMode fwMode, AirGradient &ag,
|
|
|
|
JSONVar Measurements::buildOutdoor(bool localServer, AgFirmwareMode fwMode) {
|
|
|
|
Configuration &config) {
|
|
|
|
|
|
|
|
JSONVar outdoor;
|
|
|
|
JSONVar outdoor;
|
|
|
|
if (fwMode == FW_MODE_O_1P || fwMode == FW_MODE_O_1PS || fwMode == FW_MODE_O_1PST) {
|
|
|
|
if (fwMode == FW_MODE_O_1P || fwMode == FW_MODE_O_1PS || fwMode == FW_MODE_O_1PST) {
|
|
|
|
// buildPMS params:
|
|
|
|
// buildPMS params:
|
|
|
@ -697,14 +696,16 @@ JSONVar Measurements::buildOutdoor(bool localServer, AgFirmwareMode fwMode, AirG
|
|
|
|
/// compensated values if requested by local server
|
|
|
|
/// compensated values if requested by local server
|
|
|
|
/// Set ch based on hasSensorPMSx
|
|
|
|
/// Set ch based on hasSensorPMSx
|
|
|
|
if (config.hasSensorPMS1) {
|
|
|
|
if (config.hasSensorPMS1) {
|
|
|
|
outdoor = buildPMS(ag, 1, false, true, localServer);
|
|
|
|
outdoor = buildPMS(1, false, true, localServer);
|
|
|
|
if (!localServer) {
|
|
|
|
if (!localServer) {
|
|
|
|
outdoor[json_prop_pmFirmware] = pms5003TFirmwareVersion(ag.pms5003t_1.getFirmwareVersion());
|
|
|
|
outdoor[json_prop_pmFirmware] =
|
|
|
|
|
|
|
|
pms5003TFirmwareVersion(ag->pms5003t_1.getFirmwareVersion());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
outdoor = buildPMS(ag, 2, false, true, localServer);
|
|
|
|
outdoor = buildPMS(2, false, true, localServer);
|
|
|
|
if (!localServer) {
|
|
|
|
if (!localServer) {
|
|
|
|
outdoor[json_prop_pmFirmware] = pms5003TFirmwareVersion(ag.pms5003t_2.getFirmwareVersion());
|
|
|
|
outdoor[json_prop_pmFirmware] =
|
|
|
|
|
|
|
|
pms5003TFirmwareVersion(ag->pms5003t_2.getFirmwareVersion());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -713,20 +714,20 @@ JSONVar Measurements::buildOutdoor(bool localServer, AgFirmwareMode fwMode, AirG
|
|
|
|
/// Have 2 PMS sensor, allCh is set to true (ch params ignored)
|
|
|
|
/// Have 2 PMS sensor, allCh is set to true (ch params ignored)
|
|
|
|
/// Enable temp hum from PMS
|
|
|
|
/// Enable temp hum from PMS
|
|
|
|
/// compensated values if requested by local server
|
|
|
|
/// compensated values if requested by local server
|
|
|
|
outdoor = buildPMS(ag, 1, true, true, localServer);
|
|
|
|
outdoor = buildPMS(1, true, true, localServer);
|
|
|
|
// PMS5003T version
|
|
|
|
// PMS5003T version
|
|
|
|
if (!localServer) {
|
|
|
|
if (!localServer) {
|
|
|
|
outdoor["channels"]["1"][json_prop_pmFirmware] =
|
|
|
|
outdoor["channels"]["1"][json_prop_pmFirmware] =
|
|
|
|
pms5003TFirmwareVersion(ag.pms5003t_1.getFirmwareVersion());
|
|
|
|
pms5003TFirmwareVersion(ag->pms5003t_1.getFirmwareVersion());
|
|
|
|
outdoor["channels"]["2"][json_prop_pmFirmware] =
|
|
|
|
outdoor["channels"]["2"][json_prop_pmFirmware] =
|
|
|
|
pms5003TFirmwareVersion(ag.pms5003t_2.getFirmwareVersion());
|
|
|
|
pms5003TFirmwareVersion(ag->pms5003t_2.getFirmwareVersion());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return outdoor;
|
|
|
|
return outdoor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JSONVar Measurements::buildIndoor(bool localServer, AirGradient &ag, Configuration &config) {
|
|
|
|
JSONVar Measurements::buildIndoor(bool localServer) {
|
|
|
|
JSONVar indoor;
|
|
|
|
JSONVar indoor;
|
|
|
|
|
|
|
|
|
|
|
|
if (config.hasSensorPMS1) {
|
|
|
|
if (config.hasSensorPMS1) {
|
|
|
@ -734,26 +735,26 @@ JSONVar Measurements::buildIndoor(bool localServer, AirGradient &ag, Configurati
|
|
|
|
/// PMS channel 1 (indoor only have 1 PMS; hence allCh false)
|
|
|
|
/// PMS channel 1 (indoor only have 1 PMS; hence allCh false)
|
|
|
|
/// Not include temperature and humidity from PMS sensor
|
|
|
|
/// Not include temperature and humidity from PMS sensor
|
|
|
|
/// Not include compensated calculation
|
|
|
|
/// Not include compensated calculation
|
|
|
|
indoor = buildPMS(ag, 1, false, false, false);
|
|
|
|
indoor = buildPMS(1, false, false, false);
|
|
|
|
if (!localServer) {
|
|
|
|
if (!localServer) {
|
|
|
|
// Indoor is using PMS5003
|
|
|
|
// Indoor is using PMS5003
|
|
|
|
indoor[json_prop_pmFirmware] = this->pms5003FirmwareVersion(ag.pms5003.getFirmwareVersion());
|
|
|
|
indoor[json_prop_pmFirmware] = this->pms5003FirmwareVersion(ag->pms5003.getFirmwareVersion());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (config.hasSensorSHT) {
|
|
|
|
if (config.hasSensorSHT) {
|
|
|
|
// Add temperature
|
|
|
|
// Add temperature
|
|
|
|
if (utils::isValidTemperature(_temperature[0].update.avg)) {
|
|
|
|
if (utils::isValidTemperature(_temperature[0].update.avg)) {
|
|
|
|
indoor[json_prop_temp] = ag.round2(_temperature[0].update.avg);
|
|
|
|
indoor[json_prop_temp] = ag->round2(_temperature[0].update.avg);
|
|
|
|
if (localServer) {
|
|
|
|
if (localServer) {
|
|
|
|
indoor[json_prop_tempCompensated] = ag.round2(_temperature[0].update.avg);
|
|
|
|
indoor[json_prop_tempCompensated] = ag->round2(_temperature[0].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Add humidity
|
|
|
|
// Add humidity
|
|
|
|
if (utils::isValidHumidity(_humidity[0].update.avg)) {
|
|
|
|
if (utils::isValidHumidity(_humidity[0].update.avg)) {
|
|
|
|
indoor[json_prop_rhum] = ag.round2(_humidity[0].update.avg);
|
|
|
|
indoor[json_prop_rhum] = ag->round2(_humidity[0].update.avg);
|
|
|
|
if (localServer) {
|
|
|
|
if (localServer) {
|
|
|
|
indoor[json_prop_rhumCompensated] = ag.round2(_humidity[0].update.avg);
|
|
|
|
indoor[json_prop_rhumCompensated] = ag->round2(_humidity[0].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -762,16 +763,15 @@ JSONVar Measurements::buildIndoor(bool localServer, AirGradient &ag, Configurati
|
|
|
|
if (config.hasSensorPMS1 && utils::isValidPm(_pm_25[0].update.avg)) {
|
|
|
|
if (config.hasSensorPMS1 && utils::isValidPm(_pm_25[0].update.avg)) {
|
|
|
|
if (config.hasSensorSHT && utils::isValidHumidity(_humidity[0].update.avg)) {
|
|
|
|
if (config.hasSensorSHT && utils::isValidHumidity(_humidity[0].update.avg)) {
|
|
|
|
// Correction using moving average value
|
|
|
|
// Correction using moving average value
|
|
|
|
float tmp = getCorrectedPM25(ag, config, true);
|
|
|
|
float tmp = getCorrectedPM25(true);
|
|
|
|
indoor[json_prop_pm25Compensated] = ag.round2(tmp);
|
|
|
|
indoor[json_prop_pm25Compensated] = ag->round2(tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return indoor;
|
|
|
|
return indoor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JSONVar Measurements::buildPMS(AirGradient &ag, int ch, bool allCh, bool withTempHum,
|
|
|
|
JSONVar Measurements::buildPMS(int ch, bool allCh, bool withTempHum, bool compensate) {
|
|
|
|
bool compensate) {
|
|
|
|
|
|
|
|
JSONVar pms;
|
|
|
|
JSONVar pms;
|
|
|
|
|
|
|
|
|
|
|
|
// When only one of the channel
|
|
|
|
// When only one of the channel
|
|
|
@ -783,47 +783,47 @@ JSONVar Measurements::buildPMS(AirGradient &ag, int ch, bool allCh, bool withTem
|
|
|
|
ch = ch - 1;
|
|
|
|
ch = ch - 1;
|
|
|
|
|
|
|
|
|
|
|
|
if (utils::isValidPm(_pm_01[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_01[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm01Ae] = ag.round2(_pm_01[ch].update.avg);
|
|
|
|
pms[json_prop_pm01Ae] = ag->round2(_pm_01[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidPm(_pm_25[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_25[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm25Ae] = ag.round2(_pm_25[ch].update.avg);
|
|
|
|
pms[json_prop_pm25Ae] = ag->round2(_pm_25[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidPm(_pm_10[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_10[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm10Ae] = ag.round2(_pm_10[ch].update.avg);
|
|
|
|
pms[json_prop_pm10Ae] = ag->round2(_pm_10[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidPm(_pm_01_sp[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_01_sp[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm01Sp] = ag.round2(_pm_01_sp[ch].update.avg);
|
|
|
|
pms[json_prop_pm01Sp] = ag->round2(_pm_01_sp[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidPm(_pm_25_sp[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_25_sp[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm25Sp] = ag.round2(_pm_25_sp[ch].update.avg);
|
|
|
|
pms[json_prop_pm25Sp] = ag->round2(_pm_25_sp[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidPm(_pm_10_sp[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_10_sp[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm10Sp] = ag.round2(_pm_10_sp[ch].update.avg);
|
|
|
|
pms[json_prop_pm10Sp] = ag->round2(_pm_10_sp[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidPm03Count(_pm_03_pc[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm03Count(_pm_03_pc[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm03Count] = ag.round2(_pm_03_pc[ch].update.avg);
|
|
|
|
pms[json_prop_pm03Count] = ag->round2(_pm_03_pc[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidPm03Count(_pm_05_pc[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm03Count(_pm_05_pc[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm05Count] = ag.round2(_pm_05_pc[ch].update.avg);
|
|
|
|
pms[json_prop_pm05Count] = ag->round2(_pm_05_pc[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidPm03Count(_pm_01_pc[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm03Count(_pm_01_pc[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm1Count] = ag.round2(_pm_01_pc[ch].update.avg);
|
|
|
|
pms[json_prop_pm1Count] = ag->round2(_pm_01_pc[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidPm03Count(_pm_25_pc[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm03Count(_pm_25_pc[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm25Count] = ag.round2(_pm_25_pc[ch].update.avg);
|
|
|
|
pms[json_prop_pm25Count] = ag->round2(_pm_25_pc[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_pm_5_pc[ch].listValues.empty() == false) {
|
|
|
|
if (_pm_5_pc[ch].listValues.empty() == false) {
|
|
|
|
// Only include pm5.0 count when values available on its list
|
|
|
|
// Only include pm5.0 count when values available on its list
|
|
|
|
// If not, means no pm5_pc available from the sensor
|
|
|
|
// If not, means no pm5_pc available from the sensor
|
|
|
|
if (utils::isValidPm03Count(_pm_5_pc[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm03Count(_pm_5_pc[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm5Count] = ag.round2(_pm_5_pc[ch].update.avg);
|
|
|
|
pms[json_prop_pm5Count] = ag->round2(_pm_5_pc[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_pm_10_pc[ch].listValues.empty() == false) {
|
|
|
|
if (_pm_10_pc[ch].listValues.empty() == false) {
|
|
|
|
// Only include pm10 count when values available on its list
|
|
|
|
// Only include pm10 count when values available on its list
|
|
|
|
// If not, means no pm10_pc available from the sensor
|
|
|
|
// If not, means no pm10_pc available from the sensor
|
|
|
|
if (utils::isValidPm03Count(_pm_10_pc[ch].update.avg)) {
|
|
|
|
if (utils::isValidPm03Count(_pm_10_pc[ch].update.avg)) {
|
|
|
|
pms[json_prop_pm10Count] = ag.round2(_pm_10_pc[ch].update.avg);
|
|
|
|
pms[json_prop_pm10Count] = ag->round2(_pm_10_pc[ch].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -831,23 +831,23 @@ JSONVar Measurements::buildPMS(AirGradient &ag, int ch, bool allCh, bool withTem
|
|
|
|
float _vc;
|
|
|
|
float _vc;
|
|
|
|
// Set temperature if valid
|
|
|
|
// Set temperature if valid
|
|
|
|
if (utils::isValidTemperature(_temperature[ch].update.avg)) {
|
|
|
|
if (utils::isValidTemperature(_temperature[ch].update.avg)) {
|
|
|
|
pms[json_prop_temp] = ag.round2(_temperature[ch].update.avg);
|
|
|
|
pms[json_prop_temp] = ag->round2(_temperature[ch].update.avg);
|
|
|
|
// Compensate temperature when flag is set
|
|
|
|
// Compensate temperature when flag is set
|
|
|
|
if (compensate) {
|
|
|
|
if (compensate) {
|
|
|
|
_vc = ag.pms5003t_1.compensateTemp(_temperature[ch].update.avg);
|
|
|
|
_vc = ag->pms5003t_1.compensateTemp(_temperature[ch].update.avg);
|
|
|
|
if (utils::isValidTemperature(_vc)) {
|
|
|
|
if (utils::isValidTemperature(_vc)) {
|
|
|
|
pms[json_prop_tempCompensated] = ag.round2(_vc);
|
|
|
|
pms[json_prop_tempCompensated] = ag->round2(_vc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Set humidity if valid
|
|
|
|
// Set humidity if valid
|
|
|
|
if (utils::isValidHumidity(_humidity[ch].update.avg)) {
|
|
|
|
if (utils::isValidHumidity(_humidity[ch].update.avg)) {
|
|
|
|
pms[json_prop_rhum] = ag.round2(_humidity[ch].update.avg);
|
|
|
|
pms[json_prop_rhum] = ag->round2(_humidity[ch].update.avg);
|
|
|
|
// Compensate relative humidity when flag is set
|
|
|
|
// Compensate relative humidity when flag is set
|
|
|
|
if (compensate) {
|
|
|
|
if (compensate) {
|
|
|
|
_vc = ag.pms5003t_1.compensateHum(_humidity[ch].update.avg);
|
|
|
|
_vc = ag->pms5003t_1.compensateHum(_humidity[ch].update.avg);
|
|
|
|
if (utils::isValidTemperature(_vc)) {
|
|
|
|
if (utils::isValidTemperature(_vc)) {
|
|
|
|
pms[json_prop_rhumCompensated] = ag.round2(_vc);
|
|
|
|
pms[json_prop_rhumCompensated] = ag->round2(_vc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -858,9 +858,9 @@ JSONVar Measurements::buildPMS(AirGradient &ag, int ch, bool allCh, bool withTem
|
|
|
|
utils::isValidHumidity(_humidity[ch].update.avg)) {
|
|
|
|
utils::isValidHumidity(_humidity[ch].update.avg)) {
|
|
|
|
// Note: the pms5003t object is not matter either for channel 1 or 2, compensate points to
|
|
|
|
// Note: the pms5003t object is not matter either for channel 1 or 2, compensate points to
|
|
|
|
// the same base function
|
|
|
|
// the same base function
|
|
|
|
float pm25 = ag.pms5003t_1.compensate(_pm_25[ch].update.avg, _humidity[ch].update.avg);
|
|
|
|
float pm25 = ag->pms5003t_1.compensate(_pm_25[ch].update.avg, _humidity[ch].update.avg);
|
|
|
|
if (utils::isValidPm(pm25)) {
|
|
|
|
if (utils::isValidPm(pm25)) {
|
|
|
|
pms[json_prop_pm25Compensated] = ag.round2(pm25);
|
|
|
|
pms[json_prop_pm25Compensated] = ag->round2(pm25);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -876,144 +876,144 @@ JSONVar Measurements::buildPMS(AirGradient &ag, int ch, bool allCh, bool withTem
|
|
|
|
/// PM1.0 atmospheric environment
|
|
|
|
/// PM1.0 atmospheric environment
|
|
|
|
if (utils::isValidPm(_pm_01[0].update.avg) && utils::isValidPm(_pm_01[1].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_01[0].update.avg) && utils::isValidPm(_pm_01[1].update.avg)) {
|
|
|
|
float avg = (_pm_01[0].update.avg + _pm_01[1].update.avg) / 2.0f;
|
|
|
|
float avg = (_pm_01[0].update.avg + _pm_01[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_pm01Ae] = ag.round2(avg);
|
|
|
|
pms[json_prop_pm01Ae] = ag->round2(avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm01Ae] = ag.round2(_pm_01[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm01Ae] = ag->round2(_pm_01[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm01Ae] = ag.round2(_pm_01[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm01Ae] = ag->round2(_pm_01[1].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_01[0].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_01[0].update.avg)) {
|
|
|
|
pms[json_prop_pm01Ae] = ag.round2(_pm_01[0].update.avg);
|
|
|
|
pms[json_prop_pm01Ae] = ag->round2(_pm_01[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm01Ae] = ag.round2(_pm_01[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm01Ae] = ag->round2(_pm_01[0].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_01[1].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_01[1].update.avg)) {
|
|
|
|
pms[json_prop_pm01Ae] = ag.round2(_pm_01[1].update.avg);
|
|
|
|
pms[json_prop_pm01Ae] = ag->round2(_pm_01[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm01Ae] = ag.round2(_pm_01[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm01Ae] = ag->round2(_pm_01[1].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// PM2.5 atmospheric environment
|
|
|
|
/// PM2.5 atmospheric environment
|
|
|
|
if (utils::isValidPm(_pm_25[0].update.avg) && utils::isValidPm(_pm_25[1].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_25[0].update.avg) && utils::isValidPm(_pm_25[1].update.avg)) {
|
|
|
|
float avg = (_pm_25[0].update.avg + _pm_25[1].update.avg) / 2.0f;
|
|
|
|
float avg = (_pm_25[0].update.avg + _pm_25[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_pm25Ae] = ag.round2(avg);
|
|
|
|
pms[json_prop_pm25Ae] = ag->round2(avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Ae] = ag.round2(_pm_25[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Ae] = ag->round2(_pm_25[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Ae] = ag.round2(_pm_25[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Ae] = ag->round2(_pm_25[1].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_25[0].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_25[0].update.avg)) {
|
|
|
|
pms[json_prop_pm25Ae] = ag.round2(_pm_25[0].update.avg);
|
|
|
|
pms[json_prop_pm25Ae] = ag->round2(_pm_25[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Ae] = ag.round2(_pm_25[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Ae] = ag->round2(_pm_25[0].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_25[1].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_25[1].update.avg)) {
|
|
|
|
pms[json_prop_pm25Ae] = ag.round2(_pm_25[1].update.avg);
|
|
|
|
pms[json_prop_pm25Ae] = ag->round2(_pm_25[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Ae] = ag.round2(_pm_25[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Ae] = ag->round2(_pm_25[1].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// PM10 atmospheric environment
|
|
|
|
/// PM10 atmospheric environment
|
|
|
|
if (utils::isValidPm(_pm_10[0].update.avg) && utils::isValidPm(_pm_10[1].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_10[0].update.avg) && utils::isValidPm(_pm_10[1].update.avg)) {
|
|
|
|
float avg = (_pm_10[0].update.avg + _pm_10[1].update.avg) / 2.0f;
|
|
|
|
float avg = (_pm_10[0].update.avg + _pm_10[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_pm10Ae] = ag.round2(avg);
|
|
|
|
pms[json_prop_pm10Ae] = ag->round2(avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm10Ae] = ag.round2(_pm_10[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm10Ae] = ag->round2(_pm_10[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm10Ae] = ag.round2(_pm_10[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm10Ae] = ag->round2(_pm_10[1].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_10[0].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_10[0].update.avg)) {
|
|
|
|
pms[json_prop_pm10Ae] = ag.round2(_pm_10[0].update.avg);
|
|
|
|
pms[json_prop_pm10Ae] = ag->round2(_pm_10[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm10Ae] = ag.round2(_pm_10[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm10Ae] = ag->round2(_pm_10[0].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_10[1].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_10[1].update.avg)) {
|
|
|
|
pms[json_prop_pm10Ae] = ag.round2(_pm_10[1].update.avg);
|
|
|
|
pms[json_prop_pm10Ae] = ag->round2(_pm_10[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm10Ae] = ag.round2(_pm_10[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm10Ae] = ag->round2(_pm_10[1].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// PM1.0 standard particle
|
|
|
|
/// PM1.0 standard particle
|
|
|
|
if (utils::isValidPm(_pm_01_sp[0].update.avg) && utils::isValidPm(_pm_01_sp[1].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_01_sp[0].update.avg) && utils::isValidPm(_pm_01_sp[1].update.avg)) {
|
|
|
|
float avg = (_pm_01_sp[0].update.avg + _pm_01_sp[1].update.avg) / 2.0f;
|
|
|
|
float avg = (_pm_01_sp[0].update.avg + _pm_01_sp[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_pm01Sp] = ag.round2(avg);
|
|
|
|
pms[json_prop_pm01Sp] = ag->round2(avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm01Sp] = ag.round2(_pm_01_sp[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm01Sp] = ag->round2(_pm_01_sp[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm01Sp] = ag.round2(_pm_01_sp[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm01Sp] = ag->round2(_pm_01_sp[1].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_01_sp[0].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_01_sp[0].update.avg)) {
|
|
|
|
pms[json_prop_pm01Sp] = ag.round2(_pm_01_sp[0].update.avg);
|
|
|
|
pms[json_prop_pm01Sp] = ag->round2(_pm_01_sp[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm01Sp] = ag.round2(_pm_01_sp[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm01Sp] = ag->round2(_pm_01_sp[0].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_01_sp[1].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_01_sp[1].update.avg)) {
|
|
|
|
pms[json_prop_pm01Sp] = ag.round2(_pm_01_sp[1].update.avg);
|
|
|
|
pms[json_prop_pm01Sp] = ag->round2(_pm_01_sp[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm01Sp] = ag.round2(_pm_01_sp[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm01Sp] = ag->round2(_pm_01_sp[1].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// PM2.5 standard particle
|
|
|
|
/// PM2.5 standard particle
|
|
|
|
if (utils::isValidPm(_pm_25_sp[0].update.avg) && utils::isValidPm(_pm_25_sp[1].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_25_sp[0].update.avg) && utils::isValidPm(_pm_25_sp[1].update.avg)) {
|
|
|
|
float avg = (_pm_25_sp[0].update.avg + _pm_25_sp[1].update.avg) / 2.0f;
|
|
|
|
float avg = (_pm_25_sp[0].update.avg + _pm_25_sp[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_pm25Sp] = ag.round2(avg);
|
|
|
|
pms[json_prop_pm25Sp] = ag->round2(avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Sp] = ag.round2(_pm_25_sp[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Sp] = ag->round2(_pm_25_sp[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Sp] = ag.round2(_pm_25_sp[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Sp] = ag->round2(_pm_25_sp[1].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_25_sp[0].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_25_sp[0].update.avg)) {
|
|
|
|
pms[json_prop_pm25Sp] = ag.round2(_pm_25_sp[0].update.avg);
|
|
|
|
pms[json_prop_pm25Sp] = ag->round2(_pm_25_sp[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Sp] = ag.round2(_pm_25_sp[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Sp] = ag->round2(_pm_25_sp[0].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_25_sp[1].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_25_sp[1].update.avg)) {
|
|
|
|
pms[json_prop_pm25Sp] = ag.round2(_pm_25_sp[1].update.avg);
|
|
|
|
pms[json_prop_pm25Sp] = ag->round2(_pm_25_sp[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Sp] = ag.round2(_pm_25_sp[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Sp] = ag->round2(_pm_25_sp[1].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// PM10 standard particle
|
|
|
|
/// PM10 standard particle
|
|
|
|
if (utils::isValidPm(_pm_10_sp[0].update.avg) && utils::isValidPm(_pm_10_sp[1].update.avg)) {
|
|
|
|
if (utils::isValidPm(_pm_10_sp[0].update.avg) && utils::isValidPm(_pm_10_sp[1].update.avg)) {
|
|
|
|
float avg = (_pm_10_sp[0].update.avg + _pm_10_sp[1].update.avg) / 2.0f;
|
|
|
|
float avg = (_pm_10_sp[0].update.avg + _pm_10_sp[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_pm10Sp] = ag.round2(avg);
|
|
|
|
pms[json_prop_pm10Sp] = ag->round2(avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm10Sp] = ag.round2(_pm_10_sp[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm10Sp] = ag->round2(_pm_10_sp[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm10Sp] = ag.round2(_pm_10_sp[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm10Sp] = ag->round2(_pm_10_sp[1].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_10_sp[0].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_10_sp[0].update.avg)) {
|
|
|
|
pms[json_prop_pm10Sp] = ag.round2(_pm_10_sp[0].update.avg);
|
|
|
|
pms[json_prop_pm10Sp] = ag->round2(_pm_10_sp[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm10Sp] = ag.round2(_pm_10_sp[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm10Sp] = ag->round2(_pm_10_sp[0].update.avg);
|
|
|
|
} else if (utils::isValidPm(_pm_10_sp[1].update.avg)) {
|
|
|
|
} else if (utils::isValidPm(_pm_10_sp[1].update.avg)) {
|
|
|
|
pms[json_prop_pm10Sp] = ag.round2(_pm_10_sp[1].update.avg);
|
|
|
|
pms[json_prop_pm10Sp] = ag->round2(_pm_10_sp[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm10Sp] = ag.round2(_pm_10_sp[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm10Sp] = ag->round2(_pm_10_sp[1].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// PM003 particle count
|
|
|
|
/// PM003 particle count
|
|
|
|
if (utils::isValidPm03Count(_pm_03_pc[0].update.avg) &&
|
|
|
|
if (utils::isValidPm03Count(_pm_03_pc[0].update.avg) &&
|
|
|
|
utils::isValidPm03Count(_pm_03_pc[1].update.avg)) {
|
|
|
|
utils::isValidPm03Count(_pm_03_pc[1].update.avg)) {
|
|
|
|
float avg = (_pm_03_pc[0].update.avg + _pm_03_pc[1].update.avg) / 2.0f;
|
|
|
|
float avg = (_pm_03_pc[0].update.avg + _pm_03_pc[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_pm03Count] = ag.round2(avg);
|
|
|
|
pms[json_prop_pm03Count] = ag->round2(avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm03Count] = ag.round2(_pm_03_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm03Count] = ag->round2(_pm_03_pc[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm03Count] = ag.round2(_pm_03_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm03Count] = ag->round2(_pm_03_pc[1].update.avg);
|
|
|
|
} else if (utils::isValidPm03Count(_pm_03_pc[0].update.avg)) {
|
|
|
|
} else if (utils::isValidPm03Count(_pm_03_pc[0].update.avg)) {
|
|
|
|
pms[json_prop_pm03Count] = ag.round2(_pm_03_pc[0].update.avg);
|
|
|
|
pms[json_prop_pm03Count] = ag->round2(_pm_03_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm03Count] = ag.round2(_pm_03_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm03Count] = ag->round2(_pm_03_pc[0].update.avg);
|
|
|
|
} else if (utils::isValidPm03Count(_pm_03_pc[1].update.avg)) {
|
|
|
|
} else if (utils::isValidPm03Count(_pm_03_pc[1].update.avg)) {
|
|
|
|
pms[json_prop_pm03Count] = ag.round2(_pm_03_pc[1].update.avg);
|
|
|
|
pms[json_prop_pm03Count] = ag->round2(_pm_03_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm03Count] = ag.round2(_pm_03_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm03Count] = ag->round2(_pm_03_pc[1].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// PM0.5 particle count
|
|
|
|
/// PM0.5 particle count
|
|
|
|
if (utils::isValidPm03Count(_pm_05_pc[0].update.avg) &&
|
|
|
|
if (utils::isValidPm03Count(_pm_05_pc[0].update.avg) &&
|
|
|
|
utils::isValidPm03Count(_pm_05_pc[1].update.avg)) {
|
|
|
|
utils::isValidPm03Count(_pm_05_pc[1].update.avg)) {
|
|
|
|
float avg = (_pm_05_pc[0].update.avg + _pm_05_pc[1].update.avg) / 2.0f;
|
|
|
|
float avg = (_pm_05_pc[0].update.avg + _pm_05_pc[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_pm05Count] = ag.round2(avg);
|
|
|
|
pms[json_prop_pm05Count] = ag->round2(avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm05Count] = ag.round2(_pm_05_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm05Count] = ag->round2(_pm_05_pc[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm05Count] = ag.round2(_pm_05_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm05Count] = ag->round2(_pm_05_pc[1].update.avg);
|
|
|
|
} else if (utils::isValidPm03Count(_pm_05_pc[0].update.avg)) {
|
|
|
|
} else if (utils::isValidPm03Count(_pm_05_pc[0].update.avg)) {
|
|
|
|
pms[json_prop_pm05Count] = ag.round2(_pm_05_pc[0].update.avg);
|
|
|
|
pms[json_prop_pm05Count] = ag->round2(_pm_05_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm05Count] = ag.round2(_pm_05_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm05Count] = ag->round2(_pm_05_pc[0].update.avg);
|
|
|
|
} else if (utils::isValidPm03Count(_pm_05_pc[1].update.avg)) {
|
|
|
|
} else if (utils::isValidPm03Count(_pm_05_pc[1].update.avg)) {
|
|
|
|
pms[json_prop_pm05Count] = ag.round2(_pm_05_pc[1].update.avg);
|
|
|
|
pms[json_prop_pm05Count] = ag->round2(_pm_05_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm05Count] = ag.round2(_pm_05_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm05Count] = ag->round2(_pm_05_pc[1].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// PM1.0 particle count
|
|
|
|
/// PM1.0 particle count
|
|
|
|
if (utils::isValidPm03Count(_pm_01_pc[0].update.avg) &&
|
|
|
|
if (utils::isValidPm03Count(_pm_01_pc[0].update.avg) &&
|
|
|
|
utils::isValidPm03Count(_pm_01_pc[1].update.avg)) {
|
|
|
|
utils::isValidPm03Count(_pm_01_pc[1].update.avg)) {
|
|
|
|
float avg = (_pm_01_pc[0].update.avg + _pm_01_pc[1].update.avg) / 2.0f;
|
|
|
|
float avg = (_pm_01_pc[0].update.avg + _pm_01_pc[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_pm1Count] = ag.round2(avg);
|
|
|
|
pms[json_prop_pm1Count] = ag->round2(avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm1Count] = ag.round2(_pm_01_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm1Count] = ag->round2(_pm_01_pc[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm1Count] = ag.round2(_pm_01_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm1Count] = ag->round2(_pm_01_pc[1].update.avg);
|
|
|
|
} else if (utils::isValidPm03Count(_pm_01_pc[0].update.avg)) {
|
|
|
|
} else if (utils::isValidPm03Count(_pm_01_pc[0].update.avg)) {
|
|
|
|
pms[json_prop_pm1Count] = ag.round2(_pm_01_pc[0].update.avg);
|
|
|
|
pms[json_prop_pm1Count] = ag->round2(_pm_01_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm1Count] = ag.round2(_pm_01_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm1Count] = ag->round2(_pm_01_pc[0].update.avg);
|
|
|
|
} else if (utils::isValidPm03Count(_pm_01_pc[1].update.avg)) {
|
|
|
|
} else if (utils::isValidPm03Count(_pm_01_pc[1].update.avg)) {
|
|
|
|
pms[json_prop_pm1Count] = ag.round2(_pm_01_pc[1].update.avg);
|
|
|
|
pms[json_prop_pm1Count] = ag->round2(_pm_01_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm1Count] = ag.round2(_pm_01_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm1Count] = ag->round2(_pm_01_pc[1].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// PM2.5 particle count
|
|
|
|
/// PM2.5 particle count
|
|
|
|
if (utils::isValidPm03Count(_pm_25_pc[0].update.avg) &&
|
|
|
|
if (utils::isValidPm03Count(_pm_25_pc[0].update.avg) &&
|
|
|
|
utils::isValidPm03Count(_pm_25_pc[1].update.avg)) {
|
|
|
|
utils::isValidPm03Count(_pm_25_pc[1].update.avg)) {
|
|
|
|
float avg = (_pm_25_pc[0].update.avg + _pm_25_pc[1].update.avg) / 2.0f;
|
|
|
|
float avg = (_pm_25_pc[0].update.avg + _pm_25_pc[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_pm25Count] = ag.round2(avg);
|
|
|
|
pms[json_prop_pm25Count] = ag->round2(avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Count] = ag.round2(_pm_25_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Count] = ag->round2(_pm_25_pc[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Count] = ag.round2(_pm_25_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Count] = ag->round2(_pm_25_pc[1].update.avg);
|
|
|
|
} else if (utils::isValidPm03Count(_pm_25_pc[0].update.avg)) {
|
|
|
|
} else if (utils::isValidPm03Count(_pm_25_pc[0].update.avg)) {
|
|
|
|
pms[json_prop_pm25Count] = ag.round2(_pm_25_pc[0].update.avg);
|
|
|
|
pms[json_prop_pm25Count] = ag->round2(_pm_25_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Count] = ag.round2(_pm_25_pc[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Count] = ag->round2(_pm_25_pc[0].update.avg);
|
|
|
|
} else if (utils::isValidPm03Count(_pm_25_pc[1].update.avg)) {
|
|
|
|
} else if (utils::isValidPm03Count(_pm_25_pc[1].update.avg)) {
|
|
|
|
pms[json_prop_pm25Count] = ag.round2(_pm_25_pc[1].update.avg);
|
|
|
|
pms[json_prop_pm25Count] = ag->round2(_pm_25_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Count] = ag.round2(_pm_25_pc[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Count] = ag->round2(_pm_25_pc[1].update.avg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: No need for particle count 5.0 and 10. When allCh is true, basically monitor using
|
|
|
|
// NOTE: No need for particle count 5.0 and 10. When allCh is true, basically monitor using
|
|
|
@ -1025,40 +1025,40 @@ JSONVar Measurements::buildPMS(AirGradient &ag, int ch, bool allCh, bool withTem
|
|
|
|
utils::isValidTemperature(_temperature[1].update.avg)) {
|
|
|
|
utils::isValidTemperature(_temperature[1].update.avg)) {
|
|
|
|
|
|
|
|
|
|
|
|
float temperature = (_temperature[0].update.avg + _temperature[1].update.avg) / 2.0f;
|
|
|
|
float temperature = (_temperature[0].update.avg + _temperature[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_temp] = ag.round2(temperature);
|
|
|
|
pms[json_prop_temp] = ag->round2(temperature);
|
|
|
|
pms["channels"]["1"][json_prop_temp] = ag.round2(_temperature[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_temp] = ag->round2(_temperature[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_temp] = ag.round2(_temperature[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_temp] = ag->round2(_temperature[1].update.avg);
|
|
|
|
|
|
|
|
|
|
|
|
if (compensate) {
|
|
|
|
if (compensate) {
|
|
|
|
// Compensate both temperature channel
|
|
|
|
// Compensate both temperature channel
|
|
|
|
float temp = ag.pms5003t_1.compensateTemp(temperature);
|
|
|
|
float temp = ag->pms5003t_1.compensateTemp(temperature);
|
|
|
|
float temp1 = ag.pms5003t_1.compensateTemp(_temperature[0].update.avg);
|
|
|
|
float temp1 = ag->pms5003t_1.compensateTemp(_temperature[0].update.avg);
|
|
|
|
float temp2 = ag.pms5003t_2.compensateTemp(_temperature[1].update.avg);
|
|
|
|
float temp2 = ag->pms5003t_2.compensateTemp(_temperature[1].update.avg);
|
|
|
|
pms[json_prop_tempCompensated] = ag.round2(temp);
|
|
|
|
pms[json_prop_tempCompensated] = ag->round2(temp);
|
|
|
|
pms["channels"]["1"][json_prop_tempCompensated] = ag.round2(temp1);
|
|
|
|
pms["channels"]["1"][json_prop_tempCompensated] = ag->round2(temp1);
|
|
|
|
pms["channels"]["2"][json_prop_tempCompensated] = ag.round2(temp2);
|
|
|
|
pms["channels"]["2"][json_prop_tempCompensated] = ag->round2(temp2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (utils::isValidTemperature(_temperature[0].update.avg)) {
|
|
|
|
} else if (utils::isValidTemperature(_temperature[0].update.avg)) {
|
|
|
|
pms[json_prop_temp] = ag.round2(_temperature[0].update.avg);
|
|
|
|
pms[json_prop_temp] = ag->round2(_temperature[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_temp] = ag.round2(_temperature[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_temp] = ag->round2(_temperature[0].update.avg);
|
|
|
|
|
|
|
|
|
|
|
|
if (compensate) {
|
|
|
|
if (compensate) {
|
|
|
|
// Compensate channel 1
|
|
|
|
// Compensate channel 1
|
|
|
|
float temp1 = ag.pms5003t_1.compensateTemp(_temperature[0].update.avg);
|
|
|
|
float temp1 = ag->pms5003t_1.compensateTemp(_temperature[0].update.avg);
|
|
|
|
pms[json_prop_tempCompensated] = ag.round2(temp1);
|
|
|
|
pms[json_prop_tempCompensated] = ag->round2(temp1);
|
|
|
|
pms["channels"]["1"][json_prop_tempCompensated] = ag.round2(temp1);
|
|
|
|
pms["channels"]["1"][json_prop_tempCompensated] = ag->round2(temp1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (utils::isValidTemperature(_temperature[1].update.avg)) {
|
|
|
|
} else if (utils::isValidTemperature(_temperature[1].update.avg)) {
|
|
|
|
pms[json_prop_temp] = ag.round2(_temperature[1].update.avg);
|
|
|
|
pms[json_prop_temp] = ag->round2(_temperature[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_temp] = ag.round2(_temperature[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_temp] = ag->round2(_temperature[1].update.avg);
|
|
|
|
|
|
|
|
|
|
|
|
if (compensate) {
|
|
|
|
if (compensate) {
|
|
|
|
// Compensate channel 2
|
|
|
|
// Compensate channel 2
|
|
|
|
float temp2 = ag.pms5003t_2.compensateTemp(_temperature[1].update.avg);
|
|
|
|
float temp2 = ag->pms5003t_2.compensateTemp(_temperature[1].update.avg);
|
|
|
|
pms[json_prop_tempCompensated] = ag.round2(temp2);
|
|
|
|
pms[json_prop_tempCompensated] = ag->round2(temp2);
|
|
|
|
pms["channels"]["2"][json_prop_tempCompensated] = ag.round2(temp2);
|
|
|
|
pms["channels"]["2"][json_prop_tempCompensated] = ag->round2(temp2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1066,40 +1066,40 @@ JSONVar Measurements::buildPMS(AirGradient &ag, int ch, bool allCh, bool withTem
|
|
|
|
if (utils::isValidHumidity(_humidity[0].update.avg) &&
|
|
|
|
if (utils::isValidHumidity(_humidity[0].update.avg) &&
|
|
|
|
utils::isValidHumidity(_humidity[1].update.avg)) {
|
|
|
|
utils::isValidHumidity(_humidity[1].update.avg)) {
|
|
|
|
float humidity = (_humidity[0].update.avg + _humidity[1].update.avg) / 2.0f;
|
|
|
|
float humidity = (_humidity[0].update.avg + _humidity[1].update.avg) / 2.0f;
|
|
|
|
pms[json_prop_rhum] = ag.round2(humidity);
|
|
|
|
pms[json_prop_rhum] = ag->round2(humidity);
|
|
|
|
pms["channels"]["1"][json_prop_rhum] = ag.round2(_humidity[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_rhum] = ag->round2(_humidity[0].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_rhum] = ag.round2(_humidity[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_rhum] = ag->round2(_humidity[1].update.avg);
|
|
|
|
|
|
|
|
|
|
|
|
if (compensate) {
|
|
|
|
if (compensate) {
|
|
|
|
// Compensate both humidity channel
|
|
|
|
// Compensate both humidity channel
|
|
|
|
float hum = ag.pms5003t_1.compensateHum(humidity);
|
|
|
|
float hum = ag->pms5003t_1.compensateHum(humidity);
|
|
|
|
float hum1 = ag.pms5003t_1.compensateHum(_humidity[0].update.avg);
|
|
|
|
float hum1 = ag->pms5003t_1.compensateHum(_humidity[0].update.avg);
|
|
|
|
float hum2 = ag.pms5003t_2.compensateHum(_humidity[1].update.avg);
|
|
|
|
float hum2 = ag->pms5003t_2.compensateHum(_humidity[1].update.avg);
|
|
|
|
pms[json_prop_rhumCompensated] = ag.round2(hum);
|
|
|
|
pms[json_prop_rhumCompensated] = ag->round2(hum);
|
|
|
|
pms["channels"]["1"][json_prop_rhumCompensated] = ag.round2(hum1);
|
|
|
|
pms["channels"]["1"][json_prop_rhumCompensated] = ag->round2(hum1);
|
|
|
|
pms["channels"]["2"][json_prop_rhumCompensated] = ag.round2(hum2);
|
|
|
|
pms["channels"]["2"][json_prop_rhumCompensated] = ag->round2(hum2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (utils::isValidHumidity(_humidity[0].update.avg)) {
|
|
|
|
} else if (utils::isValidHumidity(_humidity[0].update.avg)) {
|
|
|
|
pms[json_prop_rhum] = ag.round2(_humidity[0].update.avg);
|
|
|
|
pms[json_prop_rhum] = ag->round2(_humidity[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_rhum] = ag.round2(_humidity[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_rhum] = ag->round2(_humidity[0].update.avg);
|
|
|
|
|
|
|
|
|
|
|
|
if (compensate) {
|
|
|
|
if (compensate) {
|
|
|
|
// Compensate humidity channel 1
|
|
|
|
// Compensate humidity channel 1
|
|
|
|
float hum1 = ag.pms5003t_1.compensateHum(_humidity[0].update.avg);
|
|
|
|
float hum1 = ag->pms5003t_1.compensateHum(_humidity[0].update.avg);
|
|
|
|
pms[json_prop_rhumCompensated] = ag.round2(hum1);
|
|
|
|
pms[json_prop_rhumCompensated] = ag->round2(hum1);
|
|
|
|
pms["channels"]["1"][json_prop_rhumCompensated] = ag.round2(hum1);
|
|
|
|
pms["channels"]["1"][json_prop_rhumCompensated] = ag->round2(hum1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (utils::isValidHumidity(_humidity[1].update.avg)) {
|
|
|
|
} else if (utils::isValidHumidity(_humidity[1].update.avg)) {
|
|
|
|
pms[json_prop_rhum] = ag.round2(_humidity[1].update.avg);
|
|
|
|
pms[json_prop_rhum] = ag->round2(_humidity[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_rhum] = ag.round2(_humidity[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_rhum] = ag->round2(_humidity[1].update.avg);
|
|
|
|
|
|
|
|
|
|
|
|
if (compensate) {
|
|
|
|
if (compensate) {
|
|
|
|
// Compensate humidity channel 2
|
|
|
|
// Compensate humidity channel 2
|
|
|
|
float hum2 = ag.pms5003t_2.compensateHum(_humidity[1].update.avg);
|
|
|
|
float hum2 = ag->pms5003t_2.compensateHum(_humidity[1].update.avg);
|
|
|
|
pms[json_prop_rhumCompensated] = ag.round2(hum2);
|
|
|
|
pms[json_prop_rhumCompensated] = ag->round2(hum2);
|
|
|
|
pms["channels"]["2"][json_prop_rhumCompensated] = ag.round2(hum2);
|
|
|
|
pms["channels"]["2"][json_prop_rhumCompensated] = ag->round2(hum2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1110,22 +1110,22 @@ JSONVar Measurements::buildPMS(AirGradient &ag, int ch, bool allCh, bool withTem
|
|
|
|
float pm25_comp2 = utils::getInvalidPmValue();
|
|
|
|
float pm25_comp2 = utils::getInvalidPmValue();
|
|
|
|
if (utils::isValidPm(_pm_25[0].update.avg) &&
|
|
|
|
if (utils::isValidPm(_pm_25[0].update.avg) &&
|
|
|
|
utils::isValidHumidity(_humidity[0].update.avg)) {
|
|
|
|
utils::isValidHumidity(_humidity[0].update.avg)) {
|
|
|
|
pm25_comp1 = ag.pms5003t_1.compensate(_pm_25[0].update.avg, _humidity[0].update.avg);
|
|
|
|
pm25_comp1 = ag->pms5003t_1.compensate(_pm_25[0].update.avg, _humidity[0].update.avg);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Compensated] = ag.round2(pm25_comp1);
|
|
|
|
pms["channels"]["1"][json_prop_pm25Compensated] = ag->round2(pm25_comp1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (utils::isValidPm(_pm_25[1].update.avg) &&
|
|
|
|
if (utils::isValidPm(_pm_25[1].update.avg) &&
|
|
|
|
utils::isValidHumidity(_humidity[1].update.avg)) {
|
|
|
|
utils::isValidHumidity(_humidity[1].update.avg)) {
|
|
|
|
pm25_comp2 = ag.pms5003t_2.compensate(_pm_25[1].update.avg, _humidity[1].update.avg);
|
|
|
|
pm25_comp2 = ag->pms5003t_2.compensate(_pm_25[1].update.avg, _humidity[1].update.avg);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Compensated] = ag.round2(pm25_comp2);
|
|
|
|
pms["channels"]["2"][json_prop_pm25Compensated] = ag->round2(pm25_comp2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Get average or one of the channel compensated value if only one channel is valid
|
|
|
|
/// Get average or one of the channel compensated value if only one channel is valid
|
|
|
|
if (utils::isValidPm(pm25_comp1) && utils::isValidPm(pm25_comp2)) {
|
|
|
|
if (utils::isValidPm(pm25_comp1) && utils::isValidPm(pm25_comp2)) {
|
|
|
|
pms[json_prop_pm25Compensated] = ag.round2((pm25_comp1 + pm25_comp2) / 2.0f);
|
|
|
|
pms[json_prop_pm25Compensated] = ag->round2((pm25_comp1 + pm25_comp2) / 2.0f);
|
|
|
|
} else if (utils::isValidPm(pm25_comp1)) {
|
|
|
|
} else if (utils::isValidPm(pm25_comp1)) {
|
|
|
|
pms[json_prop_pm25Compensated] = ag.round2(pm25_comp1);
|
|
|
|
pms[json_prop_pm25Compensated] = ag->round2(pm25_comp1);
|
|
|
|
} else if (utils::isValidPm(pm25_comp2)) {
|
|
|
|
} else if (utils::isValidPm(pm25_comp2)) {
|
|
|
|
pms[json_prop_pm25Compensated] = ag.round2(pm25_comp2);
|
|
|
|
pms[json_prop_pm25Compensated] = ag->round2(pm25_comp2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|