All tutorials

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

  1. 01Add the DHT22 on pin 7.
  2. 02Read temperature and humidity.
  3. 03Space readings by at least 2000 ms using millis().
  4. 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