Writing the program

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:

  1. 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>
  1. 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;
  1. Prepare our HTML response on the WEATHER_TXT variable:
static const char *TAG="APP";static const char *WEATHER_TXT = ...

Get Internet of Things Projects with ESP32 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.