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

ESP32-C6 internal temperature sensor implementation. More...

#include <EspTemperature.h>

Inheritance diagram for EspTemperature:
[legend]
Collaboration diagram for EspTemperature:
[legend]

Public Member Functions

 EspTemperature () noexcept
 Default constructor.
 
 EspTemperature (const esp_temp_config_t &esp_config) noexcept
 Constructor with ESP32-specific configuration.
 
 EspTemperature (const EspTemperature &)=delete
 Copy constructor is deleted to avoid copying instances.
 
EspTemperatureoperator= (const EspTemperature &)=delete
 Assignment operator is deleted to avoid copying instances.
 
virtual ~EspTemperature () noexcept
 Virtual destructor for proper cleanup.
 
hf_temp_err_t GetSensorInfo (hf_temp_sensor_info_t *info) const noexcept override
 Get ESP32-C6 temperature sensor information.
 
hf_u32_t GetCapabilities () const noexcept override
 Get ESP32-C6 temperature sensor capabilities.
 
hf_temp_err_t SetRange (float min_celsius, float max_celsius) noexcept override
 Set temperature measurement range (ESP32-C6 supported)
 
hf_temp_err_t GetRange (float *min_celsius, float *max_celsius) const noexcept override
 Get temperature measurement range (ESP32-C6 supported)
 
hf_temp_err_t GetResolution (float *resolution_celsius) const noexcept override
 Get measurement resolution (ESP32-C6 supported)
 
hf_temp_err_t SetThresholds (float low_threshold_celsius, float high_threshold_celsius) noexcept override
 Set temperature thresholds (ESP32-C6 supported)
 
hf_temp_err_t GetThresholds (float *low_threshold_celsius, float *high_threshold_celsius) const noexcept override
 Get temperature thresholds (ESP32-C6 supported)
 
hf_temp_err_t EnableThresholdMonitoring (hf_temp_threshold_callback_t callback, void *user_data) noexcept override
 Enable threshold monitoring (ESP32-C6 supported)
 
hf_temp_err_t DisableThresholdMonitoring () noexcept override
 Disable threshold monitoring (ESP32-C6 supported)
 
hf_temp_err_t StartContinuousMonitoring (hf_u32_t sample_rate_hz, hf_temp_reading_callback_t callback, void *user_data) noexcept override
 Start continuous temperature monitoring (ESP32-C6 supported)
 
hf_temp_err_t StopContinuousMonitoring () noexcept override
 Stop continuous temperature monitoring (ESP32-C6 supported)
 
bool IsMonitoringActive () const noexcept override
 Check if continuous monitoring is active (ESP32-C6 supported)
 
hf_temp_err_t SetCalibrationOffset (float offset_celsius) noexcept override
 Set calibration offset (ESP32-C6 supported)
 
hf_temp_err_t GetCalibrationOffset (float *offset_celsius) const noexcept override
 Get calibration offset (ESP32-C6 supported)
 
hf_temp_err_t ResetCalibration () noexcept override
 Reset calibration to default (ESP32-C6 supported)
 
hf_temp_err_t EnterSleepMode () noexcept override
 Enter low power mode (ESP32-C6 supported)
 
hf_temp_err_t ExitSleepMode () noexcept override
 Exit low power mode (ESP32-C6 supported)
 
bool IsSleeping () const noexcept override
 Check if sensor is in sleep mode (ESP32-C6 supported)
 
hf_temp_err_t SelfTest () noexcept override
 Perform sensor self-test (ESP32-C6 supported)
 
hf_temp_err_t CheckHealth () noexcept override
 Check sensor health status (ESP32-C6 supported)
 
hf_temp_err_t GetStatistics (hf_temp_statistics_t &statistics) noexcept override
 Get operation statistics (ESP32-C6 supported)
 
hf_temp_err_t GetDiagnostics (hf_temp_diagnostics_t &diagnostics) noexcept override
 Get diagnostic information (ESP32-C6 supported)
 
hf_temp_err_t ResetStatistics () noexcept override
 Reset operation statistics (ESP32-C6 supported)
 
hf_temp_err_t ResetDiagnostics () noexcept override
 Reset diagnostic information (ESP32-C6 supported)
 
hf_temp_err_t InitializeEsp32 (const esp_temp_config_t &esp_config) noexcept
 Initialize with ESP32-specific configuration.
 
