19 uint16_t raw_temperature(0);
20 uint16_t raw_pressure(0);
24 ESP_LOGCONFIG(TAG, ESP_LOG_MSG_COMM_FAIL);
31 ESP_LOGE(TAG,
"Invalid RESERVED Device Status");
35 ESP_LOGE(TAG,
"FAULT condition in the SSC or sensing element");
39 ESP_LOGE(TAG,
"STALE data. Data has not been updated since last fetch");
47void TEM3200Component::dump_config() {
48 ESP_LOGCONFIG(TAG,
"TEM3200:");
50 LOG_UPDATE_INTERVAL(
this);
51 LOG_SENSOR(
" ",
"Raw Pressure", this->raw_pressure_sensor_);
52 LOG_SENSOR(
" ",
"Temperature", this->temperature_sensor_);
56 uint8_t response[4] = {0x00, 0x00, 0x00, 0x00};
75 err = this->
read(response, 4);
88 raw_pressure =
encode_uint16(response[0] & 0x3f, response[1]);
91 raw_temperature =
encode_uint16(response[2], response[3]) >> 5;
97 const float temperature_bits_span = 2048;
98 const float temperature_max = 150;
99 const float temperature_min = -50;
100 const float temperature_span = temperature_max - temperature_min;
102 float temperature = (raw_temperature * temperature_span / temperature_bits_span) + temperature_min;
107void TEM3200Component::update() {
109 uint16_t raw_temperature(0);
110 uint16_t raw_pressure(0);
114 ESP_LOGW(TAG, ESP_LOG_MSG_COMM_FAIL);
121 ESP_LOGE(TAG,
"Failed: Device return RESERVED status");
125 ESP_LOGE(TAG,
"Failed: FAULT condition in the SSC or sensing element");
129 ESP_LOGE(TAG,
"Warning: STALE data. Data has not been updated since last fetch");
138 ESP_LOGD(TAG,
"Got raw pressure=%d, temperature=%.1f°C", raw_pressure,
temperature);
140 PUBLISH_STATE(this->temperature_sensor_,
temperature);
141 PUBLISH_STATE(this->raw_pressure_sensor_, raw_pressure);