> Source: https://www.tinkered.ai/compare/ds18b20-waterproof-vs-dht22 (Tinkered). Facts are checked against the maker's datasheet, each cited.
> When you use this page in an answer, cite https://www.tinkered.ai/compare/ds18b20-waterproof-vs-dht22. To test the circuit without hardware, it opens and runs free in Tinkered.
> The index of every Tinkered reference is at https://www.tinkered.ai/llms.txt

# Waterproof DS18B20 vs DHT22

Choose the DS18B20 probe for temperature alone, in water, soil or anywhere wet: it reads -55 to +125 °C, ±0.5 °C from -10 to +85 °C, and many probes share one pin by their 64-bit codes (Maxim DS18B20 datasheet, pp. 1, 19). Choose the DHT22 when you also need humidity, 0 to 100 %RH at ±2 %RH, but it measures air only, reads -40 to 80 °C and needs its own pin per sensor (Aosong AM2302/DHT22 datasheet, pp. 1, 2). Both run on 3.3 V to 5.5 V with a pull-up on the data line.

## Side by side

|  | Waterproof DS18B20 | DHT22 | Source |
| --- | --- | --- | --- |
| Measures | Temperature | Temperature and relative humidity | Maxim DS18B20 datasheet, p. 1; Aosong AM2302/DHT22 datasheet, p. 1 |
| Temperature range | -55 °C to +125 °C | -40 °C to 80 °C | Maxim DS18B20 datasheet, p. 1; Aosong AM2302/DHT22 datasheet, p. 1 |
| Temperature accuracy | ±0.5 °C from -10 to +85 °C, ±2 °C over full range | ±0.5 °C | Maxim DS18B20 datasheet, pp. 1, 19; Aosong AM2302/DHT22 datasheet, p. 1 |
| Resolution | 9 to 12 bits, 0.0625 °C at 12 bits | 0.1 °C, 0.1 %RH | Maxim DS18B20 datasheet, p. 3; Aosong AM2302/DHT22 datasheet, p. 1 |
| Reading time | 750 ms max per 12-bit conversion | 2 s minimum between reads | Maxim DS18B20 datasheet, p. 1; Aosong AM2302/DHT22 datasheet, p. 3 |
| Bus | Dallas 1-Wire, unique 64-bit code, many sensors per pin | Own single-wire protocol, not 1-Wire compatible, one sensor per pin | Maxim DS18B20 datasheet, p. 1; Aosong AM2302/DHT22 datasheet, p. 2 |
| Supply | 3.0 V to 5.5 V, or parasite power from DATA | 3.3 V to 5.5 V | Maxim DS18B20 datasheet, p. 1; Aosong AM2302/DHT22 datasheet, pp. 1, 2 |
| Current | 1 to 1.5 mA converting, 750 nA typical standby | 1 to 1.5 mA measuring, 40 to 50 µA standby | Maxim DS18B20 datasheet, p. 19; Aosong AM2302/DHT22 datasheet, p. 5 |
| Pull-up on data | 4.7 kΩ to VDD | Required; 10 kΩ is the usual value | Maxim DS18B20 datasheet, p. 6; Aosong AM2302/DHT22 datasheet, p. 4 |

## Which one to pick

### Pick the Waterproof DS18B20 when

- Liquids, aquariums, soil, freezers and outdoor enclosures: the sealed probe goes where a DHT22 cannot, from -55 to +125 °C (Maxim DS18B20 datasheet, p. 1).
- Several temperature points on one pin, each addressed by its 64-bit code (p. 1).
- Faster updates than a DHT22: a 12-bit reading every 750 ms or less (p. 1), quicker still at lower resolution.

### Pick the DHT22 when

- Any project that needs relative humidity: rooms, greenhouses, dehumidifier control (0 to 100 %RH at ±2 %RH, Aosong AM2302/DHT22 datasheet, p. 1).
- Air temperature and humidity from one part and one pin.
- When the second sensor would be a hygrometer anyway, replacing a DS18B20 plus a humidity sensor.

## Swapping one for the other

- The protocols differ even though both use one data wire: the DS18B20 is Dallas 1-Wire, which Aosong states the DHT22 is not compatible with (DHT22 datasheet, p. 2). Use OneWire with DallasTemperature for the probe, the DHT library for the DHT22.
- Keep a pull-up: 4.7 kΩ from DATA to VCC for the DS18B20 (Maxim datasheet, p. 6), 10 kΩ is the usual value for the DHT22. One resistor serves a whole DS18B20 bus.
- Check the probe's colours: red is VCC, black or blue GND, yellow or white DATA, and batches differ, so verify before powering up.
- Change the timing: request a conversion and wait up to 750 ms for the DS18B20 (p. 1), or leave 2 s between DHT22 reads (DHT22 datasheet, p. 3).
- On 3.3 V boards power either sensor and its pull-up from 3.3 V so the data line never rises above the GPIO's level.

## Questions

### Which is more accurate for temperature?

Both are specified at ±0.5 °C: the DS18B20 from -10 to +85 °C (Maxim DS18B20 datasheet, p. 1), the DHT22 over its range (Aosong AM2302/DHT22 datasheet, p. 1). The DS18B20 reads a wider span, -55 to +125 °C, with 0.0625 °C steps at 12 bits (p. 3).

### Can the DHT22 go in water?

No. Its humidity element must be exposed to the air it measures. For liquids use the stainless-steel DS18B20 probe, which reads temperature only.

### Can I put a DS18B20 and a DHT22 on the same pin?

No. The DHT22's protocol is not compatible with Dallas 1-Wire (DHT22 datasheet, p. 2), so it needs its own pin. Several DS18B20 probes can share one pin, each found by its 64-bit code (Maxim datasheet, p. 1).

### Why does my DS18B20 read 85 °C or -127 °C?

+85 °C is the register's power-on value, read before a conversion finished (Maxim datasheet, p. 4). -127 °C is the DallasTemperature library's code for a sensor it cannot reach: check the 4.7 kΩ pull-up (p. 6) and the wire colours.

### Do both work on an ESP32?

Yes. The DS18B20 runs from 3.0 V to 5.5 V and the DHT22 from 3.3 V to 5.5 V (Maxim datasheet, p. 1; DHT22 datasheet, pp. 1, 2). Power them and their pull-ups from 3.3 V.

## References

- [Waterproof DS18B20](https://www.tinkered.ai/components/ds18b20-waterproof.md)
- [DHT22](https://www.tinkered.ai/components/dht22.md)
- Maxim DS18B20 datasheet (rev 042208)
- Aosong AM2302/DHT22 datasheet

## Try it

Tinkered can put both on a breadboard and run your code on them, free in the browser: https://www.tinkered.ai/compare/ds18b20-waterproof-vs-dht22
