mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-14 16:36:31 +02:00
add atmp_compensated
and rhum_compensated
to sync data
This commit is contained in:
@ -631,6 +631,7 @@ static void boardInit(void) {
|
|||||||
} else {
|
} else {
|
||||||
openAirInit();
|
openAirInit();
|
||||||
}
|
}
|
||||||
|
localServer.setFwMode(fwMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void failedHandler(String msg) {
|
static void failedHandler(String msg) {
|
||||||
|
@ -42,9 +42,11 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|||||||
if (config->hasSensorSHT) {
|
if (config->hasSensorSHT) {
|
||||||
if (this->Temperature > -1001) {
|
if (this->Temperature > -1001) {
|
||||||
root["atmp"] = ag->round2(this->Temperature);
|
root["atmp"] = ag->round2(this->Temperature);
|
||||||
|
root["atmp_compensated"] = ag->round2(this->Temperature);
|
||||||
}
|
}
|
||||||
if (this->Humidity >= 0) {
|
if (this->Humidity >= 0) {
|
||||||
root["rhum"] = this->Humidity;
|
root["rhum"] = this->Humidity;
|
||||||
|
root["rhum_compensated"] = this->Humidity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +62,13 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|||||||
root["pm003_count"] =
|
root["pm003_count"] =
|
||||||
ag->round2((this->pm03PCount_1 + this->pm03PCount_2) / 2.0);
|
ag->round2((this->pm03PCount_1 + this->pm03PCount_2) / 2.0);
|
||||||
}
|
}
|
||||||
root["atmp"] = ag->round2((this->temp_1 + this->temp_2) / 2.0);
|
root["atmp"] = ag->round2((this->temp_1 + this->temp_2) / 2.0f);
|
||||||
root["rhum"] = ag->round2((this->hum_1 + this->hum_2) / 2.0);
|
root["rhum"] = ag->round2((this->hum_1 + this->hum_2) / 2.0f);
|
||||||
|
root["atmp_compensated"] =
|
||||||
|
ag->round2(ag->pms5003t_2.temperatureCompensated(
|
||||||
|
(this->temp_1 + this->temp_2) / 2.0f));
|
||||||
|
root["rhum_compensated"] = (int)ag->pms5003t_2.humidityCompensated(
|
||||||
|
(this->hum_1 + this->hum_2) / 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fwMode == FW_MDOE_O_1PS || fwMode == FW_MODE_O_1PST) {
|
if (fwMode == FW_MDOE_O_1PS || fwMode == FW_MODE_O_1PST) {
|
||||||
@ -76,6 +83,10 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|||||||
}
|
}
|
||||||
root["atmp"] = ag->round2(this->temp_1);
|
root["atmp"] = ag->round2(this->temp_1);
|
||||||
root["rhum"] = this->hum_1;
|
root["rhum"] = this->hum_1;
|
||||||
|
root["atmp_compensated"] =
|
||||||
|
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1));
|
||||||
|
root["rhum_compensated"] =
|
||||||
|
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
|
||||||
}
|
}
|
||||||
if (config->hasSensorPMS2) {
|
if (config->hasSensorPMS2) {
|
||||||
root["pm01"] = this->pm01_2;
|
root["pm01"] = this->pm01_2;
|
||||||
@ -88,6 +99,10 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|||||||
}
|
}
|
||||||
root["atmp"] = ag->round2(this->temp_2);
|
root["atmp"] = ag->round2(this->temp_2);
|
||||||
root["rhum"] = this->hum_2;
|
root["rhum"] = this->hum_2;
|
||||||
|
root["atmp_compensated"] =
|
||||||
|
ag->round2(ag->pms5003t_2.temperatureCompensated(this->temp_2));
|
||||||
|
root["rhum_compensated"] =
|
||||||
|
(int)ag->pms5003t_2.humidityCompensated(this->hum_2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (config->hasSensorPMS1) {
|
if (config->hasSensorPMS1) {
|
||||||
@ -101,6 +116,10 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|||||||
}
|
}
|
||||||
root["channels"]["1"]["atmp"] = ag->round2(this->temp_1);
|
root["channels"]["1"]["atmp"] = ag->round2(this->temp_1);
|
||||||
root["channels"]["1"]["rhum"] = this->hum_1;
|
root["channels"]["1"]["rhum"] = this->hum_1;
|
||||||
|
root["channels"]["1"]["atmp_compensated"] =
|
||||||
|
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_1));
|
||||||
|
root["channels"]["1"]["rhum_compensated"] =
|
||||||
|
(int)ag->pms5003t_1.humidityCompensated(this->hum_1);
|
||||||
}
|
}
|
||||||
if (config->hasSensorPMS2) {
|
if (config->hasSensorPMS2) {
|
||||||
root["channels"]["2"]["pm01"] = this->pm01_2;
|
root["channels"]["2"]["pm01"] = this->pm01_2;
|
||||||
@ -113,6 +132,10 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
|
|||||||
}
|
}
|
||||||
root["channels"]["2"]["atmp"] = ag->round2(this->temp_2);
|
root["channels"]["2"]["atmp"] = ag->round2(this->temp_2);
|
||||||
root["channels"]["2"]["rhum"] = this->hum_2;
|
root["channels"]["2"]["rhum"] = this->hum_2;
|
||||||
|
root["channels"]["2"]["atmp_compensated"] =
|
||||||
|
ag->round2(ag->pms5003t_1.temperatureCompensated(this->temp_2));
|
||||||
|
root["channels"]["2"]["rhum_compensated"] =
|
||||||
|
(int)ag->pms5003t_1.humidityCompensated(this->hum_2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,3 +201,19 @@ void PMS5003T::handle(void) { pms.handle(); }
|
|||||||
* @return false Communication timeout or sensor has removed
|
* @return false Communication timeout or sensor has removed
|
||||||
*/
|
*/
|
||||||
bool PMS5003T::isFailed(void) { return pms.isFailed(); }
|
bool PMS5003T::isFailed(void) { return pms.isFailed(); }
|
||||||
|
|
||||||
|
float PMS5003T::temperatureCompensated(float temp) {
|
||||||
|
if (temp < 10.0f) {
|
||||||
|
return temp * 1.327f - 6.738f;
|
||||||
|
}
|
||||||
|
return temp * 1.181f - 5.113f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float PMS5003T::humidityCompensated(float hum) {
|
||||||
|
hum = hum * 1.259f + 7.34f;
|
||||||
|
|
||||||
|
if (hum > 100.0f) {
|
||||||
|
hum = 100.0f;
|
||||||
|
}
|
||||||
|
return hum;
|
||||||
|
}
|
||||||
|
@ -28,6 +28,8 @@ public:
|
|||||||
int convertPm25ToUsAqi(int pm25);
|
int convertPm25ToUsAqi(int pm25);
|
||||||
float getTemperature(void);
|
float getTemperature(void);
|
||||||
float getRelativeHumidity(void);
|
float getRelativeHumidity(void);
|
||||||
|
float temperatureCompensated(float temp);
|
||||||
|
float humidityCompensated(float hum);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _isBegin = false;
|
bool _isBegin = false;
|
||||||
|
Reference in New Issue
Block a user