2026-09-11 10:19:50 +02:00
|
|
|
#include <freertos/FreeRTOS.h>
|
|
|
|
|
#include <freertos/task.h>
|
|
|
|
|
#include <esp_system.h>
|
|
|
|
|
|
|
|
|
|
#include "nvs_flash.h"
|
|
|
|
|
#include "esp_http_server.h"
|
|
|
|
|
|
|
|
|
|
#include "ygg_http_server.h"
|
|
|
|
|
#include "ygg_http_routes.h"
|
|
|
|
|
#include "ygg_wifi.h"
|
|
|
|
|
#include "ygg_http_server.h"
|
|
|
|
|
#include "ygg_bmp280.h"
|
2026-09-13 18:14:19 +02:00
|
|
|
#include "ygg_http_req.h"
|
2026-09-11 10:19:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
static const char *TAG = "thermo_sensor";
|
|
|
|
|
float last_temperature = 0.0f;
|
2026-09-11 13:34:55 +02:00
|
|
|
float last_pressure = 0.0f;
|
|
|
|
|
float last_humidity = 0.0f;
|
2026-09-11 10:19:50 +02:00
|
|
|
bmp280_t dev_bmp_280;
|
|
|
|
|
|
|
|
|
|
void main_loop(void *pvParameters) {
|
|
|
|
|
while (1) {
|
2026-09-13 18:14:19 +02:00
|
|
|
vTaskDelay(pdMS_TO_TICKS(10000));
|
2026-09-11 10:19:50 +02:00
|
|
|
ygg_bmp280_read_sensor(&dev_bmp_280);
|
2026-09-13 18:14:19 +02:00
|
|
|
ygg_send_sensor_redouts(last_temperature,
|
|
|
|
|
last_pressure,
|
|
|
|
|
last_humidity);
|
2026-09-11 10:19:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void app_main()
|
|
|
|
|
{
|
|
|
|
|
esp_err_t ret = nvs_flash_init();
|
|
|
|
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
|
|
|
|
ESP_ERROR_CHECK(nvs_flash_erase());
|
|
|
|
|
ret = nvs_flash_init();
|
|
|
|
|
}
|
|
|
|
|
ESP_ERROR_CHECK(ret);
|
|
|
|
|
wifi_init_sta();
|
|
|
|
|
|
|
|
|
|
httpd_handle_t server = ygg_start_webserver();
|
|
|
|
|
httpd_register_uri_handler(server, &ygg_temp_uri);
|
2026-09-11 13:34:55 +02:00
|
|
|
httpd_register_uri_handler(server, &ygg_press_uri);
|
|
|
|
|
httpd_register_uri_handler(server, &ygg_hum_uri);
|
2026-09-11 10:19:50 +02:00
|
|
|
|
|
|
|
|
ESP_ERROR_CHECK(i2cdev_init());
|
|
|
|
|
ygg_bmp280_init(&dev_bmp_280);
|
|
|
|
|
xTaskCreatePinnedToCore(main_loop, "bmp280_test", configMINIMAL_STACK_SIZE * 8, NULL, 5, NULL, APP_CPU_NUM);
|
|
|
|
|
}
|
|
|
|
|
|