HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
EspTemperature.h File Reference

ESP32-C6 internal temperature sensor implementation for the HardFOC system. More...

#include "base/BaseTemperature.h"
#include "utils/PlatformMutex.h"
#include "driver/temperature_sensor.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_timer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <atomic>
#include <functional>
Include dependency graph for EspTemperature.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  esp_temp_state_t
 ESP32-C6 specific temperature sensor state. More...
 
struct  esp_temp_config_t
 ESP32-C6 specific temperature sensor configuration. More...
 
struct  esp_temp_range_info_t
 Temperature range information structure. More...
 
class  EspTemperature
 ESP32-C6 internal temperature sensor implementation. More...
 

Macros

#define ESP_TEMP_DEFAULT_RESOLUTION_CELSIUS   0.25f
 ESP32-C6 Temperature sensor default values.
 
#define ESP_TEMP_DEFAULT_RESPONSE_TIME_MS   50
 Typical response time (50ms)
 
#define ESP_TEMP_DEFAULT_SAMPLE_RATE_HZ   10
 Default sample rate for continuous monitoring.
 
#define ESP_TEMP_MAX_SAMPLE_RATE_HZ   1000
 Maximum sample rate.
 
#define ESP_TEMP_MIN_SAMPLE_RATE_HZ   1
 Minimum sample rate.
 
#define ESP_TEMP_DEFAULT_TIMEOUT_MS   1000
 Default operation timeout.
 
#define ESP_TEMP_ABSOLUTE_MIN_CELSIUS   -40.0f
 ESP32-C6 Temperature sensor range limits.
 
#define ESP_TEMP_ABSOLUTE_MAX_CELSIUS   125.0f
 Absolute maximum temperature.
 
#define ESP_TEMP_RECOMMENDED_MIN_CELSIUS   -10.0f
 Recommended minimum for best accuracy.
 
#define ESP_TEMP_RECOMMENDED_MAX_CELSIUS   80.0f
 Recommended maximum for best accuracy.
 
#define ESP_TEMP_CONFIG_DEFAULT()
 Default ESP32-C6 temperature sensor configuration.
 

Typedefs

using esp_temp_threshold_callback_t
 ESP32-C6 threshold callback function type.
 
using esp_temp_monitoring_callback_t
 ESP32-C6 continuous monitoring callback function type.
 

Enumerations

enum  esp_temp_range_t {
  ESP_TEMP_RANGE_NEG10_80 = 0 , ESP_TEMP_RANGE_20_100 = 1 , ESP_TEMP_RANGE_NEG30_50 = 2 , ESP_TEMP_RANGE_50_125 = 3 ,
  ESP_TEMP_RANGE_NEG40_20 = 4 , ESP_TEMP_RANGE_COUNT
}
 ESP32-C6 Temperature sensor measurement ranges. More...
 

Detailed Description

ESP32-C6 internal temperature sensor implementation for the HardFOC system.

This file contains the declaration of the EspTemperature class that extends the BaseTemperature abstract class to provide comprehensive ESP32-C6 temperature sensor functionality using the ESP-IDF temperature sensor driver.

Key features implemented:

  • ESP32-C6 internal temperature sensor support using ESP-IDF v5.x APIs
  • Multiple measurement ranges with different accuracy levels
  • Hardware calibration and offset compensation
  • Threshold monitoring with interrupt callbacks
  • Continuous monitoring with timer-based sampling
  • Thread-safe operations with mutex protection
  • Power management (sleep/wake modes)
  • Comprehensive error handling and diagnostics
  • Self-test and health monitoring capabilities
  • Operation statistics tracking
Author
Nebiyu Tadesse
Date
2025
Note
ESP32-C6 specific implementation using ESP-IDF v5.x
Each EspTemperature instance represents the internal chip temperature sensor
Thread-safe design suitable for multi-threaded applications

Macro Definition Documentation

◆ ESP_TEMP_ABSOLUTE_MAX_CELSIUS

#define ESP_TEMP_ABSOLUTE_MAX_CELSIUS   125.0f

Absolute maximum temperature.

◆ ESP_TEMP_ABSOLUTE_MIN_CELSIUS

#define ESP_TEMP_ABSOLUTE_MIN_CELSIUS   -40.0f

