add dht dependency
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user