DHT11 vs DHT22 vs DS18B20: Choosing a Temperature Sensor

DHT22 digital temperature and humidity sensor module

The DHT11, DHT22 and DS18B20 are the most common temperature sensors for Arduino and ESP32 projects. The right one depends on your temperature range, your accuracy needs and whether you also want to measure humidity.

Short answer: use a DHT11 for basic learning, a DHT22 for accurate room or greenhouse readings with humidity, and a DS18B20 for wide temperature ranges or liquids.

Sensor comparison

Feature DHT11 DHT22 DS18B20
Temperature range 0 to 50°C -40 to 80°C -55 to 125°C
Temperature accuracy ±2°C ±0.5°C ±0.5°C (from -10 to 85°C)
Humidity Yes, about 20 to 90% Yes, 0 to 100% No
Reading rate About once per second About once every 2 seconds About 0.75 seconds at full resolution
Interface Single data pin Single data pin 1-Wire

DHT11: best for learning

The DHT11 module is the budget choice for first projects, classroom demos and simple indoor displays. Its 50°C limit and ±2°C accuracy make it a poor fit for hot outdoor sites.

DHT22: best for temperature and humidity

The DHT22 module is more accurate and covers a wider range. It suits weather stations, greenhouses and incubator monitoring. Read it no faster than once every two seconds.

DS18B20: best for liquids and long ranges

The DS18B20 has the widest range and shares one data wire between several sensors, because each has a unique address. For water tanks and aquariums, choose the waterproof DS18B20 probe. It needs a 4.7 kΩ pull-up resistor between the data line and VCC unless your module already includes one.

Other options

Wiring tips

  • Bare DHT sensors need a pull-up resistor on the data line, while most modules already include one.
  • Keep sensors away from voltage regulators and other warm parts, which can raise your readings.
  • On an ESP32 or ESP8266, use 3.3 V logic and check the sensor's supply range.

Frequently asked questions

Can I replace a DHT11 with a DHT22?

Usually, yes. The wiring matches, and common Arduino libraries support both. Change the sensor type in your code and read it less often.

Which sensor is best for outdoor use in Pakistan?

A DHT11 can exceed its 50°C limit in direct summer heat. Use a DHT22 in a shaded, ventilated enclosure, or a waterproof DS18B20 if you do not need humidity.

Where can I buy these sensors in Pakistan?

Browse our sensor range or see the latest arrivals. We deliver across Pakistan.