2 · Inputs & sensors
Temperature & humidity (DHT22)
Intermediate18 min
Goal
Read a digital sensor once every 2 seconds.
Why it matters
A digital sensor sets its own pace: reading too fast returns errors.
Steps
- 01Add the DHT22 on pin 7.
- 02Read temperature and humidity.
- 03Space readings by at least 2000 ms using millis().
- 04Print both values on one line.
This tutorial runs inside the Circuitly simulator: your wiring and your code are checked automatically at every step.
Next tutorials
- Read a push button
Light the LED only while the button is pressed.
- Toggle button (debounced)
One press turns on, the next turns off — with no contact bounce.
- Read a potentiometer
Print the analog value of A0 on the serial monitor.
- Convert to volts (map & float)
Turn the ADC's 0–1023 into a 0.00–5.00 V reading.