9static const uint8_t WHOAMI_REG = 0x01;
10static const uint8_t CTRL_REG = 0x04;
11static const uint8_t TEMPERATURE_REG = 0x06;
14static const uint8_t LOW_ODR_CTRL_ENABLE_FLAG = 0x80;
15static const uint8_t FREERUN_CTRL_ENABLE_FLAG = 0x04;
16static const uint8_t ADD_INC_ENABLE_FLAG = 0x08;
18static const uint8_t WHOAMI_STTS22H_IDENTIFICATION = 0xA0;
20static const float SENSOR_SCALE = 0.01f;
23 if (!this->
check_chip_id(
this, WHOAMI_REG, WHOAMI_STTS22H_IDENTIFICATION))
38 LOG_SENSOR(
"",
"STTS22H",
this);
40 LOG_UPDATE_INTERVAL(
this);
44 uint8_t temp_reg_value[2];
46 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
53 return temp_raw_value * SENSOR_SCALE;
67 ctrl_value &= ~FREERUN_CTRL_ENABLE_FLAG;
74 ctrl_value |= LOW_ODR_CTRL_ENABLE_FLAG | ADD_INC_ENABLE_FLAG;
void mark_failed()
Mark this component as failed.
ErrorCode write_register(uint8_t a_register, const uint8_t *data, size_t len) const
writes an array of bytes to a specific register in the I²C device
bool check_chip_id(Component *component, uint8_t a_register, uint8_t expected, uint8_t mask=0xFF)
Read the 8-bit ID at a_register and accept it when it matches expected in the bits set in mask.
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len)
reads an array of bytes from a specific register in the I²C device
void publish_state(float state)
Publish a new state to the front-end.
void dump_config() override
void initialize_sensor_()
float read_temperature_()
@ NO_ERROR
No error found during execution of method.
ESPHOME_LOG_TAG(TAG, "stts22h")
constexpr T encode_value_le(const uint8_t *bytes)
Encode a value from its constituent bytes (from least to most significant) in an array with length si...