Choosing the right humidity and temperature sensor can make or break your weather station, greenhouse controller, HVAC system, or IoT product. Three sensors dominate maker conversations: the DHT22 (the old reliable), the BME280 (the versatile upgrade), and the SHT31 (the precision champion). Each has distinct strengths, weaknesses, and ideal use cases. In this in-depth comparison, we analyse accuracy specs, communication protocols, power consumption, cost, library support, and real-world performance to help you pick the right sensor for your specific project.
Sensor Overview
DHT22 (AM2302)
The DHT22 has been the workhorse humidity sensor for Arduino makers since around 2010. It uses a proprietary single-wire protocol (not Dallas 1-Wire) to communicate temperature and humidity readings. The sensor contains a capacitive humidity element and a thermistor, with a microcontroller inside the module that handles the analog-to-digital conversion. The DHT22 is cheap, well-documented, and has excellent library support across every platform. However, its single-wire protocol has timing issues, its minimum sampling interval is 2 seconds, and its accuracy is moderate by modern standards.
BME280
Launched by Bosch Sensortec around 2015, the BME280 integrates a barometric pressure sensor, humidity sensor, and temperature sensor in a 2.5 × 2.5 mm package. It communicates over I2C or SPI, supports flexible oversampling and filtering, and offers much faster sampling than the DHT22. The BME280’s humidity accuracy (±3% RH) is comparable to the DHT22 but its superior I2C interface, programmability, and pressure measurement make it the go-to upgrade for IoT projects.
SHT31
The SHT31 from Sensirion is a premium humidity and temperature sensor aimed at applications where accuracy, repeatability, and long-term stability are non-negotiable. It uses a fully calibrated, temperature-compensated CMOSens® sensor element with a digital I2C interface. The SHT31 offers ±2% RH accuracy, ±0.3°C temperature accuracy, and excellent long-term stability — making it the preferred choice for reference instruments, laboratory equipment, clean rooms, and any application where sensor accuracy directly impacts product quality or safety.
DHT11 Digital Relative Humidity and Temperature Sensor Module
Just starting out? The DHT11 is the entry-level humidity sensor — simpler and cheaper than DHT22, perfect for beginner projects and learning the basics of environmental sensing.
Full Specifications Comparison
| Parameter | DHT22 | BME280 | SHT31 |
|---|---|---|---|
| Humidity Range | 0–100% RH | 0–100% RH | 0–100% RH |
| Humidity Accuracy | ±2–5% RH | ±3% RH | ±2% RH |
| Humidity Resolution | 0.1% RH | 0.008% RH | 0.01% RH |
| Temp Range | -40°C to +80°C | -40°C to +85°C | -40°C to +125°C |
| Temp Accuracy | ±0.5°C | ±1.0°C | ±0.3°C |
| Pressure Measurement | No | Yes (±1 hPa) | No |
| Interface | Single-wire proprietary | I2C / SPI | I2C |
| Min Sampling Interval | 2 seconds | ~1 ms (forced mode) | ~15 ms (high repeatability) |
| Supply Voltage | 3.3V – 6V | 1.71V – 3.6V | 2.4V – 5.5V |
| Current (measuring) | 1.5 mA | 0.714 mA | ~1.0 mA |
| Sleep Current | ~40 µA | ~0.1 µA | ~0.5 µA |
| Long-term Stability | ±0.5% RH/year | Not specified | <0.5% RH/year |
| Relative Cost (India) | Low (₹80–150) | Medium (₹150–300) | High (₹400–800) |
Accuracy Deep Dive
DHT22 Accuracy Reality Check
The DHT22 datasheet specifies ±2% RH accuracy in the 0–80% range, but this is the best-case specification at room temperature. In practice, most units from inexpensive suppliers show ±3–5% RH variation. Temperature affects humidity readings significantly because humidity sensing capacitors are temperature-sensitive, and the DHT22’s temperature compensation is limited. At high humidity (>80% RH) and high temperatures (>40°C), DHT22 readings can drift by 5–10% compared to a calibrated reference.
Additionally, the DHT22 requires 2 seconds between readings. Rapid data acquisition is impossible, and consecutive readings within 2 seconds return stale data. The single-wire protocol has timing-sensitive bit decoding that fails under certain conditions (interrupt-heavy firmware, noisy power supply, long cable lengths). Most DHT22 Arduino libraries handle this gracefully with error returns, but it means you occasionally get NaN readings that require retry logic.
BME280 Accuracy Analysis
The BME280 humidity accuracy of ±3% RH (20–80% RH) is formally worse than the DHT22’s spec — but the BME280’s I2C interface is far more reliable, its 0.008% RH resolution allows detecting tiny humidity changes, and its programmable oversampling and IIR filtering produce consistently smooth readings. The BME280 also benefits from Bosch’s quality manufacturing standards and factory calibration of all three measurement types simultaneously.
The BME280’s temperature accuracy spec of ±1°C is its weakest point. Self-heating from the chip running in normal mode causes the temperature sensor to read 1–3°C higher than actual ambient temperature. This also indirectly affects humidity readings. The fix: use forced mode (trigger a measurement, read, then sleep), mount the BME280 away from heat sources, and add ventilation. In forced mode at low duty cycle, self-heating is essentially eliminated.
SHT31 Accuracy Excellence
The SHT31 is a class above the others in accuracy. Its ±2% RH humidity accuracy specification covers the full 10–90% range (not just the comfortable middle range) and holds across its operating temperature range. Temperature accuracy of ±0.3°C (0–90°C) is exceptional — even thermocouple-based instruments struggle to beat this. Sensirion’s CMOSens® technology integrates the sensor element and processing on a single chip, eliminating the accuracy-robbing variability of discrete component matching.
The SHT31 also features a heater element that can be activated programmatically to dry out the sensor after condensation events — a feature unavailable on DHT22 or BME280. This extends sensor lifetime in high-humidity environments like greenhouses and bathrooms where condensation cycling would permanently degrade cheaper sensors.
Communication Protocols
DHT22: Single-Wire Protocol
The DHT22 uses a custom single-wire protocol that is timing-dependent. The MCU pulls the line low for 1–10 ms to initiate a reading, then the sensor responds with 40 bits of data (16-bit humidity + 16-bit temperature + 8-bit checksum) encoded as pulse widths. A 26–28 µs high pulse = ‘0’, a 70 µs high pulse = ‘1’. On fast MCUs (ESP32, STM32), you may need interrupt-based decoding. Key limitations:
- Maximum cable length ~20 cm without signal degradation (add 100 nF capacitor between VCC and GND near sensor for longer runs)
- Cannot read while another interrupt is firing
- Minimum 2-second reading interval (sensor explicitly specifies this)
- No multi-sensor capability without separate data lines for each sensor
BME280 and SHT31: I2C
Both the BME280 and SHT31 use standard I2C, which offers significant advantages:
- Multiple sensors on the same two-wire bus (SDA + SCL)
- Cable lengths up to 1 meter at standard speed (400 kHz), up to 4 meters at 100 kHz with appropriate pull-ups
- Error detection built into the protocol (ACK/NACK)
- Reading can be triggered at any time without timing-sensitive bit-banging
- Bus can be shared with other I2C devices (RTC, OLED, magnetometer, etc.)
The BME280 also supports SPI for environments where I2C is not available or where faster communication is needed (useful in high-speed data logging applications).
DHT20 SIP Packaged Temperature and Humidity Sensor
The DHT20 upgrades the DHT series with an I2C interface, eliminating the timing issues of the DHT22 while keeping compatibility with existing DHT libraries — the ideal intermediate step.
Sampling Rate and Response Time
Sampling rate determines how quickly the sensor reacts to environmental changes — critical for fast-changing conditions like a door opening or HVAC vent switching.
- DHT22: Minimum 2-second interval. Thermal response time ~10 seconds (physical sensor element lag). Effectively a “slow” sensor suitable only for slow environmental changes.
- BME280: In forced mode, a measurement completes in ~2 ms (at 1x oversampling). In normal mode, configurable from 0.5 ms to several seconds per cycle. Very fast for applications that need real-time trending.
- SHT31: Low repeatability mode: 4 ms. Medium repeatability: 6 ms. High repeatability: 15 ms. Far faster than DHT22 and more than adequate for most applications.
For a greenhouse controller that only needs temperature/humidity updates every 30 seconds, all three sensors are equally suitable from a sampling rate perspective. For a wind tunnel humidity mapping experiment or an HVAC system that must react within seconds to humidity changes, the BME280 or SHT31 are required — the DHT22 simply cannot keep up.
Power Consumption
Battery-powered projects make power consumption critical. Here is the practical breakdown:
| Scenario | DHT22 | BME280 | SHT31 |
|---|---|---|---|
| Average current (1 reading/min) | ~78 µA | ~0.15 µA | ~0.6 µA |
| Battery life on 1000 mAh cell | ~18 months | ~760 years | ~190 years |
| Sleep mode current | ~40 µA | ~0.1 µA | ~0.5 µA |
Note: the above battery life estimates assume the sensor is the only power draw. In a real system with an MCU, radio module, and display, the MCU typically dominates power consumption and the sensor choice is less critical. However, the DHT22’s significantly higher sleep current (40 µA vs 0.1–0.5 µA) can matter in ultra-low-power designs where the MCU itself sleeps at just a few µA.
Wiring Guide for Each Sensor
DHT22 Wiring
Connect VCC to 3.3V–5V, GND to GND, and DATA to any digital GPIO. Add a 10kΩ pull-up resistor between DATA and VCC. Without the pull-up, the single-wire protocol will fail intermittently.
BME280 Wiring (I2C)
VCC to 3.3V (critical — 5V will damage the chip if your board lacks a voltage regulator). GND to GND. SDA to Arduino A4. SCL to Arduino A5. SDO pin to GND (I2C address 0x76) or 3.3V (address 0x77). Most breakout boards include a 4.7kΩ pull-up on SDA/SCL onboard.
SHT31 Wiring
VCC to 2.4–5.5V (directly 5V compatible unlike BME280). GND to GND. SDA to A4. SCL to A5. ADDR pin to GND (address 0x44) or VCC (address 0x45). Alert pin optional — connect to a digital input with 10kΩ pull-up for threshold alerts.
Arduino Code Examples
DHT22 Code
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() { Serial.begin(115200); dht.begin(); }
void loop() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) { Serial.println("DHT22 read failed!"); return; }
Serial.print("Humidity: "); Serial.print(h); Serial.print("% | Temp: "); Serial.print(t); Serial.println("°C");
}
BME280 Code
#include <Wire.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme;
void setup() {
Serial.begin(115200);
if (!bme.begin(0x76)) { Serial.println("BME280 not found!"); while(1); }
bme.setSampling(Adafruit_BME280::MODE_FORCED,
Adafruit_BME280::SAMPLING_X1, Adafruit_BME280::SAMPLING_X16,
Adafruit_BME280::SAMPLING_X1, Adafruit_BME280::FILTER_X16);
}
void loop() {
bme.takeForcedMeasurement();
Serial.print("Humidity: "); Serial.print(bme.readHumidity());
Serial.print("% | Temp: "); Serial.print(bme.readTemperature());
Serial.print("°C | Pressure: "); Serial.print(bme.readPressure()/100.0); Serial.println(" hPa");
delay(5000);
}
SHT31 Code
#include <Wire.h>
#include <Adafruit_SHT31.h>
Adafruit_SHT31 sht31 = Adafruit_SHT31();
void setup() {
Serial.begin(115200);
if (!sht31.begin(0x44)) { Serial.println("SHT31 not found!"); while(1); }
}
void loop() {
float t = sht31.readTemperature();
float h = sht31.readHumidity();
if (!isnan(t) && !isnan(h)) {
Serial.print("Temp: "); Serial.print(t); Serial.print("°C | Humidity: "); Serial.print(h); Serial.println("%");
}
delay(1000);
}
DHT11 Temperature And Humidity Sensor Module with LED
The DHT11 module with onboard LED indicator — an excellent visual-feedback sensor for classroom demos and beginner projects where exact accuracy is less critical than simplicity.
Library Support and Ecosystem
DHT22: The DHT library by Adafruit is the gold standard, available in every Arduino Library Manager. Works on AVR, ESP8266, ESP32, STM32, and more. The DHT_nonblocking library provides non-blocking reading for use with RTOS or other timing-sensitive code.
BME280: Adafruit BME280 Library and BME280 by tylerpotts are both excellent. Bosch’s own BSEC library (for the BME680/BME688 successor) provides more advanced features. PlatformIO and MicroPython (via the bme280 module) fully support it. CircuitPython has a dedicated Adafruit_CircuitPython_BME280 library.
SHT31: Adafruit SHT31 Library is the primary Arduino library. Sensirion provides official Python and C libraries for Raspberry Pi and embedded Linux. CircuitPython support via Adafruit_CircuitPython_SHT31D. Less breadth than DHT22 but all major platforms are covered.
Use Case Recommendations
| Use Case | Best Choice | Why |
|---|---|---|
| Beginner / learning | DHT22 | Simple wiring, excellent tutorials, cheap |
| Weather station (home) | BME280 | Adds pressure, altitude; better sampling rate |
| Greenhouse / agriculture | SHT31 | Best accuracy, heater for condensation recovery |
| IoT sensor node (battery) | BME280 | Ultra-low sleep current (0.1 µA) |
| HVAC / building automation | SHT31 | Long-term stability, industrial accuracy |
| Lab / calibration reference | SHT31 | Highest accuracy (±2% RH, ±0.3°C) |
| Drone / altitude tracking | BME280 | Pressure sensor adds barometric altitude |
| School project / science fair | DHT22 | Budget-friendly, massive community support |
Cost vs. Performance Analysis
In the Indian electronics market as of 2025–2026, approximate module prices are:
- DHT11 module: ₹40–80 (significantly less accurate than DHT22)
- DHT22 module: ₹80–150
- BME280 module (3.3V): ₹150–250
- BME280 module (5V): ₹200–350
- SHT31 module: ₹400–800
For a home weather station, the BME280 offers the best value — it adds barometric pressure and altitude to temperature and humidity at roughly twice the price of a DHT22, which is excellent value for the additional capability. The SHT31’s premium is justified only when accuracy is the primary requirement; for casual monitoring, the BME280’s ±3% RH accuracy is perfectly adequate.
If you are building a commercial product in volume (1000+ units), the SHT31’s consistent factory calibration reduces per-unit calibration costs that DHT22-based designs typically require. The SHT31 pays for itself in production efficiency at scale.
GY-BME280-3.3 Precision Altimeter Atmospheric Pressure Sensor Module
Get temperature, humidity, and barometric pressure in one compact 3.3V module — the BME280 is the perfect all-rounder upgrade for any project that has outgrown the DHT22.
Frequently Asked Questions
A: Yes. BME280 and SHT31 can share the same I2C bus (SDA/SCL). DHT22 needs its own separate digital pin for the single-wire protocol. You can run all three concurrently — they operate on independent buses and there is no interference. Just ensure your power supply can handle the combined current draw.
A: The BME280 self-heats when running in continuous (normal) mode. Switch to forced mode — trigger a measurement, read the result, then the sensor sleeps automatically. This eliminates self-heating and makes the temperature reading match the actual ambient temperature. The DHT22’s separate thermistor element is less affected by chip self-heating.
A: The BME280 chip is 3.3V only. However, several breakout modules (like the GY-BME280-5V sold by Zbotic) include an onboard 3.3V voltage regulator and logic level conversion, making them safe to power from 5V Arduino boards. Always check your specific module’s specs before connecting to 5V.
A: The SHT31 requires no field recalibration for typical applications — Sensirion rates it stable to <0.5% RH drift per year. DHT22 units from budget suppliers may drift significantly after 1–2 years in harsh conditions and benefit from annual calibration against a known humidity reference (saturated salt solution is a low-cost reference). BME280 typically stays within spec for 2–3 years in normal conditions.
A: No. All three sensors — DHT22, BME280, and SHT31 — are designed for clean air environments. Chemical contamination (solvents, acids, bases, corrosive gases) will permanently damage the capacitive humidity sensing element. For harsh chemical environments, use sensors with sintered filter protection or dedicated industrial-grade sensors with chemical resistance ratings.
Find Your Perfect Humidity Sensor at Zbotic
Whether you need a DHT11 for your first project or a high-accuracy BME280 for a professional weather station, Zbotic has the sensors you need — with fast delivery across India and expert support.
Add comment