PMSX003 Particulate Matter Sensor

See Application::make_pmsx003().

API Reference

class PMSX003Component : public UARTDevice, public Component

Public Functions

PMSX003Component(UARTComponent *parent, PMSX003Type type)
void loop()

This method will be called repeatedly.

Analogous to Arduino’s loop(). setup() is guaranteed to be called before this. Defaults to doing nothing.

float get_setup_priority() const

priority of setup().

higher -> executed earlier

Defaults to 0.

Return
The setup priority of this component

PMSX003Sensor *make_pm_1_0_sensor(const std::string &name)
PMSX003Sensor *make_pm_2_5_sensor(const std::string &name)
PMSX003Sensor *make_pm_10_0_sensor(const std::string &name)
PMSX003Sensor *make_temperature_sensor(const std::string &name)
PMSX003Sensor *make_humidity_sensor(const std::string &name)
PMSX003Sensor *make_formaldehyde_sensor(const std::string &name)

Protected Functions

optional<bool> check_byte_()
void parse_data_()
uint16_t get_16_bit_uint_(uint8_t start_index)

Protected Attributes

uint8_t data_[64]
uint8_t data_index_ = {0}
uint32_t last_transmission_ = {0}
const PMSX003Type type_
PMSX003Sensor *pm_1_0_sensor_ = {nullptr}
PMSX003Sensor *pm_2_5_sensor_ = {nullptr}
PMSX003Sensor *pm_10_0_sensor_ = {nullptr}
PMSX003Sensor *temperature_sensor_ = {nullptr}
PMSX003Sensor *humidity_sensor_ = {nullptr}
PMSX003Sensor *formaldehyde_sensor_ = {nullptr}
class PMSX003Sensor : public sensor::Sensor

Public Functions

PMSX003Sensor(const std::string &name, PMSX003SensorType type)
std::string unit_of_measurement()

Override this to set the Home Assistant unit of measurement for this sensor.

Return “” to disable this feature.

Return
The icon of this sensor, for example “°C”.

std::string icon()

Override this to set the Home Assistant icon for this sensor.

Return “” to disable this feature.

Return
The icon of this sensor, for example “mdi:battery”.

int8_t accuracy_decimals()

Return the accuracy in decimals for this sensor.

Protected Attributes

const PMSX003SensorType type_
enum sensor::PMSX003SensorType

Values:

PMSX003_SENSOR_TYPE_PM_1_0 = 0

PM1.0 concentration in µg/m^3, PMSX003.

PMSX003_SENSOR_TYPE_PM_2_5

PM2.5 concentration in µg/m^3, PMSX003, PMS5003T, PMS5003ST.

PMSX003_SENSOR_TYPE_PM_10_0

PM10.0 concentration in µg/m^3, PMSX003.

PMSX003_SENSOR_TYPE_TEMPERATURE

Temperature in °C, PMS5003T, PMS5003ST.

PMSX003_SENSOR_TYPE_HUMIDITY

Relative Humidity in %, PMS5003T, PMS5003T.

PMSX003_SENSOR_TYPE_FORMALDEHYDE

Formaldehyde in µg/m^3, PMS5003ST.

enum sensor::PMSX003Type

Values:

PMSX003_TYPE_X003 = 0
PMSX003_TYPE_5003T
PMSX003_TYPE_5003ST