renamed: main/include/sensor.h -> main/include/sht31.h
modified: main/src/main.c deleted: main/src/sensor.c new file: main/src/sht31.c modified: sdkconfig
This commit is contained in:
1 parent
2c62e70390
commit
34e0561f46
5 files changed
+182
-60
No files matched your search
@@ -12,11 +12,11 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "leds.h"
|
||||
#include "sensor.h"
|
||||
#include "sht31.h"
|
||||
#include "http_client.h"
|
||||
|
||||
|
||||
//static const char * TAG = "main.c";
|
||||
static const char * TAG = "main.c";
|
||||
/*
|
||||
static void wifi_init(void) {
|
||||
tcpip_adapter_init();
|
||||
@@ -36,6 +36,25 @@ static void wifi_init(void) {
|
||||
}
|
||||
*/
|
||||
|
||||
void sensor_tester(void)
|
||||
{
|
||||
ESP_ERROR_CHECK(sht31_init());
|
||||
|
||||
//float temperature, humidity;
|
||||
int temperature, humidity;
|
||||
|
||||
while (1) {
|
||||
//if (sht31_read_temp_hum(&temperature, &humidity) == ESP_OK) {
|
||||
if (sht31_read_temp_hum_int(&temperature, &humidity) == ESP_OK) {
|
||||
//ESP_LOGI(TAG, "Temperature: %.2f°C, Humidity: %.2f%%", temperature, humidity);
|
||||
ESP_LOGI(TAG, "Temperature: %i°C, Humidity: %i%%", temperature, humidity);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to read from SHT31 sensor");
|
||||
}
|
||||
vTaskDelay(2000 / portTICK_RATE_MS);
|
||||
}
|
||||
}
|
||||
|
||||
// Task to read data from UART
|
||||
void uart_read_task(void *pvParameters) {
|
||||
const unsigned bufferSize = 1024;
|
||||
@@ -95,6 +114,9 @@ void app_main()
|
||||
|
||||
//wifi_init();
|
||||
initLEDs();
|
||||
|
||||
sensor_tester();
|
||||
|
||||
//xTaskCreate(&led_blink_task, "led_blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
|
||||
xTaskCreate(uart_read_task, "uart_read_task", 2048, NULL, 10, NULL);
|
||||
//xTaskCreate(main_task, "main task", 2048, NULL, tskIDLE_PRIORITY, NULL);
|
||||
|
||||
Reference in new issue
Block a user