9static const char *
const TAG =
"tem3200";
20 uint16_t raw_temperature(0);
21 uint16_t raw_pressure(0);
25 ESP_LOGCONFIG(TAG, ESP_LOG_MSG_COMM_FAIL);
32 ESP_LOGE(TAG,
"Invalid RESERVED Device Status");
36 ESP_LOGE(TAG,
"FAULT condition in the SSC or sensing element");
40 ESP_LOGE(TAG,
"STALE data. Data has not been updated since last fetch");
47 ESP_LOGCONFIG(TAG,
"TEM3200:");
49 LOG_UPDATE_INTERVAL(
this);
57 uint8_t response[4] = {0x00, 0x00, 0x00, 0x00};
76 err = this->
read(response, 4);
89 raw_pressure = (((response[0] & 0x3f)) << 8 | response[1]);
92 raw_temperature = ((response[2] << 3) | (response[3] & 0xe0) >> 5);
98 const float temperature_bits_span = 2048;
99 const float temperature_max = 150;
100 const float temperature_min = -50;
101 const float temperature_span = temperature_max - temperature_min;
103 float temperature = (raw_temperature * temperature_span / temperature_bits_span) + temperature_min;
110 uint16_t raw_temperature(0);
111 uint16_t raw_pressure(0);
115 ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
122 ESP_LOGE(TAG,
"Failed: Device return RESERVED status");
126 ESP_LOGE(TAG,
"Failed: FAULT condition in the SSC or sensing element");
130 ESP_LOGE(TAG,
"Warning: STALE data. Data has not been updated since last fetch");
137 ESP_LOGD(TAG,
"Got raw pressure=%d, temperature=%.1f°C", raw_pressure,
temperature);
virtual void mark_failed()
Mark this component as failed.
void status_set_warning(const char *message=nullptr)
void status_clear_warning()
ErrorCode read(uint8_t *data, size_t len)
reads an array of bytes from the device using an I2CBus
void publish_state(float state)
Publish a new state to the front-end.
i2c::ErrorCode read_(uint8_t &status, uint16_t &raw_temperature, uint16_t &raw_pressure)
sensor::Sensor * raw_pressure_sensor_
sensor::Sensor * temperature_sensor_
float get_setup_priority() const override
void dump_config() override
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
@ ERROR_OK
No error found during execution of method.
const float DATA
For components that import data from directly connected sensors like DHT.
float convert_temperature(uint16_t raw_temperature)
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delay(uint32_t ms)