Added missing PM_1_0 and PM_10_0 for PMS5003T

Added missing PM_1_0 and PM_10_0 for PMS5003T
This commit is contained in:
R Huish 2023-03-14 16:29:43 +00:00
parent ee7102fcd1
commit 86084f7c61
2 changed files with 43 additions and 5 deletions

View file

@ -264,13 +264,51 @@ void PMSX003Component::parse_data_() {
break; break;
} }
case PMSX003_TYPE_5003T: { case PMSX003_TYPE_5003T: {
uint16_t pm_1_0_std_concentration = this->get_16_bit_uint_(4);
uint16_t pm_2_5_std_concentration = this->get_16_bit_uint_(6);
uint16_t pm_10_0_std_concentration = this->get_16_bit_uint_(8);
uint16_t pm_1_0_concentration = this->get_16_bit_uint_(10);
uint16_t pm_2_5_concentration = this->get_16_bit_uint_(12); uint16_t pm_2_5_concentration = this->get_16_bit_uint_(12);
uint16_t pm_10_0_concentration = this->get_16_bit_uint_(14);
uint16_t pm_particles_03um = this->get_16_bit_uint_(16);
uint16_t pm_particles_05um = this->get_16_bit_uint_(18);
uint16_t pm_particles_10um = this->get_16_bit_uint_(20);
uint16_t pm_particles_25um = this->get_16_bit_uint_(22);
// Note the pm particles 50um & 100um are not returned,
// as PMS5003T uses those data values for temperature and humidity.
float temperature = this->get_16_bit_uint_(24) / 10.0f; float temperature = this->get_16_bit_uint_(24) / 10.0f;
float humidity = this->get_16_bit_uint_(26) / 10.0f; float humidity = this->get_16_bit_uint_(26) / 10.0f;
ESP_LOGD(TAG, "Got PM2.5 Concentration: %u µg/m^3, Temperature: %.1f°C, Humidity: %.1f%%", pm_2_5_concentration,
temperature, humidity); ESP_LOGD(TAG,
"Got PM1.0 Concentration: %u µg/m^3, PM2.5 Concentration %u µg/m^3, PM10.0 Concentration: %u µg/m^3, Temperature: %.1f°C, Humidity: %.1f%%",
pm_1_0_concentration, pm_2_5_concentration, pm_10_0_concentration, temperature, humidity);
if (this->pm_1_0_std_sensor_ != nullptr)
this->pm_1_0_std_sensor_->publish_state(pm_1_0_std_concentration);
if (this->pm_2_5_std_sensor_ != nullptr)
this->pm_2_5_std_sensor_->publish_state(pm_2_5_std_concentration);
if (this->pm_10_0_std_sensor_ != nullptr)
this->pm_10_0_std_sensor_->publish_state(pm_10_0_std_concentration);
if (this->pm_1_0_sensor_ != nullptr)
this->pm_1_0_sensor_->publish_state(pm_1_0_concentration);
if (this->pm_2_5_sensor_ != nullptr) if (this->pm_2_5_sensor_ != nullptr)
this->pm_2_5_sensor_->publish_state(pm_2_5_concentration); this->pm_2_5_sensor_->publish_state(pm_2_5_concentration);
if (this->pm_10_0_sensor_ != nullptr)
this->pm_10_0_sensor_->publish_state(pm_10_0_concentration);
if (this->pm_particles_03um_sensor_ != nullptr)
this->pm_particles_03um_sensor_->publish_state(pm_particles_03um);
if (this->pm_particles_05um_sensor_ != nullptr)
this->pm_particles_05um_sensor_->publish_state(pm_particles_05um);
if (this->pm_particles_10um_sensor_ != nullptr)
this->pm_particles_10um_sensor_->publish_state(pm_particles_10um);
if (this->pm_particles_25um_sensor_ != nullptr)
this->pm_particles_25um_sensor_->publish_state(pm_particles_25um);
if (this->temperature_sensor_ != nullptr) if (this->temperature_sensor_ != nullptr)
this->temperature_sensor_->publish_state(temperature); this->temperature_sensor_->publish_state(temperature);
if (this->humidity_sensor_ != nullptr) if (this->humidity_sensor_ != nullptr)

View file

@ -55,9 +55,9 @@ PMSX003_TYPES = {
} }
SENSORS_TO_TYPE = { SENSORS_TO_TYPE = {
CONF_PM_1_0: [TYPE_PMSX003, TYPE_PMS5003ST, TYPE_PMS5003S], CONF_PM_1_0: [TYPE_PMSX003, TYPE_PMS5003T, TYPE_PMS5003ST, TYPE_PMS5003S],
CONF_PM_2_5: [TYPE_PMSX003, TYPE_PMS5003T, TYPE_PMS5003ST, TYPE_PMS5003S], CONF_PM_2_5: [TYPE_PMSX003, TYPE_PMS5003T, TYPE_PMS5003ST, TYPE_PMS5003S],
CONF_PM_10_0: [TYPE_PMSX003, TYPE_PMS5003ST, TYPE_PMS5003S], CONF_PM_10_0: [TYPE_PMSX003, TYPE_PMS5003T, TYPE_PMS5003ST, TYPE_PMS5003S],
CONF_TEMPERATURE: [TYPE_PMS5003T, TYPE_PMS5003ST], CONF_TEMPERATURE: [TYPE_PMS5003T, TYPE_PMS5003ST],
CONF_HUMIDITY: [TYPE_PMS5003T, TYPE_PMS5003ST], CONF_HUMIDITY: [TYPE_PMS5003T, TYPE_PMS5003ST],
CONF_FORMALDEHYDE: [TYPE_PMS5003ST, TYPE_PMS5003S], CONF_FORMALDEHYDE: [TYPE_PMS5003ST, TYPE_PMS5003S],