7 static const char *
const TAG =
"sts3x";
9 static const uint16_t STS3X_COMMAND_READ_SERIAL_NUMBER = 0x3780;
10 static const uint16_t STS3X_COMMAND_READ_STATUS = 0xF32D;
11 static const uint16_t STS3X_COMMAND_SOFT_RESET = 0x30A2;
12 static const uint16_t STS3X_COMMAND_POLLING_H = 0x2400;
15 static const uint16_t STS3X_COMMAND_CLEAR_STATUS = 0x3041;
16 static const uint16_t STS3X_COMMAND_HEATER_ENABLE = 0x306D;
17 static const uint16_t STS3X_COMMAND_HEATER_DISABLE = 0x3066;
18 static const uint16_t STS3X_COMMAND_FETCH_DATA = 0xE000;
21 ESP_LOGCONFIG(TAG,
"Setting up STS3x...");
27 uint16_t raw_serial_number[2];
28 if (!this->
read_data(raw_serial_number, 1)) {
32 uint32_t
serial_number = (uint32_t(raw_serial_number[0]) << 16);
33 ESP_LOGV(TAG,
" Serial Number: 0x%08" PRIX32, serial_number);
36 ESP_LOGCONFIG(TAG,
"STS3x:");
39 ESP_LOGE(TAG,
"Communication with ST3x failed!");
41 LOG_UPDATE_INTERVAL(
this);
43 LOG_SENSOR(
" ",
"STS3x",
this);
48 ESP_LOGD(TAG,
"Retrying to reconnect the sensor.");
63 float temperature = 175.0f * float(raw_data[0]) / 65535.0f - 45.0f;
64 ESP_LOGD(TAG,
"Got temperature=%.2f°C", temperature);
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.
float get_setup_priority() const override
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()
void publish_state(float state)
Publish a new state to the front-end.
virtual void mark_failed()
Mark this component as failed.
Implementation of SPI Controller mode.
void dump_config() override