mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-03 19:26:32 +02:00
Update OpenMetrics with compensated values
This commit is contained in:
@ -71,6 +71,8 @@ String OpenMetrics::getPayload(void) {
|
|||||||
int pm25 = -1;
|
int pm25 = -1;
|
||||||
int pm10 = -1;
|
int pm10 = -1;
|
||||||
int pm03PCount = -1;
|
int pm03PCount = -1;
|
||||||
|
int atmpCompensated = -1;
|
||||||
|
int ahumCompensated = -1;
|
||||||
if (config.hasSensorPMS1 && config.hasSensorPMS2) {
|
if (config.hasSensorPMS1 && config.hasSensorPMS2) {
|
||||||
_temp = (measure.temp_1 + measure.temp_2) / 2.0f;
|
_temp = (measure.temp_1 + measure.temp_2) / 2.0f;
|
||||||
_hum = (measure.hum_1 + measure.hum_2) / 2.0f;
|
_hum = (measure.hum_1 + measure.hum_2) / 2.0f;
|
||||||
@ -104,6 +106,15 @@ String OpenMetrics::getPayload(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get temperature and humidity compensated */
|
||||||
|
if (ag->isOne()) {
|
||||||
|
atmpCompensated = _temp;
|
||||||
|
ahumCompensated = _hum;
|
||||||
|
} else {
|
||||||
|
atmpCompensated = ag->pms5003t_1.temperatureCompensated(_temp);
|
||||||
|
ahumCompensated = ag->pms5003t_1.humidityCompensated(_hum);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.hasSensorPMS1 || config.hasSensorPMS2) {
|
if (config.hasSensorPMS1 || config.hasSensorPMS2) {
|
||||||
if (pm01 >= 0) {
|
if (pm01 >= 0) {
|
||||||
add_metric("pm1",
|
add_metric("pm1",
|
||||||
@ -173,6 +184,13 @@ String OpenMetrics::getPayload(void) {
|
|||||||
"gauge", "celsius");
|
"gauge", "celsius");
|
||||||
add_metric_point("", String(_temp));
|
add_metric_point("", String(_temp));
|
||||||
}
|
}
|
||||||
|
if (atmpCompensated > -1001) {
|
||||||
|
add_metric(
|
||||||
|
"temperature_compensated",
|
||||||
|
"The ambient temperature as measured by the AirGradient SHT / PMS",
|
||||||
|
"gauge", "celsius");
|
||||||
|
add_metric_point("", String(atmpCompensated));
|
||||||
|
}
|
||||||
if (_hum >= 0) {
|
if (_hum >= 0) {
|
||||||
add_metric(
|
add_metric(
|
||||||
"humidity",
|
"humidity",
|
||||||
@ -180,6 +198,13 @@ String OpenMetrics::getPayload(void) {
|
|||||||
"gauge", "percent");
|
"gauge", "percent");
|
||||||
add_metric_point("", String(_hum));
|
add_metric_point("", String(_hum));
|
||||||
}
|
}
|
||||||
|
if (ahumCompensated >= 0) {
|
||||||
|
add_metric(
|
||||||
|
"humidity_compensated",
|
||||||
|
"The relative humidity as measured by the AirGradient SHT / PMS sensor",
|
||||||
|
"gauge", "percent");
|
||||||
|
add_metric_point("", String(ahumCompensated));
|
||||||
|
}
|
||||||
|
|
||||||
response += "# EOF\n";
|
response += "# EOF\n";
|
||||||
return response;
|
return response;
|
||||||
|
Reference in New Issue
Block a user