7 static const char *
const TAG =
"sht3xd";
12 static const uint16_t SHT3XD_COMMAND_READ_SERIAL_NUMBER = 0x3682;
14 static const uint16_t SHT3XD_COMMAND_READ_STATUS = 0xF32D;
15 static const uint16_t SHT3XD_COMMAND_CLEAR_STATUS = 0x3041;
16 static const uint16_t SHT3XD_COMMAND_HEATER_ENABLE = 0x306D;
17 static const uint16_t SHT3XD_COMMAND_HEATER_DISABLE = 0x3066;
18 static const uint16_t SHT3XD_COMMAND_SOFT_RESET = 0x30A2;
19 static const uint16_t SHT3XD_COMMAND_POLLING_H = 0x2400;
20 static const uint16_t SHT3XD_COMMAND_FETCH_DATA = 0xE000;
23 ESP_LOGCONFIG(TAG,
"Setting up SHT3xD...");
24 uint16_t raw_serial_number[2];
25 if (!this->
get_register(SHT3XD_COMMAND_READ_SERIAL_NUMBER, raw_serial_number, 2)) {
29 this->
serial_number_ = (uint32_t(raw_serial_number[0]) << 16) | uint32_t(raw_serial_number[1]);
38 ESP_LOGCONFIG(TAG,
"SHT3xD:");
40 ESP_LOGE(TAG,
" Communication with SHT3xD failed!");
43 ESP_LOGD(TAG,
" Serial Number: 0x%08" PRIX32, this->
serial_number_);
44 ESP_LOGD(TAG,
" Heater Enabled: %s", this->
heater_enabled_ ?
"true" :
"false");
47 LOG_UPDATE_INTERVAL(
this);
57 ESP_LOGD(TAG,
"Retrying to reconnect the sensor.");
72 float temperature = 175.0f * float(raw_data[0]) / 65535.0f - 45.0f;
73 float humidity = 100.0f * float(raw_data[1]) / 65535.0f;
75 ESP_LOGD(TAG,
"Got temperature=%.2f°C humidity=%.2f%%", temperature, humidity);
sensor::Sensor * temperature_sensor_
const float DATA
For components that import data from directly connected sensors like DHT.
void status_set_warning(const char *message="unspecified")
bool status_has_warning() const
bool write_command(T i2c_register)
Write a command to the i2c device.
void set_timeout(const std::string &name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
bool read_data(uint16_t *data, uint8_t len)
Read data words from i2c device.
void status_clear_warning()
float get_setup_priority() const override
void publish_state(float state)
Publish a new state to the front-end.
void dump_config() override
bool get_register(uint16_t command, uint16_t *data, uint8_t len, uint8_t delay=0)
get data words from i2c register.
virtual void mark_failed()
Mark this component as failed.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
sensor::Sensor * humidity_sensor_