Lesson objectives
The goal of this lesson is to teach you how to dynamically display live sensor data — specifically temperature and humidity — on a web page hosted by the ESP32. When you finish the lesson, you will have a fully functional IoT system that displays real-time sensor data directly in a web browser.
List of required components:
![]() |
AHT10 high-precision temperature and humidity sensor |
![]() |
TTGO T-Display ESP32 16MB with WiFi, Bluetooth and 1.1" color LCD screen |
![]() |
Dupont cables, 40 pcs |
Introduction
In the previous lesson, we learned how to set up a basic web server on the ESP32. That server only hosted a static HTML page, but in this lesson we take it a step further by integrating live data. We will modify the web server to serve dynamic HTML content containing live sensor data — specifically temperature and humidity readings from our AHT10 sensor.
This is an important step in creating an interactive IoT project, as it allows users to monitor data remotely from any device with a browser. Instead of checking the serial monitor, users can simply access a web page to see live updates from the ESP32.
Step 1: Overview of dynamic web content
Here, dynamic web content means that the server generates the page with current readings for each request. This does not itself update an already open page automatically; that requires reloading or the automatic refresh in step 5. In this case, temperature and humidity readings will be updated whenever a client (browser) requests the page.
The web server will retrieve the latest sensor data, format it into an HTML structure, and send it to the client. Each time the user opens or refreshes the page, new sensor readings are displayed. This makes it easier to monitor data remotely in real time.
Step 2: Coding the dynamic web page
We will modify our web server code to retrieve temperature and humidity readings from the AHT10 sensor and display them on the web page.
Here is the code:
About the measurements: The station in this series measures temperature and relative humidity using the AHT10. These are indoor climate readings, not direct measurements of CO2, VOCs, or particles. The series name “air quality monitoring” should be understood with this limitation.