hf_temp_err_t SetMeasurementRange (esp_temp_range_t range) noexcept
 Set measurement range using ESP32 enum.
 
esp_temp_range_t GetMeasurementRange () const noexcept
 Get current measurement range.
 
hf_temp_err_t GetRangeInfo (esp_temp_range_t range, float *min_celsius, float *max_celsius, float *accuracy_celsius) const noexcept
 Get range information for a specific range.
 
esp_temp_range_t FindOptimalRange (float min_celsius, float max_celsius) const noexcept
 Find optimal range for given temperature requirements.
 
hf_temp_err_t ReadRawTemperature (float *raw_value) noexcept
 Read raw temperature value (before calibration)
 
temperature_sensor_handle_t GetEspHandle () const noexcept
 Get ESP-IDF temperature sensor handle.
 
hf_temp_err_t SetEspThresholdCallback (esp_temp_threshold_callback_t callback) noexcept
 Set ESP32-specific threshold callback.
 
hf_temp_err_t SetEspMonitoringCallback (esp_temp_monitoring_callback_t callback) noexcept
 Set ESP32-specific monitoring callback.
 
- Public Member Functions inherited from BaseTemperature
 BaseTemperature (const BaseTemperature &)=delete
 Copy constructor is deleted to avoid copying instances.
 
BaseTemperatureoperator= (const BaseTemperature &)=delete
 Assignment operator is deleted to avoid copying instances.
 
virtual ~BaseTemperature () noexcept=default
 Virtual destructor for proper cleanup of derived classes.
 
bool IsInitialized () const noexcept
 Check if the temperature sensor is initialized.
 
bool EnsureInitialized () noexcept
 Ensures the sensor is initialized (lazy initialization).
 
bool EnsureDeinitialized () noexcept
 Ensures the sensor is deinitialized (lazy deinitialization).
 
hf_temp_state_t GetState () const noexcept
 Get current sensor state.
 
hf_temp_err_t ReadTemperatureCelsius (float *temperature_celsius) noexcept
 Read temperature in Celsius (blocking)
 
hf_temp_err_t ReadTemperature (hf_temp_reading_t *reading) noexcept
 Read temperature with full information (blocking)
 
hf_temp_err_t ReadTemperatureFahrenheit (float *temperature_fahrenheit) noexcept
 Read temperature in Fahrenheit.
 
hf_temp_err_t ReadTemperatureKelvin (float *temperature_kelvin) noexcept
 Read temperature in Kelvin.
 
hf_temp_err_t ReadTemperatureUnit (float *temperature, hf_temp_unit_t unit) noexcept
 Read temperature in specified unit.
 
bool HasCapability (hf_temp_capabilities_t capability) const noexcept
 Check if a specific capability is supported.
 
virtual hf_temp_err_t SetResolution (float resolution_celsius) noexcept
 Set measurement resolution (advanced feature)
 
virtual hf_temp_err_t Calibrate (float reference_temperature_celsius) noexcept
 Perform sensor calibration (advanced feature)
 

Protected Member Functions

bool Initialize () noexcept override
 ESP32-specific implementation for initialization.
 
bool Deinitialize () noexcept override
 ESP32-specific implementation for deinitialization.
 
hf_temp_err_t ReadTemperatureCelsiusImpl (float *temperature_celsius) noexcept override
 ESP32-specific implementation for reading temperature in Celsius.
 
- Protected Member Functions inherited from BaseTemperature
 BaseTemperature () noexcept
 Protected default constructor.
 
hf_temp_err_t ValidateBasicOperation () const noexcept
 Protected helper to validate basic operation preconditions.
 

Private Member Functions

hf_temp_err_t ConvertEspError (esp_err_t esp_err) const noexcept
 Convert ESP-IDF error to HardFOC temperature error.
 
hf_temp_err_t ConfigureEspSensor () noexcept
 Configure ESP temperature sensor with current settings.
 
hf_temp_err_t SetupRange (esp_temp_range_t range) noexcept
 Setup measurement range configuration.
 
void GetRangeConfig (esp_temp_range_t range, float *min_celsius, float *max_celsius, float *accuracy_celsius) const noexcept
 Get range configuration values.
 
void SetLastError (hf_temp_err_t error) noexcept
 Set last error code and update diagnostics.
 
