ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
hm3301.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace esphome::hm3301 {
9
10static const uint8_t SELECT_COMM_CMD = 0x88;
11
12class HM3301Component final : public PollingComponent, public i2c::I2CDevice {
13 SUB_SENSOR(pm_1_0)
14 SUB_SENSOR(pm_2_5)
15 SUB_SENSOR(pm_10_0)
16 SUB_SENSOR(aqi)
17
18 public:
19 HM3301Component() = default;
20
21 void set_aqi_calculation_type(aqi::AQICalculatorType aqi_calc_type) { aqi_calc_type_ = aqi_calc_type; }
22
23 void setup() override;
24 void dump_config() override;
25 void update() override;
26
27 protected:
28 enum {
33 } error_code_{NO_ERROR};
34
35 uint8_t data_buffer_[30];
36
39
40 bool validate_checksum_(const uint8_t *data);
41 uint16_t get_sensor_value_(const uint8_t *data, uint8_t i);
42};
43
44} // namespace esphome::hm3301
This class simplifies creating components that periodically check a state.
Definition component.h:532
uint16_t get_sensor_value_(const uint8_t *data, uint8_t i)
Definition hm3301.cpp:86
aqi::AQICalculatorFactory aqi_calculator_factory_
Definition hm3301.h:38
aqi::AQICalculatorType aqi_calc_type_
Definition hm3301.h:37
enum esphome::hm3301::HM3301Component::@91 NO_ERROR
bool validate_checksum_(const uint8_t *data)
Definition hm3301.cpp:84
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144