ESPHome  2024.3.2
ens210.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace ens210 {
9 
12  public:
13  float get_setup_priority() const override;
14  void dump_config() override;
15  void setup() override;
16  void update() override;
17 
18  void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; }
19  void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
20 
21  enum ErrorCode {
22  ENS210_STATUS_OK = 0, // The value was read, the CRC matches, and data is valid
23  ENS210_STATUS_INVALID, // The value was read, the CRC matches, but the data is invalid (e.g. the measurement was
24  // not yet finished)
25  ENS210_STATUS_CRC_ERROR, // The value was read, but the CRC over the payload (valid and data) does not match
26  ENS210_STATUS_I2C_ERROR, // There was an I2C communication error
27  ENS210_WRONG_CHIP_ID // The read PART_ID is not the expected part id of the ENS210
28  } error_code_{ENS210_STATUS_OK};
29 
30  protected:
31  bool set_low_power_(bool enable);
32  void extract_measurement_(uint32_t val, int *data, int *status);
33 
36 };
37 
38 } // namespace ens210
39 } // namespace esphome
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition: ens210.h:19
mopeka_std_values val[4]
This class simplifies creating components that periodically check a state.
Definition: component.h:283
float get_setup_priority() const override
Definition: ens210.cpp:140
void set_humidity_sensor(sensor::Sensor *humidity_sensor)
Definition: ens210.h:18
sensor::Sensor * humidity_sensor_
Definition: ens210.h:35
This class implements support for the ENS210 relative humidity and temperature i2c sensor...
Definition: ens210.h:11
sensor::Sensor * temperature_sensor_
Definition: ens210.h:34
bool set_low_power_(bool enable)
Definition: ens210.cpp:221
uint8_t status
Definition: bl0942.h:23
enum esphome::ens210::ENS210Component::ErrorCode ENS210_STATUS_OK
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
Base-class for all sensors.
Definition: sensor.h:57
void extract_measurement_(uint32_t val, int *data, int *status)
Definition: ens210.cpp:203
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133