This web server was prototyped on an Adafruit ESP32 Feather V2 with a SparkFun Atmospheric Sensor Breakout - BME280 (Qwiic), using the Arduino Version 2.1.0 IDE. The ESP32 board is connected to the BME280 using an I2C interface. The BME280 is at address 0x77.
There are two web pages:- The page at /current gives you the current temperature (deg. F), relative humidity (%), dew point (deg. F), and barometric pressure (hPa) readings.
- The page at / (root) gives you a plot of the temperature, relative humidity, dew point, and pressure for up to the past three days.
Other features:
- This server uses Unix time (seconds since midnight January 1, 1970) to time-tag the samples of temperature, humidity, dew point, and pressure. It uses an internal timer in the ESP32 to measure time.
- The server sets its real-time clock over the web (using NTP servers) when it starts up, and every three days plus a random number of seconds up to about four hours thereafter.
- The server uses chunked data transmission to transfer data to the client in JSON format. Using chunked transmission means we don't have to store the entire JSON response, which can be up to 1440 samples of five parameters per sample.
The following Arduino libraries are required:
- Arduinojson by Benoit Blanchon (v. 6.21.2 was used)
- ESP32AsyncWebSrv by dvarrel (v. 1.2.6 was used)
- ESPAsyncTCP by dvarrel (v. 1.2.4 was used)
- SparkFun BME280 by SparkFun Electronics (v. 2.0.9 was used)
- ESP32Time by fbiego (v. 2.0.0 was used)
- WiFi
- SPIFFS
Install any Arduino libraries listed above that you don't already have in your IDE.
Change the Wi-Fi ssid and password in lines 13 and 14 of the .ino file to your network ssid and password. Build and upload the .ino file to your ESP32 board using the Arduino IDE.