Week 9 ยท Integration & Task C
Session 41: DHT11 temperature and humidity on the LCD
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.
Session plan
- 0:0010 minRecap
Task B reflections
- 0:1020 minDemo
A library-based sensor
Install both Adafruit libraries, run the worked sketch, then unplug the data wire to show NaN.
- 0:3040 minBuild
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().
- 1:1035 minMeasure
Compare three thermometers
Students compare the DHT11 temperature with their calibrated thermistor and the reference thermometer and record the differences.
- 1:4515 minWrap-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.