Small plastic project enclosure with AHT20 sensor and ESP32-C3 breadboard, on a windowsill

Beginner

Build a Room Temperature & Humidity Monitor

SensorsDisplaysIoT

Learn how a controller, environmental sensor and small display work together to measure and show room temperature and humidity in real time.

6 real parts included

Total for this kit: 1,544.00 ฿

Doesn't include any order discount you may get at checkout.

What you'll need

Project Goal

This project turns three individual parts into a small working instrument: a real-time readout of the temperature and humidity in a room. It's a good first project because it touches every fundamental skill (wiring, power, reading a sensor, driving a display) without needing wireless, motors, or anything safety-critical.

What the Controller Does

The controller runs one small program on a loop: read the sensor, format the values, send them to the display, wait briefly, and repeat. It's the only "brain" in the project -- the sensor and display are both dumb peripherals that do exactly what the controller tells them to.

What the Environmental Sensor Does

The sensor measures temperature and humidity and reports both values back to the controller over a digital interface, rather than the controller having to interpret a raw analog voltage. This is normal for combined temperature/humidity sensors -- the sensor itself does the analog-to-digital conversion internally.

What the Display Does

The display exists purely to show the two numbers somewhere a person can read them. It has no logic of its own -- the controller sends it exactly what to draw, on every refresh.

Common I2C Wiring Concepts

Many sensor and display modules used in a project like this share an I2C bus: two shared signal wires (clock and data) plus power and ground, with each device identified by its own address. If your specific sensor and display both use I2C, they can typically share the same two signal wires -- check each module's default address to make sure they don't conflict before wiring both up at once.

Voltage Considerations

Confirm the supply voltage and logic voltage of both the sensor and the display against what your controller provides on its pins before connecting anything. Mismatched logic voltage between modules on the same bus is one of the most common sources of unreliable readings or a display that never initializes.

Software and Library Concepts

Both the sensor and the display will have working example code available for common controller platforms. Start from a manufacturer or community example for each part individually, confirm both work on their own, and only then combine them into one program -- debugging two new, untested parts at once is significantly harder than debugging one at a time.

Testing and Troubleshooting

  • No readings at all -- check power and ground first, then confirm the sensor's address matches what your code expects.
  • Display stays blank -- confirm its own power connection separately from the sensor; a shared bus issue with one device can sometimes affect the other.
  • Readings look wrong or jump around -- check for a loose wire or a logic-voltage mismatch before assuming the sensor itself is faulty.
  • Nothing updates after the first reading -- confirm your loop actually re-reads the sensor each cycle rather than reusing the first value.

Optional Future Upgrade: Wi-Fi Logging

Once the basic version is working reliably, a natural next step is adding a wireless connection so readings can be logged remotely instead of only being visible on the local display -- see the wireless data logger project for the concepts involved.

Wiring

  • AHT20 VIN → ESP32-C3 SuperMini 3.3V — sensor power
  • AHT20 GND → ESP32-C3 SuperMini GND
  • AHT20 SDA → ESP32-C3 SuperMini GPIO8 — I2C data (Arduino-ESP32 default SDA)
  • AHT20 SCL → ESP32-C3 SuperMini GPIO9 — I2C clock (Arduino-ESP32 default SCL)

This is a single-device I2C bus, so no address conflicts and no external pull-up resistors needed (the AHT20 breakout carries its own). Give the AHT20 a couple of seconds after power-up before trusting readings, and if it lives in an enclosure, add a small vent cutout near the sensor — a sealed box will trap self-heating from the ESP32 and read a few degrees high.

Wiring Diagram

VIN → 3.3V GND SDA → GPIO8 SCL → GPIO9 ESP32-C3 SuperMini AHT20

Starter Code

#include <Wire.h>
#include <Adafruit_AHTX0.h>

// Adjust these if your board's silkscreen differs from the common
// ESP32-C3/S3 default I2C pins
#define SDA_PIN 8
#define SCL_PIN 9

Adafruit_AHTX0 aht;
sensors_event_t humidityEvent, tempEvent;

const unsigned long READ_INTERVAL_MS = 2000;
unsigned long lastRead = 0;

void setup() {
  Serial.begin(115200);
  delay(500);

  Wire.begin(SDA_PIN, SCL_PIN);

  if (!aht.begin()) {
    Serial.println("AHT20 not found — check wiring.");
    while (1) delay(1000);
  }
  Serial.println("AHT20 initialized.");
}

void loop() {
  unsigned long now = millis();
  if (now - lastRead >= READ_INTERVAL_MS) {
    lastRead = now;

    aht.getEvent(&humidityEvent, &tempEvent);

    Serial.print("Temperature: ");
    Serial.print(tempEvent.temperature);
    Serial.print(" C   Humidity: ");
    Serial.print(humidityEvent.relative_humidity);
    Serial.println(" %");
  }
}

Not sure about a step? Ask us