max31725 - Driver for MAX31725/MAX31726 temperature sensors

group max31725

ESP-IDF driver for MAX31725/MAX31726 temperature sensors.

Copyright (C) 2019 Ruslan V. Uss https://github.com/UncleRus

BSD Licensed as described in the file LICENSE

Defines

MAX31725_I2C_ADDR_BASE

See full list in datasheet.

Enums

enum max31725_data_format_t

Temperature data range.

Values:

enumerator MAX31725_FMT_NORMAL

-128 deg.C .

. +127.99609375 deg.C (default)

enumerator MAX31725_FMT_EXTENDED

-64 deg.C .

. +191.99609375 deg.C (max 150 deg.C)

enum max31725_fault_queue_t

Fault queue size.

Values:

enumerator MAX31725_FAULTS_1

1 fault to trigger OS (default)

enumerator MAX31725_FAULTS_2

2 fault to trigger OS

enumerator MAX31725_FAULTS_4

4 fault to trigger OS

enumerator MAX31725_FAULTS_6

6 fault to trigger OS

enum max31725_os_polarity_t

OS polarity.

Values:

enumerator MAX31725_OS_LOW

OS active low (default)

enumerator MAX31725_OS_HIGH

OS active high.

enum max31725_os_mode_t

Mode of OS operation.

Values:

enumerator MAX31725_OS_COMPARATOR

OS comparator mode (default)

enumerator MAX31725_OS_INTERRUPT

OS interrupt mode.

enum max31725_mode_t

Device operating mode.

Values:

enumerator MAX31725_MODE_CONTINUOUS

Continuous measurement mode (default)

enumerator MAX31725_MODE_SHUTDOWN

Shutdown mode.

Functions

esp_err_t max31725_init_desc(i2c_dev_t *dev, i2c_port_t port, uint8_t addr, gpio_num_t sda_gpio, gpio_num_t scl_gpio)

Initialize device descriptor.

Parameters
  • dev – Device descriptor

  • port – I2C port number

  • addr – I2C address

  • sda_gpio – SDA GPIO

  • scl_gpio – SCL GPIO

Returns

ESP_OK on success

esp_err_t max31725_free_desc(i2c_dev_t *dev)

Free device descriptor.

Parameters

dev – Device descriptor

Returns

ESP_OK on success

esp_err_t max31725_get_config(i2c_dev_t *dev, max31725_mode_t *mode, max31725_data_format_t *fmt, max31725_fault_queue_t *fq, max31725_os_polarity_t *op, max31725_os_mode_t *om)

Read current device config.

Parameters
  • dev – Device descriptor

  • [out] mode – Operating mode

  • [out] fmt – Data format

  • [out] fq – Fault queue size

  • [out] op – OS polarity

  • [out] om – OS mode

Returns

ESP_OK on success

esp_err_t max31725_set_config(i2c_dev_t *dev, max31725_mode_t mode, max31725_data_format_t fmt, max31725_fault_queue_t fq, max31725_os_polarity_t op, max31725_os_mode_t om)

Configure device.

Parameters
  • dev – Device descriptor

  • mode – Operating mode

  • fmt – Data format

  • fq – Fault queue size

  • op – OS polarity

  • om – OS mode

Returns

ESP_OK on success

esp_err_t max31725_one_shot(i2c_dev_t *dev, float *temp, max31725_data_format_t fmt)

Made a single-shot measurement.

Works only when device is in shutdown mode. Measurement time is ~50 ms.

Parameters
  • dev – Device descriptor

  • [out] temp – Temperature, deg.C

  • fmt – Data format

Returns

ESP_OK on success

esp_err_t max31725_get_temperature(i2c_dev_t *dev, float *temp, max31725_data_format_t fmt)

Read temperature register.

Parameters
  • dev – Device descriptor

  • [out] temp – Temperature, deg.C

  • fmt – Data format

Returns

ESP_OK on success

esp_err_t max31725_get_os_temp(i2c_dev_t *dev, float *temp, max31725_data_format_t fmt)

Read OS threshold temperature.

Parameters
  • dev – Device descriptor

  • [out] temp – Temperature, deg.C

  • fmt – Data format

Returns

ESP_OK on success

esp_err_t max31725_set_os_temp(i2c_dev_t *dev, float temp, max31725_data_format_t fmt)

Set OS threshold temperature.

Parameters
  • dev – Device descriptor

  • temp – Temperature, deg.C

  • fmt – Data format

Returns

ESP_OK on success

esp_err_t max31725_get_hysteresis_temp(i2c_dev_t *dev, float *temp, max31725_data_format_t fmt)

Read OS hysteresis temperature.

Parameters
  • dev – Device descriptor

  • [out] temp – Temperature, deg.C

  • fmt – Data format

Returns

ESP_OK on success

esp_err_t max31725_set_hysteresis_temp(i2c_dev_t *dev, float temp, max31725_data_format_t fmt)

Set OS hysteresis temperature.

Parameters
  • dev – Device descriptor

  • temp – Temperature, deg.C

  • fmt – Data format

Returns

ESP_OK on success