ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
ens210.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::ens210 {
8
10class ENS210Component final : public PollingComponent, public i2c::I2CDevice {
11 public:
12 void dump_config() override;
13 void setup() override;
14 void update() override;
15
16 void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; }
17 void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
18
19 enum ErrorCode {
20 ENS210_STATUS_OK = 0, // The value was read, the CRC matches, and data is valid
21 ENS210_STATUS_INVALID, // The value was read, the CRC matches, but the data is invalid (e.g. the measurement was
22 // not yet finished)
23 ENS210_STATUS_CRC_ERROR, // The value was read, but the CRC over the payload (valid and data) does not match
24 ENS210_STATUS_I2C_ERROR, // There was an I2C communication error
25 };
26
27 protected:
28 bool set_low_power_(bool enable);
29 void extract_measurement_(uint32_t val, int *data, int *status);
30
33};
34
35} // namespace esphome::ens210
This class simplifies creating components that periodically check a state.
Definition component.h:519
This class implements support for the ENS210 relative humidity and temperature i2c sensor.
Definition ens210.h:10
void set_humidity_sensor(sensor::Sensor *humidity_sensor)
Definition ens210.h:16
void extract_measurement_(uint32_t val, int *data, int *status)
Definition ens210.cpp:196
sensor::Sensor * humidity_sensor_
Definition ens210.h:32
bool set_low_power_(bool enable)
Definition ens210.cpp:214
void set_temperature_sensor(sensor::Sensor *temperature_sensor)
Definition ens210.h:17
sensor::Sensor * temperature_sensor_
Definition ens210.h:31
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
Base-class for all sensors.
Definition sensor.h:47
mopeka_std_values val[3]
static void uint32_t