Week 9 ยท Integration & Task C

Session 41: DHT11 temperature and humidity on the LCD

Teach & build120 minLesson 25: DHT11 / DHT22 Temperature & Humidity

Learning outcomes

  • Wire a DHT11 and install the Adafruit DHT libraries
  • Read temperature and humidity no faster than every 2 s
  • Reject failed readings with isnan()
  • Show both values on the LCD at fixed widths

Kit and components

  • Uno, DHT11 module, I2C LCD, breadboard, jumpers
  • Reference thermometer and calibrated thermistor circuit from S37

Pre-reading about 20 min

Students read these on their phones before class. They are listed on the student Before class page.

  1. Lesson 25: What a DHT reports
  2. Lesson 25: Sampling interval
  3. Lesson 25: Libraries and isnan
  4. Theory Reference: Floats with dtostrf (AVR Uno)

Session plan

  1. 0:0010 min
    Recap

    Task B reflections

  2. 0:1020 min
    Demo

    A library-based sensor

    Install both Adafruit libraries, run the worked sketch, then unplug the data wire to show NaN.

  3. 0:3040 min
    Build

    DHT11 on the LCD

    Students combine the worked sketch with their S34 dashboard: temperature and humidity on row 1, sampled every 2 s with millis().

  4. 1:1035 min
    Measure

    Compare three thermometers

    Students compare the DHT11 temperature with their calibrated thermistor and the reference thermometer and record the differences.

  5. 1:4515 min
    Wrap-up

    Why every 2 seconds?

Checkpoint: ready to move on?

Students' LCD shows temperature and humidity updated every 2 s, and a disconnected sensor shows an error instead of a false value.

Extension for fast finishers

Show a comfort message - dry, comfortable or humid - with hysteresis on humidity.

Catch-up path

Show the readings on Serial first, then move them to the LCD.

Homework and practice

Pre-reading for S42.

Facilitator notes

  • Install the DHT sensor library and Adafruit Unified Sensor on the lab PCs before the session.