ESPHome
2026.11.0b6
Loading...
Searching...
No Matches
esphome
components
cm1106
cm1106.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/components/sensor/sensor.h
"
5
#include "
esphome/components/uart/uart.h
"
6
7
namespace
esphome::cm1106
{
8
9
// ABC logic requested at boot; CM1106_ABC_NONE means nothing is sent and the
10
// sensor keeps its stored setting.
11
enum
CM1106ABCLogic
: uint8_t {
12
CM1106_ABC_NONE
= 0,
13
CM1106_ABC_ENABLED
,
14
CM1106_ABC_DISABLED
,
15
};
16
17
class
CM1106Component
final :
public
PollingComponent
,
public
uart::UARTDevice
{
18
SUB_SENSOR(co2)
19
20
public
:
21
void
setup
()
override
;
22
void
update()
override
;
23
void
dump_config()
override
;
24
25
void
calibrate_zero(uint16_t ppm);
26
void
abc_enable() { this->
abc_set_
(
true
); }
27
void
abc_disable() { this->
abc_set_
(
false
); }
28
29
void
set_abc(
bool
enabled, uint8_t cycle_days, uint16_t baseline_ppm) {
30
this->
abc_boot_logic_
= enabled ?
CM1106_ABC_ENABLED
:
CM1106_ABC_DISABLED
;
31
this->
abc_cycle_
= cycle_days;
32
this->
abc_baseline_
= baseline_ppm;
33
}
34
35
protected
:
36
bool
cm1106_write_command_
(
const
uint8_t *command,
size_t
command_len, uint8_t *response,
size_t
response_len);
38
bool
send_command_expect_ack_
(
const
uint8_t *command,
size_t
command_len,
const
uint8_t *
ack
);
39
void
abc_set_
(
bool
enabled);
40
41
CM1106ABCLogic
abc_boot_logic_
{
CM1106_ABC_NONE
};
42
uint8_t
abc_cycle_
{15};
43
uint16_t
abc_baseline_
{400};
44
};
45
46
}
// namespace esphome::cm1106
esphome::Component::setup
virtual void setup()
Where the component's initialization should happen.
Definition
component.cpp:84
esphome::PollingComponent
This class simplifies creating components that periodically check a state.
Definition
component.h:532
esphome::cm1106::CM1106Component
Definition
cm1106.h:17
esphome::cm1106::CM1106Component::send_command_expect_ack_
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:99
esphome::cm1106::CM1106Component::abc_baseline_
uint16_t abc_baseline_
Definition
cm1106.h:43
esphome::cm1106::CM1106Component::abc_set_
void abc_set_(bool enabled)
Definition
cm1106.cpp:86
esphome::cm1106::CM1106Component::abc_cycle_
uint8_t abc_cycle_
Definition
cm1106.h:42
esphome::cm1106::CM1106Component::abc_boot_logic_
CM1106ABCLogic abc_boot_logic_
Definition
cm1106.h:41
esphome::cm1106::CM1106Component::cm1106_write_command_
bool cm1106_write_command_(const uint8_t *command, size_t command_len, uint8_t *response, size_t response_len)
Definition
cm1106.cpp:116
esphome::uart::UARTDevice
Definition
uart.h:15
component.h
esphome::cm1106
Definition
cm1106.cpp:7
esphome::cm1106::CM1106ABCLogic
CM1106ABCLogic
Definition
cm1106.h:11
esphome::cm1106::CM1106_ABC_ENABLED
@ CM1106_ABC_ENABLED
Definition
cm1106.h:13
esphome::cm1106::CM1106_ABC_DISABLED
@ CM1106_ABC_DISABLED
Definition
cm1106.h:14
esphome::cm1106::CM1106_ABC_NONE
@ CM1106_ABC_NONE
Definition
cm1106.h:12
sensor.h
ack
uint8_t ack
Definition
tormatic_protocol.h:0
uart.h
Generated by
1.12.0