You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1002 B
40 lines
1002 B
2 years ago
|
/**
|
||
|
* TODO file description
|
||
|
*/
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <FreeRTOS.h>
|
||
|
#include <task.h>
|
||
|
#include "meteo_task.h"
|
||
|
#include "ds18b20.h"
|
||
|
#include "dht.h"
|
||
|
#include "driver/gpio.h"
|
||
|
|
||
|
void meteo_task(void* pvParameters)
|
||
|
{
|
||
|
// Try to unfuck GPIOs
|
||
|
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
|
||
|
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
|
||
|
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);
|
||
|
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);
|
||
|
|
||
|
float dht_hum, dht_temp, ds_temp;
|
||
|
while (1) {
|
||
|
// this works ...
|
||
|
ds_temp = ds18b20_measure_and_read(0, DS18B20_ANY);
|
||
|
if (ds_temp != ds_temp) { // NAN
|
||
|
printf("Fail to read temp\n");
|
||
|
} else {
|
||
|
printf("Dallas: %f °C\n", ds_temp);
|
||
|
}
|
||
|
|
||
|
if (dht_read_float_data(DHT_TYPE_DHT11, 12, &dht_hum, &dht_temp)) {
|
||
|
printf("DHT: %f °C, %f %%r.H\n", dht_temp, dht_hum);
|
||
|
}
|
||
|
|
||
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||
|
}
|
||
|
|
||
|
vTaskDelete(NULL);
|
||
|
}
|