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 descriptior by i2cdev_init()
Initialize LM75 descriptior 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
-
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
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 descriptior.
i2cdev_init() must be called before this function.
- Return
ESP_OK
on success- Parameters
[out] dev
: pointer to LM75 device descriptior[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 descriptior[in] config
: configuration
-
esp_err_t
lm75_free_desc
(i2c_dev_t *dev)¶ free LM75 device descriptior
- 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 descriptior[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 descriptior[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 descriptior[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 descriptior[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 descriptior[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 descriptior[in] value
: value of OS threshold
-
struct
lm75_config_t
¶ - #include <lm75.h>
Device configuration.