Skip to content

DHT11 Temperature & Humidity

Read temperature and humidity using the DHT library and a powered sensor with a DATA pull-up.

DHT11 Temperature & Humidity: the matching Arduino Uno circuit rendered in Circuitera’s simulator
Matching Circuitera simulator circuit. Real firmware capture; modeled components are idealized.

Wire it up

Disconnect power before changing connections. Follow terminal names rather than wire colors.

FromToWhy it matters
DHT11 (sensor1) · VCCUno · 5VPower connection
DHT11 (sensor1) · GNDUno · GND.1Ground reference
DHT11 (sensor1) · DATAUno · 2Match this terminal to the sketch
Resistor (pullup) · 1Uno · 5VPower connection
Resistor (pullup) · 2DHT11 (sensor1) · DATAMatch this terminal to the sketch

The complete sketch

dht11-environment.ino
#include <DHT.h>
DHT sensor(2, DHT11);
void setup() { Serial.begin(9600); sensor.begin(); }
void loop() {
  float temperature = sensor.readTemperature();
  float humidity = sensor.readHumidity();
  if (isnan(temperature) || isnan(humidity)) {
    Serial.println("Read failed");
  } else {
    Serial.print("temperature:"); Serial.print(temperature);
    Serial.print(" humidity:"); Serial.println(humidity);
  }
  delay(2000);
}

The launch buttons use this same code and a matching saved circuit.

Build it step by step

  1. Open a complete project

    Launch in Simulator creates a separate Uno sketch and its matching wired circuit. Existing sketches are preserved. Press Run to compile and execute.

  2. Explore the live circuit

    Run for at least two seconds, open simulated serial output, and change the sensor temperature or humidity.

  3. Try it on hardware

    Disconnect power while wiring. Match terminal names in the table, select the exact board, Verify, then connect and upload. Check component ratings and power requirements first.

Understand the sketch

A timed digital protocol

The DHT library decodes timed data pulses. The simulator supplies ideal DHT11 frames from its temperature and humidity properties; it does not model sensor accuracy or environmental lag.

If something is different

Read failed

Use DHT11 in the constructor and a 10 kΩ DATA-to-5 V pull-up. NC remains unconnected. Wait between readings.

Expected output and tested scope

Serial output contains temperature and humidity readings; the default modeled sensor state is approximately 25 °C and 50% relative humidity.

Version 1 · Last source- and build-matched test: 2026-10-25. Actual shipped AVR-GCC WASM compilation and Uno AVR engine execution; no physical hardware test.

Supported tutorial target: Arduino Uno R3 / ATmega328P. Compile: PASS · Modeled execution: PASS. Other boards require a separate review of pins, voltage, libraries and the exact build profile.

Keep exploring.