ESPHome  2022.6.3
pmsa003i.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace pmsa003i {
9 
11 // From https://github.com/adafruit/Adafruit_PM25AQI
12 struct PM25AQIData {
13  uint16_t framelen;
14  uint16_t pm10_standard,
17  uint16_t pm10_env,
18  pm25_env,
19  pm100_env;
20  uint16_t particles_03um,
26  uint16_t unused;
27  uint16_t checksum;
28 };
29 
31  public:
32  void setup() override;
33  void dump_config() override;
34  void update() override;
35  float get_setup_priority() const override { return setup_priority::DATA; }
36 
37  void set_standard_units(bool standard_units) { standard_units_ = standard_units; }
38 
39  void set_pm_1_0_sensor(sensor::Sensor *pm_1_0) { pm_1_0_sensor_ = pm_1_0; }
40  void set_pm_2_5_sensor(sensor::Sensor *pm_2_5) { pm_2_5_sensor_ = pm_2_5; }
41  void set_pm_10_0_sensor(sensor::Sensor *pm_10_0) { pm_10_0_sensor_ = pm_10_0; }
42 
43  void set_pmc_0_3_sensor(sensor::Sensor *pmc_0_3) { pmc_0_3_sensor_ = pmc_0_3; }
44  void set_pmc_0_5_sensor(sensor::Sensor *pmc_0_5) { pmc_0_5_sensor_ = pmc_0_5; }
45  void set_pmc_1_0_sensor(sensor::Sensor *pmc_1_0) { pmc_1_0_sensor_ = pmc_1_0; }
46  void set_pmc_2_5_sensor(sensor::Sensor *pmc_2_5) { pmc_2_5_sensor_ = pmc_2_5; }
47  void set_pmc_5_0_sensor(sensor::Sensor *pmc_5_0) { pmc_5_0_sensor_ = pmc_5_0; }
48  void set_pmc_10_0_sensor(sensor::Sensor *pmc_10_0) { pmc_10_0_sensor_ = pmc_10_0; }
49 
50  protected:
51  bool read_data_(PM25AQIData *data);
52 
54 
55  sensor::Sensor *pm_1_0_sensor_{nullptr};
56  sensor::Sensor *pm_2_5_sensor_{nullptr};
57  sensor::Sensor *pm_10_0_sensor_{nullptr};
58 
59  sensor::Sensor *pmc_0_3_sensor_{nullptr};
60  sensor::Sensor *pmc_0_5_sensor_{nullptr};
61  sensor::Sensor *pmc_1_0_sensor_{nullptr};
62  sensor::Sensor *pmc_2_5_sensor_{nullptr};
63  sensor::Sensor *pmc_5_0_sensor_{nullptr};
64  sensor::Sensor *pmc_10_0_sensor_{nullptr};
65 };
66 
67 } // namespace pmsa003i
68 } // namespace esphome
void setup()
uint16_t unused
Unused.
Definition: pmsa003i.h:26
uint16_t particles_03um
0.3um Particle Count
Definition: pmsa003i.h:20
uint16_t particles_25um
2.5um Particle Count
Definition: pmsa003i.h:20
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:18
void set_pmc_10_0_sensor(sensor::Sensor *pmc_10_0)
Definition: pmsa003i.h:48
uint16_t pm10_standard
Standard PM1.0.
Definition: pmsa003i.h:14
uint16_t pm10_env
Environmental PM1.0.
Definition: pmsa003i.h:17
uint16_t particles_05um
0.5um Particle Count
Definition: pmsa003i.h:20
This class simplifies creating components that periodically check a state.
Definition: component.h:266
uint16_t pm25_standard
Standard PM2.5.
Definition: pmsa003i.h:14
void set_pmc_5_0_sensor(sensor::Sensor *pmc_5_0)
Definition: pmsa003i.h:47
uint16_t checksum
Packet checksum.
Definition: pmsa003i.h:27
void set_pmc_0_3_sensor(sensor::Sensor *pmc_0_3)
Definition: pmsa003i.h:43
uint16_t pm25_env
Environmental PM2.5.
Definition: pmsa003i.h:17
void set_pm_1_0_sensor(sensor::Sensor *pm_1_0)
Definition: pmsa003i.h:39
void set_pmc_0_5_sensor(sensor::Sensor *pmc_0_5)
Definition: pmsa003i.h:44
void set_pm_10_0_sensor(sensor::Sensor *pm_10_0)
Definition: pmsa003i.h:41
uint16_t framelen
How long this data chunk is.
Definition: pmsa003i.h:13
float get_setup_priority() const override
Definition: pmsa003i.h:35
void set_pm_2_5_sensor(sensor::Sensor *pm_2_5)
Definition: pmsa003i.h:40
void set_pmc_2_5_sensor(sensor::Sensor *pmc_2_5)
Definition: pmsa003i.h:46
! Structure holding Plantower's standard packet
Definition: pmsa003i.h:12
uint16_t pm100_standard
Standard PM10.0.
Definition: pmsa003i.h:14
uint16_t particles_10um
1.0um Particle Count
Definition: pmsa003i.h:20
Definition: a4988.cpp:4
Base-class for all sensors.
Definition: sensor.h:47
void set_standard_units(bool standard_units)
Definition: pmsa003i.h:37
void set_pmc_1_0_sensor(sensor::Sensor *pmc_1_0)
Definition: pmsa003i.h:45
uint16_t particles_50um
5.0um Particle Count
Definition: pmsa003i.h:20
uint16_t particles_100um
10.0um Particle Count
Definition: pmsa003i.h:20
uint16_t pm100_env
Environmental PM10.0.
Definition: pmsa003i.h:17