ESP32-C6 Temperature sensor range limits.

Absolute minimum temperature

◆ ESP_TEMP_CONFIG_DEFAULT

#define ESP_TEMP_CONFIG_DEFAULT ( )
Value:
.calibration_offset = 0.0f, \
.enable_threshold_monitoring = false, \
.high_threshold_celsius = 80.0f, \
.low_threshold_celsius = -10.0f, \
.enable_continuous_monitoring = false, \
.sample_rate_hz = ESP_TEMP_DEFAULT_SAMPLE_RATE_HZ, \
.allow_power_down = true, \
.clk_src = 0}
#define ESP_TEMP_DEFAULT_SAMPLE_RATE_HZ
Default sample rate for continuous monitoring.
Definition EspTemperature.h:80
@ ESP_TEMP_RANGE_NEG10_80
-10°C to 80°C, ±1°C accuracy (recommended for most applications)
Definition EspTemperature.h:67

Default ESP32-C6 temperature sensor configuration.

◆ ESP_TEMP_DEFAULT_RESOLUTION_CELSIUS

#define ESP_TEMP_DEFAULT_RESOLUTION_CELSIUS   0.25f

ESP32-C6 Temperature sensor default values.

Default resolution (0.25°C)

◆ ESP_TEMP_DEFAULT_RESPONSE_TIME_MS

#define ESP_TEMP_DEFAULT_RESPONSE_TIME_MS   50

Typical response time (50ms)

◆ ESP_TEMP_DEFAULT_SAMPLE_RATE_HZ

#define ESP_TEMP_DEFAULT_SAMPLE_RATE_HZ   10

Default sample rate for continuous monitoring.

◆ ESP_TEMP_DEFAULT_TIMEOUT_MS

#define ESP_TEMP_DEFAULT_TIMEOUT_MS   1000

Default operation timeout.

◆ ESP_TEMP_MAX_SAMPLE_RATE_HZ

#define ESP_TEMP_MAX_SAMPLE_RATE_HZ   1000

Maximum sample rate.

◆ ESP_TEMP_MIN_SAMPLE_RATE_HZ

#define ESP_TEMP_MIN_SAMPLE_RATE_HZ   1

Minimum sample rate.

◆ ESP_TEMP_RECOMMENDED_MAX_CELSIUS

#define ESP_TEMP_RECOMMENDED_MAX_CELSIUS   80.0f

Recommended maximum for best accuracy.

◆ ESP_TEMP_RECOMMENDED_MIN_CELSIUS

#define ESP_TEMP_RECOMMENDED_MIN_CELSIUS   -10.0f

Recommended minimum for best accuracy.

Typedef Documentation

◆ esp_temp_monitoring_callback_t

Initial value:
std::function<void(EspTemperature* sensor, float temperature, hf_u64_t timestamp_us)>
uint64_t hf_u64_t
Platform-agnostic 64-bit unsigned integer type.
Definition HardwareTypes.h:58
ESP32-C6 internal temperature sensor implementation.
Definition EspTemperature.h:192

ESP32-C6 continuous monitoring callback function type.

◆ esp_temp_threshold_callback_t

Initial value:
std::function<void(EspTemperature* sensor, float temperature, bool is_high_threshold)>

ESP32-C6 threshold callback function type.

Enumeration Type Documentation

◆ esp_temp_range_t

ESP32-C6 Temperature sensor measurement ranges.

Each range has different accuracy characteristics optimized for specific use cases. Lower ranges generally provide better accuracy.

Enumerator
ESP_TEMP_RANGE_NEG10_80 

-10°C to 80°C, ±1°C accuracy (recommended for most applications)

ESP_TEMP_RANGE_20_100 

20°C to 100°C, ±2°C accuracy (high temperature applications)

ESP_TEMP_RANGE_NEG30_50 

-30°C to 50°C, ±2°C accuracy (low temperature applications)

ESP_TEMP_RANGE_50_125 

50°C to 125°C, ±3°C accuracy (extreme high temperature)

ESP_TEMP_RANGE_NEG40_20 

-40°C to 20°C, ±3°C accuracy (extreme low temperature)

ESP_TEMP_RANGE_COUNT 

Number of available ranges.