modified: main/include/http_client.h

new file:   main/include/lib.h
	modified:   main/src/http_client.c
	modified:   main/src/main.c
This commit is contained in:
Sven Luethi committed 2024-07-02 00:23:11 +02:00
1 parent dc78008721
commit db7e8c3237
4 files changed
+96 -10

No files matched your search

+17 -6
View File
@@ -8,8 +8,8 @@
#include "esp_http_client.h"
#include <esp_err.h>
#include "dht.h"
#include "dht.h"
#include "sensor.h"
#include "http_client.h"
@@ -31,7 +31,7 @@ void wifi_init(void) {
ESP_ERROR_CHECK(esp_wifi_start());
ESP_ERROR_CHECK(esp_wifi_connect());
}
/*
void temperature_task(void *arg)
{
ESP_ERROR_CHECK(dht_init(DHT_GPIO, false));
@@ -44,7 +44,6 @@ void temperature_task(void *arg)
// e.g. in dht22, 604 = 60.4%, 252 = 25.2 C
// If you want to print float data, you should run `make menuconfig`
// to enable full newlib and call dht_read_float_data() here instead
//printf("Humidity: %d Temperature: %d\n", humidity, temperature);
printf("Humidity: %d.%d%% Temperature: %d.%d\n", humidity/10, humidity%10, temperature/10,temperature%10);
} else {
printf("Fail to get dht temperature data\n");
@@ -53,12 +52,24 @@ void temperature_task(void *arg)
}
vTaskDelete(NULL);
}
*/
void main_task(void* args) {
//ESP_ERROR_CHECK(dht_init(DHT_GPIO, false));
//vTaskDelay(2000 / portTICK_PERIOD_MS);
float humidity = 0;
float temperature = 0;
while (1)
{
hc_send_sensor_data(50,25);
vTaskDelay(5000 / portTICK_PERIOD_MS);
ESP_ERROR_CHECK(dht_init(DHT_GPIO, false));
vTaskDelay(4000 / portTICK_PERIOD_MS);
if (dht_read_float_data(DHT_TYPE_DHT22, DHT_GPIO, &humidity, &temperature) == ESP_OK) {
} else {
printf("Fail to get dht temperature data\n");
}
hc_send_sensor_data(humidity,temperature);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}