6#include <soc/soc_caps.h>
8#if defined(USE_ESP32_VARIANT_ESP32)
13#elif SOC_TEMP_SENSOR_SUPPORTED
14#include "driver/temperature_sensor.h"
19static const char *
const TAG =
"internal_temperature.esp32";
24#if defined(USE_ESP32_VARIANT_ESP32)
26 ESP_LOGV(TAG,
"Raw temperature value: %d",
raw);
28 success = (
raw != 128);
29#elif SOC_TEMP_SENSOR_SUPPORTED
30 esp_err_t result = temperature_sensor_get_celsius(this->
tsens_, &temperature);
31 success = (result == ESP_OK);
33 ESP_LOGE(TAG,
"Reading failed (%d)", result);
40 ESP_LOGD(TAG,
"Ignoring invalid temperature (success=%d, value=%.1f)", success,
temperature);
48#if SOC_TEMP_SENSOR_SUPPORTED
49 temperature_sensor_config_t tsens_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(-10, 80);
51 esp_err_t result = temperature_sensor_install(&tsens_config, &this->
tsens_);
52 if (result != ESP_OK) {
53 ESP_LOGE(TAG,
"Install failed (%d)", result);
58 result = temperature_sensor_enable(this->
tsens_);
59 if (result != ESP_OK) {
60 ESP_LOGE(TAG,
"Enabling failed (%d)", result);
void mark_failed()
Mark this component as failed.
temperature_sensor_handle_t tsens_
void publish_state(float state)
Publish a new state to the front-end.
uint8_t temprature_sens_read()