ESPHome 2026.11.0-dev
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 public:
24 void setup() override;
25 void update() override;
26 void dump_config() override;
27
28 void calibrate_zero();
29 void abc_enable();
30 void abc_disable();
31 void range_set(MHZ19DetectionRange detection_range);
32
33 void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
34 void set_co2_sensor(sensor::Sensor *co2_sensor) { co2_sensor_ = co2_sensor; }
35 void set_abc_enabled(bool abc_enabled) { abc_boot_logic_ = abc_enabled ? MHZ19_ABC_ENABLED : MHZ19_ABC_DISABLED; }
36 void set_warmup_seconds(uint32_t seconds) { warmup_seconds_ = seconds; }
37 void set_detection_range(MHZ19DetectionRange detection_range) { detection_range_ = detection_range; }
38
39 protected:
40 bool mhz19_write_command_(const uint8_t *command, uint8_t *response);
41
45
47
49};
50
51} // namespace esphome::mhz19
This class simplifies creating components that periodically check a state.
Definition component.h:519
void range_set(MHZ19DetectionRange detection_range)
Definition mhz19.cpp:100
void set_abc_enabled(bool abc_enabled)
Definition mhz19.h:35
void set_detection_range(MHZ19DetectionRange detection_range)
Definition mhz19.h:37
void dump_config() override
Definition mhz19.cpp:132
MHZ19DetectionRange detection_range_
Definition mhz19.h:48
sensor::Sensor * temperature_sensor_
Definition mhz19.h:42
sensor::Sensor * co2_sensor_
Definition mhz19.h:43
bool mhz19_write_command_(const uint8_t *command, uint8_t *response)
Definition mhz19.cpp:120
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition mhz19.h:33
MHZ19ABCLogic abc_boot_logic_
Definition mhz19.h:44
void set_warmup_seconds(uint32_t seconds)
Definition mhz19.h:36
void set_co2_sensor(sensor::Sensor *co2_sensor)
Definition mhz19.h:34
Base-class for all sensors.
Definition sensor.h:47
@ MHZ19_ABC_DISABLED
Definition mhz19.h:12
@ MHZ19_ABC_ENABLED
Definition mhz19.h:11
@ MHZ19_ABC_NONE
Definition mhz19.h:10
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
static void uint32_t