void UpdateStatistics (bool operation_successful, hf_u32_t operation_time_us) noexcept
 Update operation statistics.
 
void UpdateDiagnostics (hf_temp_err_t error) noexcept
 Update diagnostic information.
 
void CheckThresholds (float temperature) noexcept
 Check thresholds and trigger callbacks if needed.
 
hf_temp_err_t ValidateConfig (const hf_temp_config_t *config) const noexcept
 Validate base configuration.
 
hf_temp_err_t ValidateEspConfig (const esp_temp_config_t *esp_config) const noexcept
 Validate ESP32-specific configuration.
 

Static Private Member Functions

static void MonitoringTimerCallback (void *arg) noexcept
 Timer callback for continuous monitoring.
 
static hf_u64_t GetCurrentTimeUs () noexcept
 Get current timestamp in microseconds.
 

Private Attributes

PlatformMutex mutex_
 Thread safety mutex (RTOS-aware)
 
esp_temp_state_t esp_state_
 ESP32-specific state.
 
esp_temp_config_t esp_config_
 ESP32-specific configuration.
 
hf_temp_config_t base_config_
 Base class configuration.
 
hf_temp_statistics_t statistics_
 Operation statistics.
 
hf_temp_diagnostics_t diagnostics_
 Diagnostic information.
 
hf_temp_err_t last_error_
 Last error code.
 
hf_temp_threshold_callback_t threshold_callback_
 Base threshold callback.
 
hf_temp_reading_callback_t monitoring_callback_
 Base monitoring callback.
 
esp_temp_threshold_callback_t esp_threshold_callback_
 ESP32-specific threshold callback.
 
esp_temp_monitoring_callback_t esp_monitoring_callback_
 ESP32-specific monitoring callback.
 
void * threshold_user_data_
 User data for threshold callback.
 
void * monitoring_user_data_
 User data for monitoring callback.
 

Static Private Attributes

static const char * TAG = "EspTemperature"
 ESP-IDF logging tag.
 
static const esp_temp_range_info_t RANGE_INFO []
 Range information table.
 
static PlatformMutex s_shared_mutex_
 Protect shared handle/refcount.
 
static std::atomic< int > s_refcount_ {0}
 Number of active instances.
 
static temperature_sensor_handle_t s_shared_handle_ = nullptr
 Shared ESP-IDF handle.
 

Additional Inherited Members

- Protected Attributes inherited from BaseTemperature
bool initialized_
 Initialization status.
 
hf_temp_state_t current_state_
 Current sensor state.
 

Detailed Description

ESP32-C6 internal temperature sensor implementation.

This class provides a complete implementation of the BaseTemperature interface specifically for the ESP32-C6 internal temperature sensor. It leverages the ESP-IDF temperature sensor driver to provide accurate temperature measurements with advanced features like threshold monitoring and continuous sampling.

Key features:

  • Multiple measurement ranges with different accuracy levels
  • Hardware-based threshold monitoring with interrupts
  • Continuous temperature monitoring using ESP32 timers
  • Thread-safe operations with mutex protection
  • Power management support for low-power applications
  • Comprehensive error handling and diagnostics
  • Self-test and health monitoring capabilities
  • Operation statistics and performance tracking
Note
This implementation is thread-safe and can be used in multi-threaded applications
The sensor provides approximately 0.25°C resolution with response time around 50ms
Different measurement ranges offer different accuracy levels (±1°C to ±3°C)

Constructor & Destructor Documentation

◆ EspTemperature() [1/3]

EspTemperature::EspTemperature ( )
noexcept

Default constructor.

◆ EspTemperature() [2/3]

EspTemperature::EspTemperature ( const esp_temp_config_t & esp_config)
explicitnoexcept

Constructor with ESP32-specific configuration.

Parameters
esp_configESP32-specific configuration

◆ EspTemperature() [3/3]

EspTemperature::EspTemperature ( const EspTemperature & )
delete

Copy constructor is deleted to avoid copying instances.

◆ ~EspTemperature()

EspTemperature::~EspTemperature ( )
virtualnoexcept

Virtual destructor for proper cleanup.

Member Function Documentation

◆ CheckHealth()

hf_temp_err_t EspTemperature::CheckHealth ( )
overridevirtualnoexcept

Check sensor health status (ESP32-C6 supported)

