ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
mhz19.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::mhz19 {
8
14
21
22class MHZ19Component final : public PollingComponent, public uart::UARTDevice {
23 SUB_SENSOR(temperature)
24 SUB_SENSOR(co2)
25
26 public:
27 void setup() override;
28 void update() override;
29 void dump_config() override;
30
31 void calibrate_zero();
32 void abc_enable();
33 void abc_disable();
34 void range_set(MHZ19DetectionRange detection_range);
35
36 void set_abc_enabled(bool abc_enabled) { abc_boot_logic_ = abc_enabled ? MHZ19_ABC_ENABLED : MHZ19_ABC_DISABLED; }
37 void set_warmup_seconds(uint32_t seconds) { warmup_seconds_ = seconds; }
38 void set_detection_range(MHZ19DetectionRange detection_range) { detection_range_ = detection_range; }
39
40 protected:
41 bool mhz19_write_command_(const uint8_t *command, uint8_t *response);
42
46 bool warmup_complete_{false};
47};
48
49} // namespace esphome::mhz19
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
This class simplifies creating components that periodically check a state.
Definition component.h:532
MHZ19DetectionRange detection_range_
Definition mhz19.h:45
bool mhz19_write_command_(const uint8_t *command, uint8_t *response)
Definition mhz19.cpp:123
MHZ19ABCLogic abc_boot_logic_
Definition mhz19.h:44
MHZ19DetectionRange
Definition mhz19.h:15
@ MHZ19_DETECTION_RANGE_0_10000PPM
Definition mhz19.h:19
@ MHZ19_DETECTION_RANGE_0_5000PPM
Definition mhz19.h:18
@ MHZ19_DETECTION_RANGE_0_2000PPM
Definition mhz19.h:17
@ MHZ19_DETECTION_RANGE_DEFAULT
Definition mhz19.h:16
@ MHZ19_ABC_DISABLED
Definition mhz19.h:12
@ MHZ19_ABC_ENABLED
Definition mhz19.h:11
@ MHZ19_ABC_NONE
Definition mhz19.h:10
static void uint32_t
uint16_t temperature
Definition sun_gtil2.cpp:12