add dht dependency

This commit is contained in:
2025-12-02 20:07:04 +01:00
parent 6dd232fb83
commit 615637e24c
3 changed files with 14 additions and 1 deletions

View File

@@ -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")

View File

@@ -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

View File

@@ -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);
}