ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
cm1106.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::cm1106 {
8
9// ABC logic requested at boot; CM1106_ABC_NONE means nothing is sent and the
10// sensor keeps its stored setting.
16
18 public:
19 void setup() override;
20 void update() override;
21 void dump_config() override;
22
23 void calibrate_zero(uint16_t ppm);
24 void abc_enable() { this->abc_set_(true); }
25 void abc_disable() { this->abc_set_(false); }
26
27 void set_co2_sensor(sensor::Sensor *co2_sensor) { this->co2_sensor_ = co2_sensor; }
28 void set_abc(bool enabled, uint8_t cycle_days, uint16_t baseline_ppm) {
30 this->abc_cycle_ = cycle_days;
31 this->abc_baseline_ = baseline_ppm;
32 }
33
34 protected:
35 bool cm1106_write_command_(const uint8_t *command, size_t command_len, uint8_t *response, size_t response_len);
37 bool send_command_expect_ack_(const uint8_t *command, size_t command_len, const uint8_t *ack);
38 void abc_set_(bool enabled);
39
42 uint8_t abc_cycle_{15};
43 uint16_t abc_baseline_{400};
44};
45
46} // namespace esphome::cm1106
This class simplifies creating components that periodically check a state.
Definition component.h:519
bool send_command_expect_ack_(const uint8_t *command, size_t command_len, const uint8_t *ack)
Sends a command and checks the sensor's four byte acknowledgement, updating the warning status.
Definition cm1106.cpp:100
void calibrate_zero(uint16_t ppm)
Definition cm1106.cpp:77
void abc_set_(bool enabled)
Definition cm1106.cpp:87
CM1106ABCLogic abc_boot_logic_
Definition cm1106.h:41
bool cm1106_write_command_(const uint8_t *command, size_t command_len, uint8_t *response, size_t response_len)
Definition cm1106.cpp:114
void set_co2_sensor(sensor::Sensor *co2_sensor)
Definition cm1106.h:27
sensor::Sensor * co2_sensor_
Definition cm1106.h:40
void set_abc(bool enabled, uint8_t cycle_days, uint16_t baseline_ppm)
Definition cm1106.h:28
Base-class for all sensors.
Definition sensor.h:47
@ CM1106_ABC_ENABLED
Definition cm1106.h:13
@ CM1106_ABC_DISABLED
Definition cm1106.h:14
uint8_t ack