Thermistor (thermistor)
NTC Thermistor

General Description

APIs for interacting with an NTC thermistor e.g the NCP18XH103F03RB resistor on the CY8CPROTO-062-4343W board or the CY8CKIT-028-EPD shield Note: This lib uses floating point calculations during temperature calculation so it is recommended to enable floating point support.

Data Structures

struct  mtb_thermistor_ntc_gpio_cfg_t
 Configuration structure containing ntc thermistor constants. More...
 
struct  mtb_thermistor_ntc_gpio_t
 Structure defining the pins and adc channel used to interact with the ntc thermistor. More...
 

Enumerations

enum  mtb_thermistor_ntc_wiring {
  MTB_THERMISTOR_NTC_WIRING_VIN_R_NTC_GND,
  MTB_THERMISTOR_NTC_WIRING_VIN_NTC_R_GND
}
 Defines the way the NTC thermistor is wired up: Vin-NTC-R-GND or Vin-R-NTC-GND. More...
 

Functions

cy_rslt_t mtb_thermistor_ntc_gpio_init (mtb_thermistor_ntc_gpio_t *obj, cyhal_adc_t *adc, cyhal_gpio_t gnd, cyhal_gpio_t vdd, cyhal_gpio_t out, mtb_thermistor_ntc_gpio_cfg_t *cfg, mtb_thermistor_ntc_wiring wiring)
 Initialize the ADC Channel and Pins to communicate with the thermistor. More...
 
float mtb_thermistor_ntc_gpio_get_temp (mtb_thermistor_ntc_gpio_t *obj)
 Gets the temperature reading, in degrees C, from the thermistor. More...
 
void mtb_thermistor_ntc_gpio_free (mtb_thermistor_ntc_gpio_t *obj)
 Frees up the ADC channel and Pins allocated for the thermistor. More...
 

Data Structure Documentation

◆ mtb_thermistor_ntc_gpio_cfg_t

struct mtb_thermistor_ntc_gpio_cfg_t
Data Fields
float r_ref Resistance of the reference resistor.
float b_const Beta constant of the thermistor.
float r_infinity Projected resistance of the thermistor at infinity.

◆ mtb_thermistor_ntc_gpio_t

struct mtb_thermistor_ntc_gpio_t
Data Fields
cyhal_adc_channel_t channel Adc channel obj.
cyhal_gpio_t gnd Ground reference pin.
cyhal_gpio_t vdd VDD reference pin.
cyhal_gpio_t out Voltage output.
mtb_thermistor_ntc_gpio_cfg_t * cfg Ptr to thermistor cfg structure.
mtb_thermistor_ntc_wiring wiring How the thermistor is wired up.

Enumeration Type Documentation

◆ mtb_thermistor_ntc_wiring

Defines the way the NTC thermistor is wired up: Vin-NTC-R-GND or Vin-R-NTC-GND.

Enumerator
MTB_THERMISTOR_NTC_WIRING_VIN_R_NTC_GND 

The thermistor is connected to Ground with the resister between it and Vin.

MTB_THERMISTOR_NTC_WIRING_VIN_NTC_R_GND 

The thermistor is connected to Vin with the resister between it and ground.

Function Documentation

◆ mtb_thermistor_ntc_gpio_init()

cy_rslt_t mtb_thermistor_ntc_gpio_init ( mtb_thermistor_ntc_gpio_t obj,
cyhal_adc_t *  adc,
cyhal_gpio_t  gnd,
cyhal_gpio_t  vdd,
cyhal_gpio_t  out,
mtb_thermistor_ntc_gpio_cfg_t cfg,
mtb_thermistor_ntc_wiring  wiring 
)

Initialize the ADC Channel and Pins to communicate with the thermistor.

Parameters
[in,out]objPointer to a thermistor object containing the set of pins and adc channel that are associated with the thermistor. Note: The caller must allocate the memory for this object but the init function will initialize its contents.
[out]objPointer to a Thermistor object. The caller must allocate the memory for this object but the init function will initialize its contents.
[in]adcPointer to an already initialized adc object
[in]gndGround reference pin
[in]vddVDD reference pin
[in]outVoltage output pin
[in]cfgPointer to the cfg object containing the thermistor constants
[in]wiringHow the circuit is wired up
Returns
CY_RSLT_SUCCESS if properly initialized, else an error indicating what went wrong.

◆ mtb_thermistor_ntc_gpio_get_temp()

float mtb_thermistor_ntc_gpio_get_temp ( mtb_thermistor_ntc_gpio_t obj)

Gets the temperature reading, in degrees C, from the thermistor.

Parameters
[in]objPointer to a thermistor object containing the set of pins and adc channel that are associated with the thermistor.
Returns
The temperature reading, in degrees C, from the hardware.

◆ mtb_thermistor_ntc_gpio_free()

void mtb_thermistor_ntc_gpio_free ( mtb_thermistor_ntc_gpio_t obj)

Frees up the ADC channel and Pins allocated for the thermistor.

Parameters
[in]objThe set of pins and adc channel that are associated with the thermistor