1#if defined(USE_ZEPHYR) && defined(USE_NRF52)
6#include <zephyr/device.h>
7#include <zephyr/drivers/sensor.h>
11static const char *
const TAG =
"internal_temperature.zephyr";
13static const struct device *
const DIE_TEMPERATURE_SENSOR = DEVICE_DT_GET_ONE(nordic_nrf_temp);
16 struct sensor_value value;
17 int result = sensor_sample_fetch(DIE_TEMPERATURE_SENSOR);
19 ESP_LOGE(TAG,
"Failed to fetch nRF52 die temperature sample (%d)", result);
26 result = sensor_channel_get(DIE_TEMPERATURE_SENSOR, SENSOR_CHAN_DIE_TEMP, &value);
28 ESP_LOGE(TAG,
"Failed to get nRF52 die temperature (%d)", result);
35 const float temperature = value.val1 + (value.val2 / 1000000.0f);
39 ESP_LOGD(TAG,
"Ignoring invalid nRF52 temperature (value=%.1f)",
temperature);
47 if (!device_is_ready(DIE_TEMPERATURE_SENSOR)) {
48 ESP_LOGE(TAG,
"nRF52 die temperature sensor device %s not ready", DIE_TEMPERATURE_SENSOR->name);
void mark_failed()
Mark this component as failed.
void publish_state(float state)
Publish a new state to the front-end.