We start by creating a project called weatherweb to implement our program. Our main program file is weatherweb.c inside the main folder, which we will use to write this program on the weatherweb.c file:
- Initialize all the required headers, as follows:
#include <esp_wifi.h>#include <esp_event_loop.h>#include <esp_log.h>#include <esp_system.h>#include <nvs_flash.h>#include <sys/param.h>#include <esp_http_server.h>
- Define the DHT module as DHT22 and GPIO for the DHT module on the 26 pin:
#include <dht.h>static const dht_sensor_type_t sensor_type = DHT_TYPE_DHT22;static const gpio_num_t dht_gpio = 26;
- Prepare our HTML response on the WEATHER_TXT variable:
static const char *TAG="APP";static const char *WEATHER_TXT = ...