Returns
Error code (TEMP_SUCCESS if healthy)

Reimplemented from BaseTemperature.

◆ CheckThresholds()

void EspTemperature::CheckThresholds ( float temperature)
privatenoexcept

Check thresholds and trigger callbacks if needed.

Parameters
temperatureCurrent temperature reading

◆ ConfigureEspSensor()

hf_temp_err_t EspTemperature::ConfigureEspSensor ( )
privatenoexcept

Configure ESP temperature sensor with current settings.

Returns
Error code (TEMP_SUCCESS on success)

◆ ConvertEspError()

hf_temp_err_t EspTemperature::ConvertEspError ( esp_err_t esp_err) const
privatenoexcept

Convert ESP-IDF error to HardFOC temperature error.

Parameters
esp_errESP-IDF error code
Returns
HardFOC temperature error code

◆ Deinitialize()

bool EspTemperature::Deinitialize ( )
overrideprotectedvirtualnoexcept

ESP32-specific implementation for deinitialization.

Returns
true if deinitialization successful, false otherwise

Implements BaseTemperature.

◆ DisableThresholdMonitoring()

hf_temp_err_t EspTemperature::DisableThresholdMonitoring ( )
overridevirtualnoexcept

Disable threshold monitoring (ESP32-C6 supported)

Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ EnableThresholdMonitoring()

hf_temp_err_t EspTemperature::EnableThresholdMonitoring ( hf_temp_threshold_callback_t callback,
void * user_data )
overridevirtualnoexcept

Enable threshold monitoring (ESP32-C6 supported)

Parameters
callbackCallback function for threshold events
user_dataUser data to pass to callback
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ EnterSleepMode()

hf_temp_err_t EspTemperature::EnterSleepMode ( )
overridevirtualnoexcept

Enter low power mode (ESP32-C6 supported)

Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ ExitSleepMode()

hf_temp_err_t EspTemperature::ExitSleepMode ( )
overridevirtualnoexcept

Exit low power mode (ESP32-C6 supported)

Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ FindOptimalRange()

esp_temp_range_t EspTemperature::FindOptimalRange ( float min_celsius,
float max_celsius ) const
noexcept

Find optimal range for given temperature requirements.

Parameters
min_celsiusMinimum required temperature
max_celsiusMaximum required temperature
Returns
Optimal range identifier

◆ GetCalibrationOffset()

hf_temp_err_t EspTemperature::GetCalibrationOffset ( float * offset_celsius) const
overridevirtualnoexcept

Get calibration offset (ESP32-C6 supported)

Parameters
offset_celsiusPointer to store calibration offset
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ GetCapabilities()

hf_u32_t EspTemperature::GetCapabilities ( ) const
overridevirtualnoexcept

Get ESP32-C6 temperature sensor capabilities.

Returns
Capabilities flags (hf_temp_capabilities_t)

Implements BaseTemperature.

◆ GetCurrentTimeUs()

hf_u64_t EspTemperature::GetCurrentTimeUs ( )
staticprivatenoexcept

Get current timestamp in microseconds.

Returns
Current timestamp

◆ GetDiagnostics()

hf_temp_err_t EspTemperature::GetDiagnostics ( hf_temp_diagnostics_t & diagnostics)
overridevirtualnoexcept

Get diagnostic information (ESP32-C6 supported)

Parameters
diagnosticsReference to diagnostics structure to fill
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ GetEspHandle()

temperature_sensor_handle_t EspTemperature::GetEspHandle ( ) const
noexcept

Get ESP-IDF temperature sensor handle.

Returns
ESP-IDF handle (nullptr if not initialized)

◆ GetMeasurementRange()

esp_temp_range_t EspTemperature::GetMeasurementRange ( ) const
noexcept

Get current measurement range.

Returns
Current ESP32 range identifier

◆ GetRange()

hf_temp_err_t EspTemperature::GetRange ( float * min_celsius,
float * max_celsius ) const
overridevirtualnoexcept

Get temperature measurement range (ESP32-C6 supported)

Parameters
min_celsiusPointer to store minimum temperature
max_celsiusPointer to store maximum temperature
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ GetRangeConfig()

void EspTemperature::GetRangeConfig ( esp_temp_range_t range,
float * min_celsius,
float * max_celsius,
float * accuracy_celsius ) const
privatenoexcept

Get range configuration values.

