Best Temperature Sensors for ESP32 & ESP8266 – Complete Buying Guide 2026
Choosing the right temperature sensor can make or break your IoT project. From greenhouse monitoring to freezer alerts and weather stations, each sensor has unique strengths.
This guide compares 5 popular temperature sensors for ESP32/ESP8266: DHT22, DS18B20, NTC Thermistor, BME280, and LM35. You'll learn which one is right for your project based on accuracy, cost, range, and ease of use.
📑 What You'll Learn
📊 Quick Sensor Comparison
| Sensor | Temp Range | Accuracy | Humidity | Waterproof | Price | Best For |
|---|---|---|---|---|---|---|
| DHT22 | -40 to 80°C | ±0.5°C | ✓ Yes | ❌ No | $5-8 | General purpose + humidity |
| DS18B20 | -55 to 125°C | ±0.5°C | ❌ No | ✓ Yes | $3-6 | Waterproof, long cables |
| BME280 | -40 to 85°C | ±1.0°C | ✓ Yes | ❌ No | $10-15 | Weather stations, pressure |
| NTC Thermistor | -55 to 125°C | ±1-2°C | ❌ No | ✓ Optional | $1-2 | Budget projects, high temps |
| LM35 | -55 to 150°C | ±0.5°C | ❌ No | ❌ No | $2-4 | Analog, linear output |
🌡️ DHT22 (AM2302) – Best All-Around
What it does:
The DHT22 is the most popular temperature and humidity sensor for ESP32 projects. 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
Cons:
- ❌ Not waterproof (needs protection outdoors)
- ❌ Slow reading (max 2 seconds between readings)
- ❌ Can be unstable with long cables (>5m)
- ❌ More expensive than DHT11 or NTC
Best for:
🏠 Room temperature/humidity monitoring
🌱 Greenhouses and plant monitoring
🏡 Home automation (HVAC control)
📊 Weather stations (with BME280 for pressure)
🔗 DS18B20 – Best Waterproof Sensor
What it does:
The DS18B20 comes in a waterproof stainless steel probe perfect for liquids, soil, aquariums, and outdoor use. Multiple sensors can share the same GPIO pin!
Pros:
- ✅ Waterproof version available (stainless steel probe)
- ✅ Very wide temperature range (-55 to 125°C)
- ✅ Multiple sensors on ONE GPIO pin (up to 100 sensors!)
- ✅ Great accuracy (±0.5°C)
- ✅ Long cable lengths possible (up to 100m)
- ✅ Unique 64-bit address – no calibration needed
Cons:
- ❌ Temperature only (no humidity)
- ❌ Requires external 4.7kΩ pull-up resistor
- ❌ Slower than some other sensors
Best for:
💧 Freezer/fridge temperature monitoring
🐠 Aquariums and fish tanks
🌧️ Outdoor weather monitoring
🔥 High-temperature applications (up to 125°C)
🏭 Advanced temperature logging
📊 BME280 – Best Precision + Pressure
What it does:
The BME280 measures temperature, humidity, AND barometric pressure in one tiny package. It's the go-to sensor for serious weather stations.
Pros:
- ✅ Measures 3 things: temperature + humidity + pressure
- ✅ Very small form factor
- ✅ Low power consumption (great for battery)
- ✅ I2C interface (easy wiring)
- ✅ Excellent for altitude/weather prediction
Cons:
- ❌ Most expensive option
- ❌ Not waterproof
- ❌ Slightly lower temperature accuracy than DHT22
- ❌ Limited to 85°C max
Best for:
🌤️ Professional weather stations
🏔️ Altitude measurement (drones, hiking)
📱 Portable/battery-powered projects
🔬 Laboratory/medical monitoring
🔌 NTC Thermistor – Cheapest Option
What it does:
NTC (Negative Temperature Coefficient) thermistors are simple resistors that change resistance with temperature. They're incredibly cheap but require a voltage divider circuit.
Pros:
- ✅ Very cheap ($0.10-0.20 each in bulk)
- ✅ Wide temperature range (-55 to 125°C)
- ✅ Fast response time
- ✅ Small form factor
- ✅ Available in waterproof probes
Cons:
- ❌ Non-linear output (requires math/table lookup)
- ❌ Less accurate without calibration
- ❌ Requires external resistor (voltage divider)
- ❌ Self-heating can affect readings
- ❌ No humidity measurement
Best for:
🎓 Learning projects and experiments
📦 High-volume production (cost-sensitive)
🔥 High-temperature monitoring (up to 300°C with glass thermistor)
🔧 Projects where ±2°C is acceptable
📏 LM35 – Best Linear Output
What it does:
The LM35 is a classic precision temperature sensor that outputs 10mV per degree Celsius. No calibration needed – just read the analog voltage!
Pros:
- ✅ Linear output (10mV/°C) – easy to read
- ✅ No calibration required
- ✅ Good accuracy (±0.5°C)
- ✅ Wide range (-55 to 150°C)
- ✅ Low power consumption
Cons:
- ❌ Temperature only (no humidity)
- ❌ Analog output (uses ADC pins)
- ❌ Not waterproof
- ❌ Can be affected by noise on long wires
Best for:
🔧 Simple projects needing just temperature
📚 Educational/learning projects
🏭 Advanced monitoring (up to 150°C)
🎯 Which Sensor Should You Choose?
Do you need humidity?
Quick Recommendations by Use Case:
- 🏠 Room monitoring (temp + humidity): DHT22
- 💧 Freezer/fridge/water monitoring: DS18B20 (waterproof)
- 🌤️ Outdoor weather station: BME280 (pressure + temp + humidity)
- 💰 Very tight budget: NTC Thermistor
- 🔬 High precision scientific: BME280 or calibrated DS18B20
- 🏭 Advanced high temperature: DS18B20 or NTC (glass)
- 📚 Learning/education: LM35 (simplest analog output)
🔧 Wiring & Code Examples
DHT22 Wiring (Simplest)
DHT22 ESP32 VCC → 3.3V DATA → GPIO 4 GND → GND (Optional: 10kΩ pull-up on DATA line)
DHT22 Code (OceanRemote)
#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); // Update every 10 seconds
}
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
DS18B20 Code (Multiple Sensors)
#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
NTC Code (OceanRemote Built-in)
// OceanRemote firmware generator includes NTC support! // Just select "NTC 10kΩ" as your sensor type in the wizard. // We handle the Steinhart-Hart equation automatically.
📈 Accuracy & Response Time Comparison
| Sensor | Typical Accuracy | Response Time | Update Rate | Calibration Needed |
|---|---|---|---|---|
| DHT22 | ±0.5°C | 2-5 sec | 0.5 Hz | No |
| DS18B20 | ±0.5°C | 0.75 sec | 1 Hz | No (unique address) |
| BME280 | ±1.0°C | 0.1 sec | 10 Hz | No |
| NTC | ±1-2°C | 0.5-2 sec | 100 Hz+ | Yes (Steinhart-Hart) |
| LM35 | ±0.5°C | 0.1 sec | 100 Hz+ | No |
🛒 Where to Buy Temperature Sensors
❓ Frequently Asked Questions
Which temperature sensor is most accurate?
For general use, DS18B20 and DHT22 both offer ±0.5°C accuracy. For scientific applications, calibrated DS18B20 or BME280 are excellent. The most accurate consumer sensor is the SHT35 (±0.2°C) but it costs $15-20.
Can I use multiple temperature sensors with one ESP32?
Yes! DS18B20 is the best choice for multiple sensors – you can connect up to 100 sensors on a single GPIO pin. For DHT22 or BME280, you need separate GPIO pins for each sensor (ESP32 has ~25 usable pins).
Which sensor works best outdoors?
DS18B20 in waterproof probe is the best choice for outdoor use. It's fully sealed and can handle temperature extremes. The BME280 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.
Can I measure water temperature with DHT22?
No! The DHT22 is NOT waterproof and will be destroyed in water. Use the waterproof DS18B20 for aquariums, pools, or any liquid measurement.
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. BME280 (I2C): Less than 1 meter. NTC/LM35: Less than 1 meter without amplification.
Ready to Start Monitoring Temperature?
Generate ESP32/ESP8266 firmware with sensor support in minutes – no coding required!