This is a LM75A temperature sensor device driver for ESP32(ESP32-DevKitC).
connect ESP32 and LM75A like this:
LM75A sensor | Despriction | ESP32 (demo) |
---|---|---|
VCC | Power PIN | GPIO2 |
GND | GND | GND |
SDA | A4 (I2C SDA) | GPIO 18 |
SCL | A5 (I2C SCL) | GPIO 19 |
A0 | GND (or VCC to increase I2C address of 1) | None |
A1 | GND (or VCC to increase I2C address of 2) | None |
A2 | GND (or VCC to increase I2C address of 4) | None |
OS | Interrupt PIN | GPIO4 |
- Clone esp-idf and setup it as guide.
- Clone esp32_lm75a
- cd esp32_lm75a
- make menuconfig
- make && make flash
esp32> lm75a init
I (36803) gpio: GPIO[2]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (36803) gpio: GPIO[4]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2
esp32> lm75a temp
lm75a_read_temperature=26.5
esp32> lm75a set_tos 30
lm75a_set_tos: 30
esp32> lm75a set_thys 29
lm75a_set_thys: 29
esp32> lm75a set_int 1
lm75a_set_int: 1
init_os_gpio!
(make temperature high enough to 30)
esp32> GPIO[4] intr, val: 0(interrupt happened)
(make temperature go down below 29)
esp32> GPIO[4] intr, val: 0 (interrupt happened)
esp32> lm75a set_int 0
lm75a_set_int: 0
deinit_os_gpio!
quit gpio_int_task
esp32> lm75a deinit
deinit_os_gpio!