7 of the 10 features in our table differ between the DS18B20 and the DHT22.
Analog Devices (Maxim)
DS18B20
±0.5 °C · temperature only · 1-Wire · 3 to 5.5 V
A 1-Wire temperature sensor, ±0.5 °C from −10 to 85 °C, often sold in sealed probes for water, soil and outdoors.
Watch out: Temperature only, and up to 750 ms per 12-bit reading. The data line needs a pull-up resistor.
Aosong
DHT22
±0.5 °C · ±2 %RH · Single wire (own protocol) · 3.3 to 6 V
A step up from the DHT11: ±0.5 °C, ±2 %RH typical and down to −40 °C, still on one data wire.
Watch out: The humidity error can reach ±5 %RH, one reading every 2 s at most, and its own protocol needs precise timing. About 50 µA between readings.
Differences
Feature
DS18B20
DHT22
Measures
temperature
temperature · humidity
Humidity accuracy
No humidity
±2 %RH
Temperature range
−55 to 125 °C
−40 to 80 °C
Interface
1-Wire
Single wire (own protocol)
Supply
3 to 5.5 V
3.3 to 6 V
Current between readings
0.75 µA
50 µA
ESPHome
dallas_temp
dht
Same on both: temperature accuracy · status.
Choose the DS18B20 if you need
a wider temperature range (−55 to 125 °C)
less current between readings (0.75 µA against 50 µA)
What is the difference between the DS18B20 and the DHT22?
The DS18B20 offers a wider temperature range, less current between readings, and sealed probes. The DHT22 offers humidity as well as temperature.
Which is more accurate, the DS18B20 or the DHT22?
Typical datasheet figures for temperature: ±0.5 °C for the DS18B20 and ±0.5 °C for the DHT22. Only the DHT22 measures humidity (±2 %RH). Placement matters as much as accuracy: keep either away from the board’s warm parts.
Can I replace the DS18B20 with the DHT22?
Not as a drop-in: the DS18B20 uses 1-Wire and the DHT22 a proprietary single-wire protocol, so the wiring and the code change.