Parameters
rangeRange to query
min_celsiusPointer to store minimum temperature
max_celsiusPointer to store maximum temperature
accuracy_celsiusPointer to store accuracy

◆ GetRangeInfo()

hf_temp_err_t EspTemperature::GetRangeInfo ( esp_temp_range_t range,
float * min_celsius,
float * max_celsius,
float * accuracy_celsius ) const
noexcept

Get range information for a specific range.

Parameters
rangeRange to query
min_celsiusPointer to store minimum temperature
max_celsiusPointer to store maximum temperature
accuracy_celsiusPointer to store accuracy
Returns
Error code (TEMP_SUCCESS on success)

◆ GetResolution()

hf_temp_err_t EspTemperature::GetResolution ( float * resolution_celsius) const
overridevirtualnoexcept

Get measurement resolution (ESP32-C6 supported)

Parameters
resolution_celsiusPointer to store resolution
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ GetSensorInfo()

hf_temp_err_t EspTemperature::GetSensorInfo ( hf_temp_sensor_info_t * info) const
overridevirtualnoexcept

Get ESP32-C6 temperature sensor information.

Parameters
infoPointer to store sensor information
Returns
Error code (TEMP_SUCCESS on success)

Implements BaseTemperature.

◆ GetStatistics()

hf_temp_err_t EspTemperature::GetStatistics ( hf_temp_statistics_t & statistics)
overridevirtualnoexcept

Get operation statistics (ESP32-C6 supported)

Parameters
statisticsReference to statistics structure to fill
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ GetThresholds()

hf_temp_err_t EspTemperature::GetThresholds ( float * low_threshold_celsius,
float * high_threshold_celsius ) const
overridevirtualnoexcept

Get temperature thresholds (ESP32-C6 supported)

Parameters
low_threshold_celsiusPointer to store low threshold
high_threshold_celsiusPointer to store high threshold
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ Initialize()

bool EspTemperature::Initialize ( )
overrideprotectedvirtualnoexcept

ESP32-specific implementation for initialization.

Returns
true if initialization successful, false otherwise

Implements BaseTemperature.

◆ InitializeEsp32()

hf_temp_err_t EspTemperature::InitializeEsp32 ( const esp_temp_config_t & esp_config)
noexcept

Initialize with ESP32-specific configuration.

Parameters
esp_configESP32-specific configuration structure
Returns
Error code (TEMP_SUCCESS on success)

◆ IsMonitoringActive()

bool EspTemperature::IsMonitoringActive ( ) const
overridevirtualnoexcept

Check if continuous monitoring is active (ESP32-C6 supported)

Returns
true if monitoring is active, false otherwise

Reimplemented from BaseTemperature.

◆ IsSleeping()

bool EspTemperature::IsSleeping ( ) const
overridevirtualnoexcept

Check if sensor is in sleep mode (ESP32-C6 supported)

Returns
true if in sleep mode, false otherwise

Reimplemented from BaseTemperature.

◆ MonitoringTimerCallback()

void EspTemperature::MonitoringTimerCallback ( void * arg)
staticprivatenoexcept

Timer callback for continuous monitoring.

Parameters
argPointer to EspTemperature instance

◆ operator=()

EspTemperature & EspTemperature::operator= ( const EspTemperature & )
delete

Assignment operator is deleted to avoid copying instances.

◆ ReadRawTemperature()

hf_temp_err_t EspTemperature::ReadRawTemperature ( float * raw_value)
noexcept

Read raw temperature value (before calibration)

Parameters
raw_valuePointer to store raw temperature
Returns
Error code (TEMP_SUCCESS on success)

◆ ReadTemperatureCelsiusImpl()

hf_temp_err_t EspTemperature::ReadTemperatureCelsiusImpl ( float * temperature_celsius)
overrideprotectedvirtualnoexcept

ESP32-specific implementation for reading temperature in Celsius.

Parameters
temperature_celsiusPointer to store temperature value
Returns
Error code (TEMP_SUCCESS on success)

Implements BaseTemperature.

◆ ResetCalibration()

hf_temp_err_t EspTemperature::ResetCalibration ( )
overridevirtualnoexcept

Reset calibration to default (ESP32-C6 supported)

Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ ResetDiagnostics()

hf_temp_err_t EspTemperature::ResetDiagnostics ( )
overridevirtualnoexcept

