lm75 - Driver for for LM75, a digital temperature sensor and thermal watchdog

group lm75

ESP-IDF driver for LM75, a digital temperature sensor and thermal watchdog.

The driver depends on i2cdev library in esp-idf-lib.

The driver was written using LM75B.

Short usage instruction:

  1. Include lm75.h

  2. Initialize I2C descriptor by i2cdev_init()

  3. Initialize LM75 descriptor by lm75_init_desc()

  4. Initialize LM75 by lm75_init()

  5. Read temperature by lm75_read_temperature()

Defines

LM75_I2C_ADDRESS_DEFAULT

Default I2C address (A0 == A1 == A2 == 0)

LM75_I2C_ADDRESS_MAX

I2C address (A0 == A1 == A2 == 1)

Enums

enum lm75_mode_t

Operation mode of LM75.

Values:

enumerator LM75_MODE_NORMAL

Normal operation mode.

enumerator LM75_MODE_SHUTDOWN

Shutdown mode.

enum lm75_os_polarity_t

Overtemperature Shutdown Polarity.

Values:

enumerator LM75_OSP_LOW

Overtemperature Shutdown Polarity is active low.

enumerator LM75_OSP_HIGH

OSP is active high.

enum lm75_os_mode_t

Overtemperature Shutdown output mode.

Values:

enumerator LM75_OS_MODE_COMP

OS output mode is comparator.

enumerator LM75_OS_MODE_INT

OS output mode is interrupt.

enum lm75_fault_queue_t

OS fault queue, the number of faults that must occur consecutively to activate the OS output.

Values:

enumerator LM75_FAULT_QUEUE1

1

enumerator LM75_FAULT_QUEUE2

2

enumerator LM75_FAULT_QUEUE4

4

enumerator LM75_FAULT_QUEUE6

6

Functions

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

Initialize LM75 device descriptor.

i2cdev_init() must be called before this function.

Return

ESP_OK on success

Parameters
  • [out] dev: pointer to LM75 device descriptor

  • [in] addr: I2C address of LM75

  • [in] port: I2C port

  • [in] sda_gpio: GPIO number of SDA

  • [in] scl_gpio: GPIO number of SCL

esp_err_t lm75_init(i2c_dev_t *dev, const lm75_config_t config)

Initialize LM75.

lm75_init_desc() must be called before this function.

Parameters
  • [in] dev: pointer to LM75 device descriptor

  • [in] config: configuration

esp_err_t lm75_free_desc(i2c_dev_t *dev)

free LM75 device descriptor

Parameters
  • dev: Pointer to device descriptor

esp_err_t lm75_get_os_polarity(i2c_dev_t *dev, uint8_t *v)

Get the value of OS Polarity in the configuration register.

Return

ESP_OK on success

Parameters
  • [in] dev: pointer to LM75 device descriptor

  • [out] v: value of OS Polarity

esp_err_t lm75_get_os_threshold(i2c_dev_t *dev, float *value)

Get the value of OS threshold in the configuration register.

Return

ESP_OK on success

Parameters
  • [in] dev: pointer to LM75 device descriptor

  • [out] value: value of OS threshold

esp_err_t lm75_read_temperature(i2c_dev_t *dev, float *value)

Read the temperature.

Return

ESP_OK on success

Parameters
  • [in] dev: pointer to LM75 device descriptor

  • [out] value: temperature

esp_err_t lm75_set_os_mode(i2c_dev_t *dev, const lm75_os_mode_t v)

Set OS mode.

Return

ESP_OK on success

Parameters
  • [in] dev: pointer to LM75 device descriptor

  • [in] v: OS mode

esp_err_t lm75_set_os_polarity(i2c_dev_t *dev, const lm75_os_polarity_t v)

Set the value of OS Polarity in the configuration register.

Return

ESP_OK on success

Parameters
  • [in] dev: pointer to LM75 device descriptor

  • [in] v: value of OS Polarity

esp_err_t lm75_set_os_threshold(i2c_dev_t *dev, const float value)

Set the value of OS threshold in the configuration register.

Return

ESP_OK on success

Parameters
  • [in] dev: pointer to LM75 device descriptor

  • [in] value: value of OS threshold

esp_err_t lm75_shutdown(i2c_dev_t *dev)

Shutdown LM75.

Return

ESP_OK on success

Parameters
  • [in] dev: pointer to LM75 device descriptor

esp_err_t lm75_wakeup(i2c_dev_t *dev)

Wake LM75 up.

Return

ESP_OK on success

Parameters
  • [in] dev: pointer to LM75 device descriptor

struct lm75_config_t
#include <lm75.h>

Device configuration.