DHT22 vs DS18B20 vs NTC Thermistor: Which Temperature Sensor Should You Choose?
Choosing the right temperature sensor can be overwhelming. With so many options, how do you know which one is best for your ESP32 project?
In this guide, we compare three popular temperature sensors: DHT22, DS18B20, and NTC Thermistor. You'll learn their strengths, weaknesses, and exactly which one to choose for your specific use case.
📑 Quick Navigation
📊 Quick Comparison Table
| Feature | DHT22 | DS18B20 | NTC Thermistor |
|---|---|---|---|
| Price | $5-8 | $3-6 | $1-2 |
| Temperature Range | -40 to 80°C | -55 to 125°C | -55 to 125°C |
| Accuracy | ±0.5°C | ±0.5°C | ±1-2°C |
| Humidity Measurement | ✓ Yes | ✗ No | ✗ No |
| Waterproof Available | ✗ No | ✓ Yes (probe) | ✓ Yes (optional) |
| Interface | Digital (1-Wire) | Digital (1-Wire) | Analog (ADC) |
| Multiple Sensors per Pin | ✗ No (1 per pin) | ✓ Yes (up to 100) | ✗ No (1 per pin) |
| Cable Length Capability | <5m | Up to 100m | <1m |
| Response Time | 2-5 seconds | 0.75 seconds | 0.1 seconds |
| Best For | Room + Humidity | Waterproof/Outdoor | Budget/High volume |
🌡️ DHT22 (AM2302) – The All-Rounder
Overview
The DHT22 is the most popular temperature and humidity sensor for hobbyists. It's accurate, reliable, and easy to use. Perfect for room monitoring, greenhouses, and weather stations.
✅ Pros
- Measures both temperature AND humidity
- Good accuracy (±0.5°C)
- Wide temperature range (-40 to 80°C)
- Easy to find and well-documented
- Works with 3.3V and 5V logic
- No calibration needed
❌ Cons
- Not waterproof (needs protection outdoors)
- Slow reading (max 0.5 Hz)
- Unstable with long cables (>5m)
- More expensive than alternatives
- Only 1 sensor per GPIO pin
Best Applications:
🔗 DS18B20 – The Waterproof Champion
Overview
The DS18B20 comes in a stainless steel waterproof probe perfect for liquids, soil, aquariums, and outdoor use. Multiple sensors can share the same GPIO pin!
✅ Pros
- Waterproof version available (stainless steel)
- Very wide temperature range (-55 to 125°C)
- Multiple sensors on ONE GPIO pin (up to 100!)
- Great accuracy (±0.5°C)
- Long cable lengths possible (up to 100m)
- Unique 64-bit address – plug-and-play
- Works with 3.3V or 5V
❌ Cons
- Temperature only (no humidity)
- Requires external 4.7kΩ pull-up resistor
- Slower than NTC (0.75 sec response)
- Slightly more complex wiring
Best Applications:
🔌 NTC Thermistor – The Budget King
Overview
NTC (Negative Temperature Coefficient) thermistors are simple resistors that change resistance with temperature. They're incredibly cheap but require a voltage divider circuit and calibration.
✅ Pros
- Very cheap ($0.10-0.20 each in bulk)
- Wide temperature range (-55 to 125°C)
- Fastest response time (milliseconds)
- Small form factor
- Available in waterproof probes
- Can measure up to 300°C with glass type
❌ Cons
- Non-linear output (requires math/table)
- Less accurate without calibration
- Requires external resistor (voltage divider)
- Uses ADC pins (limited on ESP8266)
- Self-heating can affect readings
Best Applications:
🎯 Head-to-Head Comparison
Accuracy Winner
Both offer ±0.5°C accuracy. NTC requires calibration to achieve similar results.
Price Winner
At $1-2, NTC is the clear winner. DS18B20 is $3-6, DHT22 is $5-8.
Waterproof Winner
The only sensor with a ready-to-use waterproof probe. NTC can be DIY waterproofed.
Multi-Sensor Winner
Connect 100+ sensors to one GPIO pin. Others need separate pins per sensor.
Response Time Winner
Milliseconds vs seconds for DHT22/DS18B20. Best for fast-changing temperatures.
Ease of Use Winner
Simple wiring, ready-to-use libraries, no extra components needed.
🎯 Decision Guide: Which One Should You Buy?
Do you need humidity measurement?
It's the only one that measures both temperature and humidity accurately.
Will the sensor be exposed to water or outdoors?
The stainless steel probe is designed for wet environments.
Do you need multiple sensors in different locations?
Connect up to 100 sensors to a single GPIO pin. Perfect for multi-zone monitoring.
Is budget your primary concern?
At $1-2, it's the cheapest option. OceanRemote includes built-in support.
Quick Recommendations by Use Case:
- 🏠 Room monitoring (temp + humidity): DHT22
- 💧 Freezer/fridge/water monitoring: DS18B20 (waterproof)
- 🌤️ Outdoor weather station: DS18B20 (waterproof)
- 💰 Very tight budget: NTC Thermistor
- 🔬 High precision scientific: Calibrated DS18B20
- 🏭 Advanced high temperature (125°C+): DS18B20 or glass NTC
- 📚 Learning/education: DHT22 (simplest)
- 🌡️ Multi-zone monitoring: DS18B20 (multiple sensors one pin)
🔧 Wiring & Code Examples
DHT22 Wiring (Simplest)
DHT22 ESP32 VCC → 3.3V DATA → GPIO 4 GND → GND (Optional: 10kΩ pull-up on DATA line)
#include <DHT.h>
#include <OceanRemote.h>
#define DHTPIN 4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
OceanRemote device(YOUR_TOKEN);
void setup() {
dht.begin();
device.begin();
}
void loop() {
float temp = dht.readTemperature();
float humidity = dht.readHumidity();
if (!isnan(temp)) device.setTemperature(temp);
if (!isnan(humidity)) device.setHumidity(humidity);
delay(10000);
}
DS18B20 Wiring (Waterproof)
DS18B20 ESP32 Red (VCC) → 3.3V or 5V Yellow (DATA) → GPIO 4 Black (GND) → GND Add 4.7kΩ resistor between VCC and DATA
#include <OneWire.h>
#include <DallasTemperature.h>
#include <OceanRemote.h>
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
OceanRemote device(YOUR_TOKEN);
void setup() {
sensors.begin();
device.begin();
}
void loop() {
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0);
if (temp != DEVICE_DISCONNECTED_C) {
device.setTemperature(temp);
}
delay(10000);
}
NTC Thermistor Wiring (Voltage Divider)
NTC ESP32 Pin 1 → GPIO 34 (ADC) Pin 2 → GND Add 10kΩ resistor between 3.3V and GPIO 34
// OceanRemote firmware includes built-in NTC support!
// Just select "NTC 10kΩ" as your sensor type.
// We handle the Steinhart-Hart equation automatically.
// Or manually calculate:
float readNTC(int analogPin, float seriesResistor = 10000) {
int raw = analogRead(analogPin);
float voltage = raw * (3.3 / 4095.0);
float resistance = seriesResistor * (3.3 - voltage) / voltage;
// Steinhart-Hart equation
float steinhart;
steinhart = log(resistance / 10000.0);
steinhart = 1.0 / (0.001129148 + (0.000234125 * steinhart) +
(0.0000000876741 * steinhart * steinhart * steinhart));
return steinhart - 273.15;
}
❓ Frequently Asked Questions
Can I use DHT22 in water?
No! DHT22 is NOT waterproof. Immersing it in water will destroy it. Use the waterproof DS18B20 for water applications.
Which sensor is most accurate?
DHT22 and DS18B20 both offer ±0.5°C accuracy out of the box. NTC requires calibration to achieve similar accuracy. For highest accuracy, consider SHT35 (±0.2°C) but it costs $15-20.
Can I use multiple temperature sensors with one ESP32?
DS18B20 is the best choice for multiple sensors – connect up to 100 sensors on a single GPIO pin. For DHT22, you need separate GPIO pins for each sensor (ESP32 has ~25 usable pins).
Which sensor works best outdoors?
DS18B20 in waterproof probe is best for outdoor use. It's fully sealed and can handle temperature extremes. DHT22 can be used outdoors if placed in a ventilated, rain-proof enclosure.
Do I need a pull-up resistor for DS18B20?
Yes! The DS18B20 requires a 4.7kΩ pull-up resistor between VCC and DATA. Without it, readings will be erratic or fail completely. Many breakout boards include this resistor.
What's the difference between DHT11 and DHT22?
DHT11 is cheaper ($3-5) but less accurate (±2°C), slower (1Hz), and narrower range (0-50°C). DHT22 is more accurate (±0.5°C), faster (0.5Hz), and wider range (-40 to 80°C). Always choose DHT22 for serious projects.
How long can my sensor wires be?
DS18B20: Up to 100 meters with proper wiring. DHT22: Less than 5 meters. NTC: Less than 1 meter without amplification.
📋 Final Summary
🌡️ DHT22
Perfect for most beginners and indoor applications where both temperature and humidity matter.
Shop DHT22 →🔗 DS18B20
The go-to choice for wet environments, outdoor use, and monitoring multiple locations.
Shop DS18B20 →🔌 NTC Thermistor
Ideal for cost-sensitive projects or when you need many sensors. OceanRemote supports it natively.
Shop NTC →Ready to Start Your Temperature Monitoring Project?
Generate ESP32/ESP8266 firmware with sensor support in minutes – no coding required!