Reset diagnostic information (ESP32-C6 supported)

Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ ResetStatistics()

hf_temp_err_t EspTemperature::ResetStatistics ( )
overridevirtualnoexcept

Reset operation statistics (ESP32-C6 supported)

Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ SelfTest()

hf_temp_err_t EspTemperature::SelfTest ( )
overridevirtualnoexcept

Perform sensor self-test (ESP32-C6 supported)

Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ SetCalibrationOffset()

hf_temp_err_t EspTemperature::SetCalibrationOffset ( float offset_celsius)
overridevirtualnoexcept

Set calibration offset (ESP32-C6 supported)

Parameters
offset_celsiusCalibration offset in Celsius
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ SetEspMonitoringCallback()

hf_temp_err_t EspTemperature::SetEspMonitoringCallback ( esp_temp_monitoring_callback_t callback)
noexcept

Set ESP32-specific monitoring callback.

Parameters
callbackESP32-specific callback function
Returns
Error code (TEMP_SUCCESS on success)

◆ SetEspThresholdCallback()

hf_temp_err_t EspTemperature::SetEspThresholdCallback ( esp_temp_threshold_callback_t callback)
noexcept

Set ESP32-specific threshold callback.

Parameters
callbackESP32-specific callback function
Returns
Error code (TEMP_SUCCESS on success)

◆ SetLastError()

void EspTemperature::SetLastError ( hf_temp_err_t error)
privatenoexcept

Set last error code and update diagnostics.

Parameters
errorError code to set

◆ SetMeasurementRange()

hf_temp_err_t EspTemperature::SetMeasurementRange ( esp_temp_range_t range)
noexcept

Set measurement range using ESP32 enum.

Parameters
rangeESP32-specific range identifier
Returns
Error code (TEMP_SUCCESS on success)

◆ SetRange()

hf_temp_err_t EspTemperature::SetRange ( float min_celsius,
float max_celsius )
overridevirtualnoexcept

Set temperature measurement range (ESP32-C6 supported)

Parameters
min_celsiusMinimum temperature in Celsius
max_celsiusMaximum temperature in Celsius
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ SetThresholds()

hf_temp_err_t EspTemperature::SetThresholds ( float low_threshold_celsius,
float high_threshold_celsius )
overridevirtualnoexcept

Set temperature thresholds (ESP32-C6 supported)

Parameters
low_threshold_celsiusLow temperature threshold
high_threshold_celsiusHigh temperature threshold
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ SetupRange()

hf_temp_err_t EspTemperature::SetupRange ( esp_temp_range_t range)
privatenoexcept

Setup measurement range configuration.

Parameters
rangeRange to configure
Returns
Error code (TEMP_SUCCESS on success)

◆ StartContinuousMonitoring()

hf_temp_err_t EspTemperature::StartContinuousMonitoring ( hf_u32_t sample_rate_hz,
hf_temp_reading_callback_t callback,
void * user_data )
overridevirtualnoexcept

Start continuous temperature monitoring (ESP32-C6 supported)

Parameters
sample_rate_hzSampling rate in Hz
callbackCallback function for each reading
user_dataUser data to pass to callback
Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ StopContinuousMonitoring()

hf_temp_err_t EspTemperature::StopContinuousMonitoring ( )
overridevirtualnoexcept

Stop continuous temperature monitoring (ESP32-C6 supported)

Returns
Error code (TEMP_SUCCESS on success)

Reimplemented from BaseTemperature.

◆ UpdateDiagnostics()

void EspTemperature::UpdateDiagnostics ( hf_temp_err_t error)
privatenoexcept

Update diagnostic information.

Parameters
errorError code from operation

◆ UpdateStatistics()

void EspTemperature::UpdateStatistics ( bool operation_successful,
hf_u32_t operation_time_us )
privatenoexcept

Update operation statistics.

Parameters
operation_successfulWhether the operation was successful
operation_time_usOperation time in microseconds

◆ ValidateConfig()

hf_temp_err_t EspTemperature::ValidateConfig ( const hf_temp_config_t * config) const
privatenoexcept

Validate base configuration.

Parameters
configConfiguration to validate
Returns
Error code (TEMP_SUCCESS if valid)

◆ ValidateEspConfig()

hf_temp_err_t EspTemperature::ValidateEspConfig ( const esp_temp_config_t * esp_config) const
privatenoexcept

