diff --git a/main/main.c b/main/main.c index 53005f0..cf201bd 100644 --- a/main/main.c +++ b/main/main.c @@ -10,6 +10,7 @@ #include #include "bme280.h" +#include "dht22.h" static const char *TAG = "BME280"; @@ -34,6 +35,27 @@ int8_t bme280_readout(); int8_t lastReadoutStatus = 1; extern struct bme280_dev bme280; // from bme280_sup.c +void DHT_task(void *pvParameter) +{ + setDHTgpio( 32 ); + printf( "Starting DHT Task\n\n"); + + while(1) { + + printf("=== Reading DHT ===\n" ); + int ret = readDHT(); + + errorHandler(ret); + + printf( "Hum %.1f\n", getHumidity() ); + printf( "Tmp %.1f\n", getTemperature() ); + + // -- wait at least 2 sec before reading again ------------ + // The interval of whole process must be beyond 2 seconds !! + vTaskDelay( 3000 / portTICK_RATE_MS ); + } +} + void app_main(void) { static httpd_handle_t server = NULL; @@ -69,6 +91,9 @@ void app_main(void) /* lastReadoutStatus = bme280_readout(); */ /* vTaskDelay(1600/portTICK_PERIOD_MS); */ /* } */ + + vTaskDelay( 1000 / portTICK_RATE_MS ); + xTaskCreate( &DHT_task, "DHT_task", 2048, NULL, 5, NULL ); } struct bme280_data comp_data;