10static const uint8_t TEMPERATURE_REG = 0x00;
11static const uint8_t CONFIG_REG = 0x01;
12static const uint8_t TEMPERATURE_LOW_REG = 0x02;
13static const uint8_t TEMPERATURE_HIGH_REG = 0x03;
14static const uint8_t SOFT_RESET_REG = 0x04;
17static const uint8_t SOFT_RESET_PAYLOAD = 0x01;
19static const float SENSOR_RESOLUTION = 0.0625f;
32 uint8_t temperature_raw[2];
34 ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
41 raw_temperature_register_value >>= 4;
42 float temperature_value = raw_temperature_register_value * SENSOR_RESOLUTION;
48 LOG_SENSOR(
"",
"BH1900NUX",
this);
50 LOG_UPDATE_INTERVAL(
this);
void mark_failed()
Mark this component as failed.
void dump_config() override
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
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.
ESPHOME_LOG_TAG(TAG, "bh1900nux.sensor")
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
@ ERROR_OK
No error found during execution of method.
constexpr T encode_value(const uint8_t *bytes)
Encode a value from its constituent bytes (from most to least significant) in an array with length si...