Validate ESP32-specific configuration.

Parameters
esp_configESP32 configuration to validate
Returns
Error code (TEMP_SUCCESS if valid)

Member Data Documentation

◆ base_config_

hf_temp_config_t EspTemperature::base_config_
private

Base class configuration.

◆ diagnostics_

hf_temp_diagnostics_t EspTemperature::diagnostics_
private

Diagnostic information.

◆ esp_config_

esp_temp_config_t EspTemperature::esp_config_
private

ESP32-specific configuration.

◆ esp_monitoring_callback_

esp_temp_monitoring_callback_t EspTemperature::esp_monitoring_callback_
private

ESP32-specific monitoring callback.

◆ esp_state_

esp_temp_state_t EspTemperature::esp_state_
private

ESP32-specific state.

◆ esp_threshold_callback_

esp_temp_threshold_callback_t EspTemperature::esp_threshold_callback_
private

ESP32-specific threshold callback.

◆ last_error_

hf_temp_err_t EspTemperature::last_error_
private

Last error code.

◆ monitoring_callback_

hf_temp_reading_callback_t EspTemperature::monitoring_callback_
private

Base monitoring callback.

◆ monitoring_user_data_

void* EspTemperature::monitoring_user_data_
private

User data for monitoring callback.

◆ mutex_

PlatformMutex EspTemperature::mutex_
mutableprivate

Thread safety mutex (RTOS-aware)

◆ RANGE_INFO

const esp_temp_range_info_t EspTemperature::RANGE_INFO
staticprivate
Initial value:
= {
{ESP_TEMP_RANGE_NEG10_80, -10.0f, 80.0f, 1.0f, "-10°C to 80°C (±1°C accuracy, recommended)"},
{ESP_TEMP_RANGE_20_100, 20.0f, 100.0f, 2.0f, "20°C to 100°C (±2°C accuracy, high temp)"},
{ESP_TEMP_RANGE_NEG30_50, -30.0f, 50.0f, 2.0f, "-30°C to 50°C (±2°C accuracy, low temp)"},
{ESP_TEMP_RANGE_50_125, 50.0f, 125.0f, 3.0f, "50°C to 125°C (±3°C accuracy, extreme high)"},
{ESP_TEMP_RANGE_NEG40_20, -40.0f, 20.0f, 3.0f, "-40°C to 20°C (±3°C accuracy, extreme low)"}}
@ ESP_TEMP_RANGE_20_100
20°C to 100°C, ±2°C accuracy (high temperature applications)
Definition EspTemperature.h:68
@ ESP_TEMP_RANGE_NEG30_50
-30°C to 50°C, ±2°C accuracy (low temperature applications)
Definition EspTemperature.h:69
@ ESP_TEMP_RANGE_NEG40_20
-40°C to 20°C, ±3°C accuracy (extreme low temperature)
Definition EspTemperature.h:71
@ ESP_TEMP_RANGE_NEG10_80
-10°C to 80°C, ±1°C accuracy (recommended for most applications)
Definition EspTemperature.h:67
@ ESP_TEMP_RANGE_50_125
50°C to 125°C, ±3°C accuracy (extreme high temperature)
Definition EspTemperature.h:70

Range information table.

ESP32-C6 temperature sensor range information table.

Based on ESP32-C6 hardware specifications and ESP-IDF documentation

◆ s_refcount_

std::atomic< int > EspTemperature::s_refcount_ {0}
staticprivate

Number of active instances.

◆ s_shared_handle_

temperature_sensor_handle_t EspTemperature::s_shared_handle_ = nullptr
staticprivate

Shared ESP-IDF handle.

◆ s_shared_mutex_

PlatformMutex EspTemperature::s_shared_mutex_
staticprivate

Protect shared handle/refcount.

◆ statistics_

hf_temp_statistics_t EspTemperature::statistics_
private

Operation statistics.

◆ TAG

const char * EspTemperature::TAG = "EspTemperature"
staticprivate

ESP-IDF logging tag.

◆ threshold_callback_

hf_temp_threshold_callback_t EspTemperature::threshold_callback_
private

Base threshold callback.

◆ threshold_user_data_

void* EspTemperature::threshold_user_data_
private

User data for threshold callback.


The documentation for this class was generated from the following files: