mcp960x - Driver for MCP9600/MCP9601, thermocouple EMF to temperature converter¶
-
group
mcp960x
ESP-IDF driver for MCP960X/L0X/RL0X Thermocouple EMF to Temperature Converter.
Copyright (C) 2020 Ruslan V. Uss unclerus@gmail.com
BSD Licensed as described in the file LICENSE
Enums
-
enum
mcp960x_thermocouple_t
¶ Thermocouple type.
Values:
-
enumerator
MCP960X_TYPE_K
¶ default
-
enumerator
MCP960X_TYPE_J
¶
-
enumerator
MCP960X_TYPE_T
¶
-
enumerator
MCP960X_TYPE_N
¶
-
enumerator
MCP960X_TYPE_S
¶
-
enumerator
MCP960X_TYPE_E
¶
-
enumerator
MCP960X_TYPE_B
¶
-
enumerator
MCP960X_TYPE_R
¶
-
enumerator
-
enum
mcp960x_adc_resolution_t
¶ ADC measurement resolution.
Values:
-
enumerator
MCP960X_ADC_RES_18
¶ 18 bits / 2 uV, 320 ms, default
-
enumerator
MCP960X_ADC_RES_16
¶ 16 bits / 8 uV, 80 ms
-
enumerator
MCP960X_ADC_RES_14
¶ 14 bits / 32 uV, 20 ms
-
enumerator
MCP960X_ADC_RES_12
¶ 12 bits / 128 uV, 5 ms
-
enumerator
-
enum
mcp960x_burst_samples_t
¶ Number of temperature samples in burst mode.
Values:
-
enumerator
MCP960X_SAMPLES_1
¶ default
-
enumerator
MCP960X_SAMPLES_2
¶
-
enumerator
MCP960X_SAMPLES_4
¶
-
enumerator
MCP960X_SAMPLES_8
¶
-
enumerator
MCP960X_SAMPLES_16
¶
-
enumerator
MCP960X_SAMPLES_32
¶
-
enumerator
MCP960X_SAMPLES_64
¶
-
enumerator
MCP960X_SAMPLES_128
¶
-
enumerator
-
enum
mcp960x_mode_t
¶ Operational mdoe.
Values:
-
enumerator
MCP960X_MODE_NORMAL
¶ default
-
enumerator
MCP960X_MODE_SHUTDOWN
¶
-
enumerator
MCP960X_MODE_BURST
¶
-
enumerator
-
enum
mcp960x_tc_resolution_t
¶ Cold-Junction/Ambient sensor resolution.
Values:
-
enumerator
MCP960X_TC_RES_0_0625
¶ 0.0625°C, conversion time: 250 ms
-
enumerator
MCP960X_TC_RES_0_25
¶ 0.25°C, conversion time: 63 ms
-
enumerator
-
enum
mcp960x_status_t
¶ Device status.
Values:
-
enumerator
MCP960X_OK
¶ Device is functioning normally.
-
enumerator
MCP960X_OPEN_CIRCUIT
¶ Open circuit detected on thermocouple input (MCP9601 only)
-
enumerator
MCP960X_SHORT_CIRCUIT
¶ Short circuit detected on thermocouple input (MCP9601 only)
-
enumerator
-
enum
mcp960x_alert_t
¶ Alert.
Values:
-
enumerator
MCP960X_ALERT_1
¶
-
enumerator
MCP960X_ALERT_2
¶
-
enumerator
MCP960X_ALERT_3
¶
-
enumerator
MCP960X_ALERT_4
¶
-
enumerator
-
enum
mcp960x_alert_mode_t
¶ Alert mode.
Values:
-
enumerator
MCP960X_ALERT_DISABLED
¶ Alert disabled.
-
enumerator
MCP960X_ALERT_COMP
¶ Comparator mode.
-
enumerator
MCP960X_ALERT_INT
¶ Interrupt mode.
-
enumerator
-
enum
mcp960x_alert_level_t
¶ Alert output active level.
Values:
-
enumerator
MCP960X_ACTIVE_LOW
¶ Active-low.
-
enumerator
MCP960X_ACTIVE_HIGH
¶ Active-high.
-
enumerator
Functions
-
esp_err_t
mcp960x_init_desc
(mcp960x_t *dev, uint8_t addr, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)¶ Initialize device descriptor.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptoraddr
: Device I2C addressport
: I2C portsda_gpio
: SDA GPIOscl_gpio
: SCL GPIO
-
esp_err_t
mcp960x_free_desc
(mcp960x_t *dev)¶ Free device descriptor.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptor
-
esp_err_t
mcp960x_init
(mcp960x_t *dev)¶ Init device.
Read device HW ID and revision
- Return
ESP_OK
on success- Parameters
dev
: Device descriptor
-
esp_err_t
mcp960x_set_sensor_config
(mcp960x_t *dev, mcp960x_thermocouple_t th, uint8_t filter)¶ Setup thermocouple parameters.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptorth
: Thermocouple typefilter
: Digital filtering level, 0..MCP960X_FILTER_MAX
-
esp_err_t
mcp960x_get_sensor_config
(mcp960x_t *dev, mcp960x_thermocouple_t *th, uint8_t *filter)¶ Get thermocouple parameters.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptor[out] th
: Thermocouple type, NULL-able[out] filter
: Digital filtering level, 0..MCP960X_FILTER_MAX, NULL-able
-
esp_err_t
mcp960x_set_device_config
(mcp960x_t *dev, mcp960x_mode_t mode, mcp960x_burst_samples_t bs, mcp960x_adc_resolution_t adc_res, mcp960x_tc_resolution_t tc_res)¶ Set device configuration.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptormode
: Operation modebs
: Number of temperature samples in burst modeadc_res
: ADC measurement resolutiontc_res
: Cold-Junction/Ambient sensor resolution
-
esp_err_t
mcp960x_get_device_config
(mcp960x_t *dev, mcp960x_mode_t *mode, mcp960x_burst_samples_t *bs, mcp960x_adc_resolution_t *adc_res, mcp960x_tc_resolution_t *tc_res)¶ Get device configuration.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptor[out] mode
: Operation mode, NULL-able[out] bs
: Number of temperature samples in burst mode, NULL-able[out] adc_res
: ADC measurement resolution, NULL-able[out] tc_res
: Cold-Junction/Ambient sensor resolution, NULL-able
-
esp_err_t
mcp960x_set_mode
(mcp960x_t *dev, mcp960x_mode_t mode)¶ Switch device operation mode.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptormode
: Operation mode
-
esp_err_t
mcp960x_get_raw_adc_data
(mcp960x_t *dev, int32_t *data)¶ Get raw ADC data.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptor[out] data
: Raw ADC data
-
esp_err_t
mcp960x_get_thermocouple_temp
(mcp960x_t *dev, float *t)¶ Get thermocouple temperature.
Returns cold-junction compensated and error-corrected thermocouple temperature
- Return
ESP_OK
on success- Parameters
dev
: Device descriptor[out] t
: Temperature, degrees Celsius
-
esp_err_t
mcp960x_get_delta_temp
(mcp960x_t *dev, float *t)¶ Get thermocouple junctions delta temperature.
Returns error corrected thermocouple hot-junction temperature without the cold-junction compensation
- Return
ESP_OK
on success- Parameters
dev
: Device descriptor[out] t
: Temperature, degrees Celsius
-
esp_err_t
mcp960x_get_ambient_temp
(mcp960x_t *dev, float *t)¶ Get cold-junction/ambient temperature.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptor[out] t
: Temperature, degrees Celsius
-
esp_err_t
mcp960x_get_status
(mcp960x_t *dev, bool *temp_ready, bool *burst_ready, mcp960x_status_t *status, bool *alert1, bool *alert2, bool *alert3, bool *alert4)¶ Get device status.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptor[out] temp_ready
: Temperature conversion complete if true, NULL-able[out] burst_ready
: Burst conversion complete if true, NULL-able (burst mode only)[out] status
: Device status, NULL-able[out] alert1
: Alert 1 status, NULL-able[out] alert2
: Alert 2 status, NULL-able[out] alert3
: Alert 3 status, NULL-able[out] alert4
: Alert 4 status, NULL-able
-
esp_err_t
mcp960x_set_alert_config
(mcp960x_t *dev, mcp960x_alert_t alert, mcp960x_alert_mode_t mode, mcp960x_alert_level_t active_lvl, mcp960x_alert_temp_dir_t temp_dir, mcp960x_alert_source_t src, float limit, uint8_t hyst)¶ Setup temperature alert.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptoralert
: Alert indexmode
: Alert modeactive_lvl
: Alert output active leveltemp_dir
: Alert temperature directionsrc
: Alert temperature sourcelimit
: Alert limithyst
: Hysteresis
-
esp_err_t
mcp960x_get_alert_config
(mcp960x_t *dev, mcp960x_alert_t alert, mcp960x_alert_mode_t *mode, mcp960x_alert_level_t *active_lvl, mcp960x_alert_temp_dir_t *temp_dir, mcp960x_alert_source_t *src, float *limit, uint8_t *hyst)¶ Get temperature alert configuration.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptoralert
: Alert index[out] mode
: Alert mode, NULL-able[out] active_lvl
: Alert output active level, NULL-able[out] temp_dir
: Alert temperature direction, NULL-able[out] src
: Alert temperature source, NULL-able[out] limit
: Alert limit, NULL-able[out] hyst
: Hysteresis, NULL-able
-
esp_err_t
mcp960x_get_alert_status
(mcp960x_t *dev, mcp960x_alert_t alert, bool *status)¶ Get alert status.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptoralert
: Alert index[out] status
: Alert status
-
esp_err_t
mcp960x_clear_alert_int
(mcp960x_t *dev, mcp960x_alert_t alert)¶ Clear alert interrupt.
- Return
ESP_OK
on success- Parameters
dev
: Device descriptoralert
: Alert index
-
struct
mcp960x_t
¶ - #include <mcp960x.h>
Device descriptor.
-
enum