Looking for a temperature or humidity sensor for your electronics projects? There is a wide variety of temperature and humidity sensors compatible with ESP32, RPi Pico, Arduino (and other microcontroller boards). In this article, we’ll compare some of the most popular sensors and see which ones are better options for different use cases.

We’ll compare the sensors when it comes to accuracy, resolution, communication protocol, temperature range, ease of use, library support, and more.
In our tutorials, we’ve been using mostly BME20, SHT41, DHT22, and DS18B20 because these are cheap, easy to use, and great for teaching and explaining IoT, microcontrollers, and programming concepts. However, for some projects, those might not be the best choice. That’s why we’ve put together this comparison guide with many temperature sensor options that you can use in your projects.
Temperature (and Humidity) Sensor Options
In this article, we cover Sensirion SHT, Bosch BME/BMP, Texas Instruments TMP, DHT sensors, and Aosong AHT series. We also include environmental sensors, digital and analog temperature sensors, thermocouples, and more. See the complete list below:

Aosong sensors
- AHT series (temperature and humidity): AHT20, AHT10, AHT21
- DHT series (temperature and humidity): DHT11, DHT22 (AM2302), AM2320
Sensirion I2C sensors
- SHT series (temperature and humidity): SHT30, SHT31, SHT35, SHT40, SHT41, and SHT45
- SCD series (CO2 sensor with temperature and humidity): SCD40, SCD41
Bosch sensors
- BME280 Temperature, Humidity, and Pressure
- BME680 Temperature, Humidity, Pressure, and Gas
- BME688 Temperature, Humidity, Pressure, and Gas
- BMP280 Temperature and Pressure
- BMP388 Temperature and Pressure
Texas Instruments sensors
- TMP117 Temperature
- TPM102 Temperature
- HDC1080 Temperature and Humidity
TE Connectivity (Measurement Specialties)
- HTU21D Temperature and Humidity
Silicon Labs
- Si7021 Temperature and Humidity
Analog Devices / Maxim Integrated
- DS18B20
- LM35
- TMP36
- MAX6675 + K-type thermocouple
- MAX31855 + K-type thermocouple
- MAX31856 + K-type thermocouple
- MAX31865 + PT100 / PT1000
Microchip Technology
- MCP9808 Temperature
Melexis
- MLX90614 non-contact infrared temperature sensor
Temperature/Humidity Sensors Comparison: Key Specifications
For a quick comparison of the sensors, we’ve put together the following table that shows the most important information when it comes to selecting a temperature sensor: communication protocol, supply voltage, temperature range, accuracy, typical price, and more.
Note: the table scrolls horizontally.
| Sensor | Measures | Temp accuracy | Temp range | RH accuracy | RH range | Resolution (T / RH) | Interface | Supply | Measurement time | Price | Datasheet |
|---|---|---|---|---|---|---|---|---|---|---|---|
| DHT11 | T + RH | ±2°C | 0–50°C | ±5% | 20–80% | 1°C / 1% | Proprietary single-wire | 3–5.5V | ≤1 Hz | $1–3 | Datasheet |
| DHT22 / AM2302 | T + RH | ±0.5°C | -40–80°C | ±2% | 0–100% | 0.1°C / 0.1% | Proprietary single-wire | 3.3–6V | ≥2 s | $3–10 | Datasheet |
| AM2320 | T + RH | ±0.5°C | -40–80°C | ±3% | 0–99.9% | 0.1°C / 0.1% | I2C or single-wire | 3.1–5.5V | ≥2 s | $3–8 | Datasheet |
| AHT20 (also AHT10/AHT21) | T + RH | ±0.3°C | -40–85°C | ±2% (20–80%) | 0–100% | ~0.01°C / ~0.024% | I2C | 2.0–5.5 V | ~80 ms | $1–5 | Datasheet |
| HTU21D / GY-21 | T + RH | ±0.3°C | -40–125°C | ±2% (20–80%) | 0–100% | 0.01°C / 0.04% | I2C | 1.5–3.6V (modules often 3–5V) | ~15–50 ms | $2–15 | Datasheet |
| Si7021 | T + RH | ±0.4°C | -10–85°C | ±3% | 0–80% | 0.01°C / 0.04% | I2C | 1.9–3.6V | ~10–25 ms | $3–9 | Datasheet |
| HDC1080 | T + RH | ±0.2°C | -40–125°C | ±2% | 0–100% | 14-bit / 14-bit | I2C | 2.7–5.5V | ~6.5 ms each | $4–10 | Datasheet |
| SHT30 | T + RH | ±0.3°C | -40–125°C | ±3% | 0–100% | 16-bit (~0.01°C/ 0.01%) | I2C | 2.15–5.5V | ~4–15 ms, up to 10 Hz | $2–6 | Datasheet |
| SHT31 | T + RH | ±0.2 °C | -40–125 °C | ±2 % | 0–100 % | 16-bit | I2C | 2.15–5.5V | ~4–15 ms, up to 10 Hz | $3–15 | Datasheet |
| SHT35 | T + RH | ±0.1 °C | -40–125 °C | ±1.5 % | 0–100 % | 16-bit | I2C | 2.15–5.5V | ~4–15 ms, up to 10 Hz | $10–25 | Datasheet |
| SHT40 / SHT41 | T + RH | ±0.2 °C | -40–125 °C | ±1.8 % | 0–100 % | 16-bit | I2C | 1.08–3.6V chip (modules 3–5V) | ~1–9 ms | $5–10 | Datasheet |
| SHT45 | T + RH | ±0.1°C | -40–125°C | ±1.0% | 0–100% | 16-bit | I2C | 1.08–3.6V chip (modules 3–5V) | ~1–9 ms | $10–16 | Datasheet |
| BME280 | T + RH + pressure | ±0.5°C | -40–85°C | ±3% | 0–100% | 0.01°C / 0.008% (pressure 0.16Pa) | I2C or SPI | 1.71–3.6V chip (modules 3.3V or 3–5V) | ~10 ms forced mode | $2–20 | Datasheet |
| BME680 / BME688 | T + RH + pressure + gas (VOC) | ±1 °C | -40–85 °C | ±3 % | 0–100 % | 0.01°C / 0.008% (pressure 0.18hPa) | I2C or SPI | 1.71–3.6V | ~150 ms with gas | $10–25 | Datasheet (BME680) |
| SCD40 / SCD41 | CO2 + T + RH | ±0.8°C | -10–60°C | ±6% | 0–95% | 0.01°C / 0.01% (CO2 1 ppm) | I2C | 2.4–5.5V | 5 s periodic, or single-shot | $18–35 | Datasheet |
| DS18B20 (bare or waterproof probe) | T | ±0.5°C (-10–85°C) | -55–125°C | none | none | 9–12-bit | Dallas 1-Wire | 3–5.5V | ~94–750 ms (750 ms at 12-bit) | $1–3 bare, $2–8 probe | Datasheet |
| BMP280 | T + pressure | ±1°C (0–65°C) | -40–85°C | none | none | 0.01°C (pressure 0.18 hPa) | I2C or SPI | 1.71–3.6V chip (modules 3.3V or 3–5V) | ~5–40 ms | $1–5 | Datasheet |
| TMP117 | T | ±0.1°C (-20–50 °C) | -55–150°C | none | none | 0.0078°C (16-bit) | I2C | 1.7–5.5V | ~15.5 ms | $8–16 | Datasheet |
| MCP9808 | T | ±0.25°C | -40–125°C | none | none | 0.5–0.0625°C (configurable) | I2C | 2.7–5.5V | ~30–250 ms | $4–8 | Product page |
| TMP102 | T | ±0.5°C (0–65°C) | -40–125°C | none | none | 0.0625°C | I2C | 1.4–3.6V | ~26 ms | $3–8 | Datasheet |
| LM35 | T | ±0.5°C at 25°C (±1 °C full range); | -55–150°C | none | none | ADC-limited (10 mV/°C) | Analog | 4–30V | Continuous | $1–3 | Datasheet |
| TMP36 | T | ±1°C at 25°C (±2°C full range); | -40–125°C | none | none | ADC-limited (10 mV/°C, 500 mV offset) | Analog | 2.7–5.5V | Continuous | $1–3 | Datasheet |
| MAX6675 + K-type | T | ~±2–3°C (probe-limited) | 0–1024 °C | none | none | 0.25°C | SPI | 3.0–5.5V | ~0.2 s | $2–6 board + $3–12 probe | Datasheet |
| MAX31855 / MAX31856 + K-type | T | ±2°C (probe-limited) | -200–1350°C | none | none | 0.25°C (31855) / 0.0078°C (31856) | SPI | 3.3V | ~70–100 ms | $4–20 board + $3–12 probe | MAX31855, MAX31856 |
| PT100 / PT1000 + MAX31865 | T | Class A: ±(0.15 + 0.002·t)°C | -200–850°C | none | none | 15-bit (~0.03°C) | SPI | 3.3V (some boards 3–5V) | ~52–63 ms | $8–25 board + $5–30 probe | Datasheet |
| MLX90614 (non-contact IR) | T (object and ambient) | ±0.5°C near room temp | Object -70–380°C, ambient -40–125°C | none | none | 0.02°C | I2C / SMBus | 3.3V or 5V | ~0.5–1 s | $8–25 | Datasheet |
Temperature and Humidity Sensors Library support
Another important point to take into account when choosing your temperature sensor is library support. You want a sensor with good library support. It will make it easier to write code for your project and debug.
For each sensor. the following table shows the library names for Arduino/PlatformIO, MicroPython, and CircuitPython.
| Sensor | Arduino / PlatformIO | MicroPython | CircuitPython |
|---|---|---|---|
| DHT11 / DHT22 | Adafruit DHT, DHTesp, DHTNEW, SimpleDHT (ESP32 Arduino Guide) | dht (built-in) (ESP32 MicroPython Guide) | adafruit_dht |
| DS18B20 | OneWire + DallasTemperature (ESP32 Arduino Guide) | onewire+ ds18x20 (built-in) (ESP32 MicroPython Guide) | adafruit_ds18x20 |
| BME280 | Adafruit_BME280, SparkFun, Bosch driver (ESP32 Arduino Guide) | BME280 (robert-hh, or adafruit_bme280) (ESP32 MicroPython Guide) | adafruit_bme280 |
| SHT30 / SHT31 / SHT35 | Adafruit_SHT31, Sensirion official, RobTillaart SHT31 | micropython-sht31 (kfricke), micropython-sht30 (rsc1975) | adafruit_sht31d |
| LM35 / TMP36 / NTC (analog) | analogRead (no library); Steinhart–Hart for NTC | machine.ADC (built-in) | analogio, adafruit_thermistor (NTC) |
| BMP280 | Adafruit_BMP280, SparkFun | micropython-bmp280 (dafvid) | adafruit_bmp280 |
| AHT20 (and AHT10/AHT21) | Adafruit_AHTX0, dvarrel AHT20, SparkFun | micropython_ahtx0 (targetblank) | adafruit_ahtx0 |
| BME680 / BME688 | Adafruit_BME680, Bosch BME68x, Bosch BSEC2 (IAQ) (ESP32 Arduino) | BME680-Micropython (robert-hh) (ESP32 MicroPython) | adafruit_bme680 |
| SHT40 / SHT41 / SHT45 | Adafruit_SHT4x, Sensirion official (ESP32 Arduino) | micropython-sht4x (jposada202020) | adafruit_sht4x |
| MLX90614 | Adafruit_MLX90614, SparkFun | micropython-mlx90614 (mcauser) | adafruit_mlx90614 |
| HTU21D | Adafruit_HTU21DF, SparkFun HTU21D | micropython-htu21df (jposada202020, archived) | adafruit_htu21d |
| MAX6675 / MAX31855 (K-type) | Adafruit MAX31855, Adafruit/RobTillaart MAX6675 (ESP32 Arduino) | max31855.py, max6675.py | adafruit_max31855 (MAX31855 only) |
| Si7021 | Adafruit_Si7021, SparkFun | micropython-si7021 (chrisbalmer) | adafruit_si7021 |
| SCD40 / SCD41 | Sensirion official, Adafruit_SCD4x, SparkFun | MicroPython_SCD4X (peter-l5) | adafruit_scd4x |
| PT100 / PT1000 + MAX31865 (also MAX31856) | Adafruit_MAX31865, Adafruit_MAX31856 | max31865.py (Adafruit port), max31856 (alinbaltaru) | adafruit_max31865, adafruit_max31856 |
| MCP9808 | Adafruit_MCP9808 | micropython-mcp9808 (kfricke) | adafruit_mcp9808 |
| TMP117 | Adafruit_TMP117, SparkFun TMP117 | micropython-tmp117 (jposada202020) | adafruit_tmp117 |
| HDC1080 | ClosedCube HDC1080, RobTillaart HDC1080 | micropython-hdc1080 (mcauser) | — |
| TMP102 | SparkFun TMP102 | micropython-tmp102 (khoulihan) | — |
| AM2320 | Adafruit_AM2320, RobTillaart AM232X | micropython-am2320 (mcauser) | adafruit_am2320 |
Best Sensor by Category
So, taking into account all of this information, how do you choose your sensor? It depends.
Do you need a sensor to use for teaching and don’t care about its precision or accuracy (you just want something cheap), or do you need something accurate to build a sensor node with triggers and thresholds? Do you care about power consumption, or is that not an issue for your project?
In the following table, we tried to pick the best sensor choice by category: overall value, budget, accuracy, power consumption, etc.
| I want… | Best pick | Why |
|---|---|---|
| Best overall (temp + humidity) | SHT41 | Good accuracy, low-power consumption, built-in heater. |
| Best overall with pressure (weather station) | BME280 | Temperature, humidity and pressure in one cheap chip. Good community support. |
| Best budget (temp + humidity) | AHT20 (~$1–3) | Cheap and better than DHT11 and DHT22. |
| Best budget (temp only) | DS18B20 (~$1–2) | Digital temperature sensor at a low price. |
| Best value (accuracy per $) | SHT31 | Great accuracy at a low price. |
| Most accurate temperature | TMP117 (±0.1°C) | Best accuracy near room temperature. |
| Most accurate humidity | SHT45 (±1.0%) | Sensirion sensors are among the best in terms of RH accuracy even in humid environments with condensation. |
| Waterproof / submersible (temperature) | DS18B20 stainless-steel probe | Cheap, sealed, and you can use many sensors on the same wire. |
| Weather-resistant temp + humidity (outdoor) | SHT31 mesh-protected probe | Splash and weather resistant. |
| Most library support / compatibility | BME280 | Supported by almost everything: Arduino, MicroPython, CircuitPython, ESPHome and Tasmota. |
| Lowest power / battery | SHT4x | Low power consumption. Great for ESP32 deep sleep projects. |
| Humid or condensing environments | SHT4x | The built-in heater clears condensation. |
| High temperatures | K-type + MAX31856 | Thermocouples reach 1350°C. |
| Cheapest high-temperature option | MAX6675 + K-type | Very low cost, but positive temperatures only. |
| Many sensors on one pin | DS18B20 | Each DS18B20 has a unique ID on the shared bus. |
| Non-contact | MLX90614 | Measures surfaces without touching them. |
| CO2 + temp/RH (air quality) | SCD41 | Measures real CO2 concentration (not an estimate). |
| VOC / indoor air quality | BME680 / BME688 | VOC gas sensing and temperature, humidity and pressure. |
| Home Assistant / ESPHome out of the box | SHT4x / SHT31 + DS18B20 | All have first-class ESPHome components |
Wrapping Up
There are a wide variety of temperature and humidity sensors for microcontrollers like the ESP32, Arduino, Raspberry Pi Pico, etc. We hope those comparison tables are helpful to help you sort the best sensor for your specify project or application. The best sensor will really depend on the application.
As we’ve mentioned previously, we use mostly the BME280 sensors in our tutorials because it measures temperature, humidity, and pressure, uses I2C communication protocol and it’s easy to use. So, it’s great for teaching IoT concepts.
But recently, we started experimenting with Sensirion’s SHT4x sensors, more specifically with the SHT41. It’s also easy to use and it’s the best option in terms of accuracy/price ratio for temperature/humidity sensor nodes. Seems a better option when compared with the BME280 if you don’t need pressure readings.
We have several guides for more than 20 sensor modules with the ESP32, ESP8266, and Raspberry Pi Pico, you can check the complete lists below:
- ESP32: 36 Free Guides for Sensors and Modules
- Raspberry Pi Pico: 20 Free Guides for Sensors and Modules
- Arduino: 39 Free Guides for Sensors and Modules
- ESP8266 NodeMCU: 25 Free Guides for Sensors and Modules
What project are you currently building? Which sensor are you planning to use? What’s your feedback on some of those sensors? Share your thoughts by writing a comment below.




Great research guys! Very useful, kudos!