From 615637e24c0972cb372ddf559da5b4f62a6fa361 Mon Sep 17 00:00:00 2001 From: Sergio Semedi Date: Tue, 2 Dec 2025 20:07:04 +0100 Subject: [PATCH] add dht dependency --- main/CMakeLists.txt | 2 +- main/include/temp.h | 4 ++++ main/src/temp.c | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 7b976bf..4c2deee 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,5 +1,5 @@ file(GLOB_RECURSE srcs "main.c" "src/*.c") idf_component_register(SRCS "${srcs}" - PRIV_REQUIRES bt nvs_flash esp_driver_gpio + PRIV_REQUIRES bt nvs_flash esp_driver_gpio dht INCLUDE_DIRS "./include") diff --git a/main/include/temp.h b/main/include/temp.h index cc609da..7215218 100644 --- a/main/include/temp.h +++ b/main/include/temp.h @@ -4,12 +4,16 @@ /* Includes */ /* ESP APIs */ #include "esp_random.h" +#include "dht.h" /* Defines */ #define HEART_RATE_TASK_PERIOD (1000 / portTICK_PERIOD_MS) +#define DHT_GPIO_PIN 23 +#define DHT_SENSOR_TIPO DHT_TYPE_DHT11 /* Public function declarations */ uint8_t get_temp(void); void update_temp(void); +void init_sensor(void); #endif // HEART_RATE_H diff --git a/main/src/temp.c b/main/src/temp.c index f9219c5..18238d2 100644 --- a/main/src/temp.c +++ b/main/src/temp.c @@ -1,6 +1,7 @@ /* Includes */ #include "common.h" #include "temp.h" +#include "driver/gpio.h" /* Private variables */ static uint8_t heart_rate; @@ -9,3 +10,11 @@ static uint8_t heart_rate; uint8_t get_temp(void) { return heart_rate; } void update_temp(void) { heart_rate = 60 + (uint8_t)(esp_random() % 21); } + +void init_sensor(void) { + // DHT PULL up resistor config + gpio_set_direction(DHT_GPIO_PIN, GPIO_MODE_INPUT); + gpio_pullup_en(DHT_GPIO_PIN); + + printf("DHT sensor config init, pull up resistor and pin: %d\n", DHT_GPIO_PIN); +}