8 static const char *
const TAG =
"pmsa003i";
11 ESP_LOGCONFIG(TAG,
"Setting up pmsa003i...");
14 bool successful_read = this->
read_data_(&data);
16 if (!successful_read) {
17 for (
int i = 0; i < 3; i++) {
19 if (successful_read) {
25 if (!successful_read) {
36 bool successful_read = this->
read_data_(&data);
39 if (successful_read) {
41 ESP_LOGV(TAG,
"Read success. Updating sensors.");
73 ESP_LOGV(TAG,
"Read failure. Skipping update.");
78 const uint8_t num_bytes = 32;
79 uint8_t buffer[num_bytes];
86 if (buffer[0] != 0x42) {
92 for (uint8_t i = 0; i < 30; i++) {
97 uint16_t buffer_u16[15];
98 for (uint8_t i = 0; i < 15; i++) {
99 buffer_u16[i] = buffer[2 + i * 2 + 1];
100 buffer_u16[i] += (buffer[2 + i * 2] << 8);
104 memcpy((
void *) data, (
void *) buffer_u16, 30);
106 return (sum == data->checksum);
uint16_t particles_25um
1.0um Particle Count
bool read_data_(PM25AQIData *data)
void status_set_warning(const char *message="unspecified")
sensor::Sensor * pmc_2_5_sensor_
optional< std::array< uint8_t, N > > read_bytes_raw()
sensor::Sensor * pm_1_0_sensor_
uint16_t pm10_standard
Standard PM1.0.
uint16_t pm10_env
Environmental PM1.0.
uint16_t particles_05um
0.3um Particle Count
uint16_t pm25_standard
Standard PM2.5.
void dump_config() override
sensor::Sensor * pm_10_0_sensor_
uint16_t pm25_env
Environmental PM2.5.
void status_clear_warning()
void publish_state(float state)
Publish a new state to the front-end.
sensor::Sensor * pmc_0_3_sensor_
sensor::Sensor * pmc_5_0_sensor_
! Structure holding Plantower's standard packet
sensor::Sensor * pm_2_5_sensor_
uint16_t pm100_standard
Standard PM10.0.
sensor::Sensor * pmc_0_5_sensor_
uint16_t particles_10um
0.5um Particle Count
sensor::Sensor * pmc_10_0_sensor_
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.
sensor::Sensor * pmc_1_0_sensor_
uint16_t particles_50um
2.5um Particle Count
uint16_t particles_100um
5.0um Particle Count
uint16_t pm100_env
Environmental PM10.0.