Source: https://mokxi.com/parts/dht
Updated: 2026-09-28

Part

# Temperature and humidity, DHT22

One wire, forty bits and a checksum. Drag the two sliders for the weather it reads.

or see every part

- 3 pins
- 5 properties

Drawn live by the editor's own code, at the size you see it.

Reference

## Every one of its 3 pins

Pin

What it does

VCC

DATA

GND

This part

## What it does

The DHT22 and its cheaper sibling the DHT11 measure temperature and humidity and report both over one data wire, with no bus standard behind it at all. The board pulls the line low to ask, lets go, and the sensor answers with forty pulses whose widths are the bits, ending in a checksum. Mokxi decodes nothing on the sensor’s behalf: the part drives the pin with the datasheet’s timing and the sketch has to measure it, exactly as on a desk. It also keeps the two habits that confuse people most. A request in the first second after power-up is ignored, so the first reading fails; and the DHT22 only measures every two seconds, handing back its last reading in between, so a sketch that polls faster sees a number that seems stuck. The model property switches between the DHT22 and the DHT11, whose bytes mean different things on the same wire.

How to use it

## How to use the DHT22 with an Arduino

Wire VCC to 5 V, GND to GND and DATA to any digital pin; a three-pin module has its pull-up on board, and a bare four-pin sensor needs a 10 k resistor from DATA to VCC. Then ask for a reading no more than once every two seconds, and check every reading before you use it, because a failed one comes back as nan.

The Adafruit DHT library’s calls compile here as they stand. The floats it returns print normally and take arithmetic of your own; the built-in weather station works in whole tenths only to stay small on the Uno.

Part pin

Board pin

VCC

5 V

DATA

Pin 2

GND

GND

The DHT library compiles on every board here, the ESP32 and the Pico included, and the sensor is happy on 3.3 V.

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

Reading a DHT22 with the DHT library

Reference

## The 5 properties you can set

Property

Default

What it means

model

dht22 (or dht11)

temperature

22

humidity

50

pullup

true

pullup_ohms

5100

How it is modeled

## What is true about the Temperature and humidity, DHT22, here

### The DHT11 and the DHT22

One wire, three pins, forty bits. The blue brick is the DHT11 and the white one
is the DHT22 (also sold as the AM2302); the wire is identical and only the five
bytes differ.

### Not modeled

The accuracy: +/-2 %RH and +/-0.5 C on a DHT22, +/-5 and +/-2 on a DHT11. The
number the slider says is the number that goes on the wire. Nor the seconds the
capacitive element takes to follow a change in the air, nor self-heating.

From Signals you time, not read, in full.

Projects

## See the Temperature and humidity, DHT22 in a project

Shown here on: Arduino Uno R3

Learn

## Where it turns up in a lesson

### In a learn article

- Arduino DHT22 Temperature and Humidity Sensor

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio, no real internet), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

STM32F411 Black Pill

The Black Pill on our own Cortex-M4 core. Pick a program and press Run.

BBC micro:bit V2

The nRF52833 board with its 5x5 LED matrix, buttons A and B and a speaker. Wire the rings to a breadboard.

See every part

## Wire up the Temperature and humidity, DHT22

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building Open the editor
