Give your Uno a weather sense. These tiny sensors spit out temperature and relative humidity on one digital wire — perfect for greenhouses, incubators, and “is my room muggy?” gadgets.
What you will learn
Pick a sensor
DHT11 (cheap & fast) vs DHT22 (wider & sharper).
Pinout
VCC, Data, NC, GND — same on both.
Wire & code
Pull-up, DHTlib, Serial °C and %RH.
Swap tip
Same wiring — just change read11 / read22.
New to Uno? Finish Basic Arduino first. Coming from motion sensing? You already use digital pins from the PIR lesson.
Why DHT sensors?
Want a greenhouse log, a humidor controller, or a tiny weather station? DHT11 and DHT22 (also sold as AM2302) are factory-calibrated humidity + temperature packages. No extra amplifier chips — just power, ground, and one Data wire.
They report values with one decimal place. The trade-off: new readings only about once or twice per second. For room climate that is plenty.
Meet DHT11 & DHT22
They look related and share the same pinout, but the white DHT22 is the sharper, wider-range sibling. Blue DHT11 wins on price, size, and sampling speed.
Left: compact blue DHT11. Right: taller white DHT22. Both shown on 3-pin breakout boards (NC already omitted).
Compare at a glance
Spec
DHT11
DHT22
Operating voltage
3 to 5 V
3 to 5 V
Max current
2.5 mA max
2.5 mA max
Humidity range
20–80% / ±5%
0–100% / 2–5%
Temperature range
0–50 °C / ±2 °C
−40 to 80 °C / ±0.5 °C
Sampling rate
1 Hz (every 1 s)
0.5 Hz (every 2 s)
Body size
15.5 × 12 × 5.5 mm
15.1 × 25 × 7.7 mm
Advantage
Ultra low cost
More accurate
DHT22 covers freerzer-to-sauna and wetter air. DHT11 is cheaper, smaller, and updates twice as often. Wiring stays the same if you swap them — only the sketch’s read11 / read22 call changes.
Pinout VCCDataNCGND
Bare sensors have four pins. Looking at the grille face, left to right:
Common grille-face order: VCC · Data · NC · GND. Always check silkscreen — modules may label S / + / −.
VCC
Power 3.3–5.5 V. Prefer 5 V on Uno (longer Data cable OK).
Data
Single-wire digital chat with the MCU. Needs a pull-up to VCC.
NC
Not connected — leave open on 4-pin parts.
GND
0 V return. Share with Uno GND.
Module tip: many black breakout boards (like the hero photo) already hide NC and include a pull-up resistor — three pins only.
How a DHT “feels” the air
Crack open the case (in your mind) and you find three friends working together.
Humidity cell: two electrodes with a moisture-loving film. Wetter air → more ions → resistance drops.
NTC thermistor: a resistor that drops ohms as it warms (Negative Temperature Coefficient).
Tiny IC: reads both, applies factory calibration, and squirts a digital packet on the Data pin.
You never do the analog maths — the sensor already speaks “%RH and °C” in bits.
Try it: pretend readings
Press Sample for a playful indoor climate reading. Real hardware will print similar numbers in Serial Monitor.
Temperature24.0 °C
Humidity55 %
Demo only — upload the sketch for live sensor data.
Wiring to Arduino Uno
Three useful wires. On a bare 4-pin sensor, leave NC open and add a 10 kΩ resistor from Data to VCC so the line idles HIGH.
Suggested lesson pin: Data → D8. Change the sketch if you pick another digital pin.
DHT pin
Arduino Uno
VCC
5V
GND
GND
Data
Digital pin 8 (+ 10 kΩ to 5V if no onboard pull-up)
NC
Leave open
Cable length: at 5 V you can often place the sensor up to ~20 m away. At 3.3 V keep it near (~1 m) or readings get weird from voltage drop.
Library — DHTlib
These sensors use a picky single-wire timing protocol. The easy path is the DHTlib library.
Arduino IDE → Sketch → Include Library → Manage Libraries…
Search dhtlib (Rob Tillaart).
Install the single matching entry.
Then call DHT.read22(pin) for DHT22/AM2302, or DHT.read11(pin) for DHT11.
Example sketch — Serial Monitor
Upload, open Tools → Serial Monitor at 9600 baud, wait a couple of seconds between samples. Blow gently on the grille — humidity should climb.