|
NTC Thermistor Driver
API reference
|
Hardware-agnostic NTC thermistor driver. More...
#include <ntc_thermistor.hpp>
Public Member Functions | |
| NtcThermistor (NtcType ntc_type, AdcType *adc_interface) noexcept | |
| Constructor with NTC type and ADC interface. | |
| NtcThermistor (const ntc_config_t &config, AdcType *adc_interface) noexcept | |
| Constructor with custom configuration. | |
| NtcThermistor (const NtcThermistor &)=delete | |
| Copy constructor is deleted. | |
| NtcThermistor & | operator= (const NtcThermistor &)=delete |
| Assignment operator is deleted. | |
| NtcThermistor (NtcThermistor &&) noexcept=default | |
| Move constructor. | |
| NtcThermistor & | operator= (NtcThermistor &&) noexcept=default |
| Move assignment operator. | |
| virtual | ~NtcThermistor () noexcept=default |
| Virtual destructor. | |
| bool | Initialize () noexcept |
| Initialize the NTC thermistor driver. | |
| bool | Deinitialize () noexcept |
| Deinitialize the NTC thermistor driver. | |
| bool | IsInitialized () const noexcept |
| Check if initialized. | |
| NtcError | GetConfiguration (ntc_config_t *config) const noexcept |
| Get current configuration. | |
| NtcError | SetConfiguration (const ntc_config_t &config) noexcept |
| Set configuration. | |
| NtcError | ReadTemperatureCelsius (float *temperature_celsius) noexcept |
| Read temperature in Celsius. | |
| NtcError | ReadTemperatureFahrenheit (float *temperature_fahrenheit) noexcept |
| Read temperature in Fahrenheit. | |
| NtcError | ReadTemperatureKelvin (float *temperature_kelvin) noexcept |
| Read temperature in Kelvin. | |
| NtcError | ReadTemperature (ntc_reading_t *reading) noexcept |
| Read complete temperature information. | |
| NtcError | GetResistance (float *resistance_ohms) noexcept |
| Get thermistor resistance. | |
| NtcError | GetVoltage (float *voltage_volts) noexcept |
| Get voltage across thermistor. | |
| NtcError | GetRawAdcValue (uint32_t *adc_value) noexcept |
| Get raw ADC value. | |
| NtcError | Calibrate (float reference_temperature_celsius) noexcept |
| Calibrate the thermistor. | |
| NtcError | SetCalibrationOffset (float offset_celsius) noexcept |
| Set calibration offset. | |
| NtcError | GetCalibrationOffset (float *offset_celsius) const noexcept |
| Get calibration offset. | |
| NtcError | ResetCalibration () noexcept |
| Reset calibration. | |
| NtcError | SetConversionMethod (NtcConversionMethod method) noexcept |
| Set conversion method. | |
| NtcError | SetVoltageDivider (float series_resistance) noexcept |
| Set voltage divider parameters. | |
| NtcError | SetReferenceVoltage (float reference_voltage) noexcept |
| Set reference voltage. | |
| NtcError | SetBetaValue (float beta_value) noexcept |
| Set beta value. | |
| NtcError | SetAdcChannel (uint8_t adc_channel) noexcept |
| Set ADC channel. | |
| NtcError | SetSamplingParameters (uint32_t sample_count, uint32_t sample_delay_ms) noexcept |
| Set sampling parameters. | |
| NtcError | SetFiltering (bool enable, float alpha=0.1F) noexcept |
| Enable/disable filtering. | |
Static Public Member Functions | |
| static float | CelsiusToFahrenheit (float celsius) noexcept |
| Convert Celsius to Fahrenheit. | |
| static float | FahrenheitToCelsius (float fahrenheit) noexcept |
| Convert Fahrenheit to Celsius. | |
| static float | CelsiusToKelvin (float celsius) noexcept |
| Convert Celsius to Kelvin. | |
| static float | KelvinToCelsius (float kelvin) noexcept |
| Convert Kelvin to Celsius. | |
| static const char * | GetErrorString (NtcError error) noexcept |
| Get error string. | |
| static const char * | GetTypeString (NtcType type) noexcept |
| Get NTC type string. | |
| static constexpr const char * | GetDriverVersion () noexcept |
| Get the compiled driver version string. | |
| static constexpr uint8_t | GetDriverVersionMajor () noexcept |
| Get the compiled driver major version number. | |
| static constexpr uint8_t | GetDriverVersionMinor () noexcept |
| Get the compiled driver minor version number. | |
| static constexpr uint8_t | GetDriverVersionPatch () noexcept |
| Get the compiled driver patch version number. | |
Hardware-agnostic NTC thermistor driver.
This class provides a comprehensive interface for temperature measurement using NTC thermistors. It supports various NTC types and provides both lookup table and mathematical conversion methods.
Key features:
| AdcType | The ADC implementation type that inherits from ntc::AdcInterface<AdcType> |
|
noexcept |
Constructor with NTC type and ADC interface.
Creates an NTC thermistor instance with default configuration for the specified NTC type. The configuration is automatically initialized with appropriate values for the thermistor type.
| ntc_type | NTC thermistor type (e.g., NtcType::NtcG163Jf103Ft1S) |
| adc_interface | Pointer to ADC interface (must inherit from ntc::AdcInterface<AdcType>) |
|
noexcept |
Constructor with custom configuration.
| config | NTC configuration structure |
| adc_interface | Pointer to ADC interface (must inherit from ntc::AdcInterface<AdcType>) |
|
delete |
Copy constructor is deleted.
|
defaultnoexcept |
Move constructor.
|
virtualdefaultnoexcept |
Virtual destructor.
|
noexcept |
Calibrate the thermistor.
Takes a reading (current offset applied) and adds (reference - reading) to the offset, so afterwards the sensor reads the reference temperature whatever offset was set before.
| reference_temperature_celsius | Known reference temperature |
|
staticnoexcept |
Convert Celsius to Fahrenheit.
| celsius | Temperature in Celsius |
|
staticnoexcept |
Convert Celsius to Kelvin.
| celsius | Temperature in Celsius |
|
noexcept |
Deinitialize the NTC thermistor driver.
|
staticnoexcept |
Convert Fahrenheit to Celsius.
| fahrenheit | Temperature in Fahrenheit |
|
noexcept |
Get calibration offset.
| offset_celsius | Pointer to store offset |
|
noexcept |
Get current configuration.
| config | Pointer to store configuration |
|
inlinestaticconstexprnoexcept |
Get the compiled driver version string.
|
inlinestaticconstexprnoexcept |
Get the compiled driver major version number.
|
inlinestaticconstexprnoexcept |
Get the compiled driver minor version number.
|
inlinestaticconstexprnoexcept |
Get the compiled driver patch version number.
|
staticnoexcept |
Get error string.
| error | Error code |
|
noexcept |
Get raw ADC value.
| adc_value | Pointer to store ADC value |
|
noexcept |
Get thermistor resistance.
| resistance_ohms | Pointer to store resistance |
|
staticnoexcept |
|
noexcept |
Get voltage across thermistor.
| voltage_volts | Pointer to store voltage |
|
noexcept |
Initialize the NTC thermistor driver.
|
noexcept |
Check if initialized.
|
staticnoexcept |
Convert Kelvin to Celsius.
| kelvin | Temperature in Kelvin |
|
delete |
Assignment operator is deleted.
|
defaultnoexcept |
Move assignment operator.
|
noexcept |
Read complete temperature information.
| reading | Pointer to store reading information |
|
noexcept |
Read temperature in Celsius.
Performs a complete temperature reading cycle: reads ADC, calculates resistance, converts to temperature, applies filtering (if enabled), and validates the result.
| temperature_celsius | Pointer to store temperature (°C) |
|
noexcept |
Read temperature in Fahrenheit.
| temperature_fahrenheit | Pointer to store temperature |
|
noexcept |
Read temperature in Kelvin.
| temperature_kelvin | Pointer to store temperature |
|
noexcept |
Reset calibration.
|
noexcept |
Set ADC channel.
| adc_channel | ADC channel number |
|
noexcept |
Set beta value.
| beta_value | Beta value (K) |
|
noexcept |
Set calibration offset.
| offset_celsius | Calibration offset in Celsius |
|
noexcept |
Set configuration.
| config | New configuration |
|
noexcept |
Set conversion method.
| method | Conversion method |
|
noexcept |
Enable/disable filtering.
| enable | Enable filtering |
| alpha | Filter alpha value (0.0-1.0) |
|
noexcept |
Set reference voltage.
| reference_voltage | Reference voltage (V) |
|
noexcept |
Set sampling parameters.
| sample_count | Number of samples |
| sample_delay_ms | Delay between samples (ms), waited through the port's optional DelayMs(); ignored by a port without one |
|
noexcept |
Set voltage divider parameters.
| series_resistance | Series resistance (ohms) |