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:
Include lm75.h
Initialize I2C descriptor by i2cdev_init()
Initialize LM75 descriptor by lm75_init_desc()
Initialize LM75 by lm75_init()
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.
-
enumerator LM75_MODE_NORMAL¶
-
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.
-
enumerator LM75_OSP_LOW¶
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.
- Parameters
dev – [out] pointer to LM75 device descriptor
addr – [in] I2C address of LM75
port – [in] I2C port
sda_gpio – [in] GPIO number of SDA
scl_gpio – [in] GPIO number of SCL
- Returns
ESP_OK
on success
-
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
dev – [in] pointer to LM75 device descriptor
config – [in] 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.
- Parameters
dev – [in] pointer to LM75 device descriptor
v – [out] value of OS Polarity
- Returns
ESP_OK
on success
-
esp_err_t lm75_get_os_threshold(i2c_dev_t *dev, float *value)¶
Get the value of OS threshold in the configuration register.
- Parameters
dev – [in] pointer to LM75 device descriptor
value – [out] value of OS threshold
- Returns
ESP_OK
on success
-
esp_err_t lm75_read_temperature(i2c_dev_t *dev, float *value)¶
Read the temperature.
- Parameters
dev – [in] pointer to LM75 device descriptor
value – [out] temperature
- Returns
ESP_OK
on success
-
esp_err_t lm75_set_os_mode(i2c_dev_t *dev, const lm75_os_mode_t v)¶
Set OS mode.
- Parameters
dev – [in] pointer to LM75 device descriptor
v – [in] OS mode
- Returns
ESP_OK
on success
-
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.
- Parameters
dev – [in] pointer to LM75 device descriptor
v – [in] value of OS Polarity
- Returns
ESP_OK
on success
-
esp_err_t lm75_set_os_threshold(i2c_dev_t *dev, const float value)¶
Set the value of OS threshold in the configuration register.
- Parameters
dev – [in] pointer to LM75 device descriptor
value – [in] value of OS threshold
- Returns
ESP_OK
on success
-
struct lm75_config_t¶
- #include <lm75.h>
Device configuration.
Public Members
-
lm75_mode_t mode¶
Operation mode of the device.
-
lm75_os_polarity_t os_pol¶
OS Polarity.
-
lm75_os_mode_t os_mode¶
OS mode.
-
lm75_fault_queue_t os_fault_queue¶
OS fault queue.
-
lm75_mode_t mode¶