Digital temperature sensors are a great way to test and monitor your environment, whether that is experimenting with cooling solutions, monitoring indoor conditions, or creating a DIY thermostat. With the wide variety of temperature sensors available, it can be overwhelming to decide on a sensor, which is why we've created this guide to help narrow down which temperature sensor is right for your project.
While this guide highlights Arduino, the same sensors and concepts can be applied to ESP32, ESP8266, and Raspberry Pi projects.
Understanding Temperature Sensors
Temperature sensors work by converting thermal energy into measurable electrical signals. These signals can then be read and interpreted by microcontrollers to provide accurate temperature measurements. There are multiple different forms of sensors, including the following:
- Resistance Temperature Detectors (RTDs) - Also known as resistance thermometers, these sensors measure temperature based on changes in electrical resistance of metals. They are highly accurate, but generally cost more.
- Thermocouple - Consist of two different metals joined together. They generate a small voltage that changes with temperature. They are great for high temperature ranges but often require additional electronics to read.
- Negative Temperature Coefficient (NTC) Thermistors - Their resistance decreases as temperature rises. Thermistors are inexpensive and popular for hobby projects but often require an analog to digital conversion.
- Infrared Sensors - Measure temperature without contact by detecting thermal radiation. These are ideal for non-contact measurements but can be affected by distance and surface emissivity.
Digital vs Analog Temperature Sensors
Temperature sensors come in both digital and analog varieties, but they work very differently and suit different types of projects.
Analog Sensors
Analog sensors, like thermistors and certain RTDs, output a voltage or resistance that changes with temperature. A microcontroller board reads this signal through an analog to digital converter (ADC), then converts it into a temperature value, which can be used in your code. Analog sensors are often inexpensive, but are generally more sensitive to noise, voltage fluctuations and wiring errors. Accuracy depends on both the sensor and the quality of the ADC reading.
Digital Sensors
Digital sensors are essentially analog sensors that include the analog to digital conversion internally, removing the need for manual conversion and reducing the chance of errors caused by wiring or noise. This simplifies the data extraction process from the sensor, while also improving accuracy and reliability by being factory calibrated. The sensors typically communicate via known protocols such as OneWire, I2C or SPI, making it easier to connect multiple sensors or interface with different microcontrollers.
For beginners and most DIY projects, digital sensors are preferred because they are easier to wire, simpler to program, and more reliable in real-world applications. Analog sensors are still useful in situations where very low cost or custom voltage sensing is needed, but this guide focuses on digital temperature sensors.
Comparing Digital Temperature Sensors
We've produced a quick comparison table comparing different popular digital temperature sensors to help narrow down which sensor suits your needs best.
| Spec / Sensor | DHT11 | DHT22 (AM2302) | BME280 | DS18B20 (Waterproof) |
|---|---|---|---|---|
| Interface / Communication | Single-wire digital (custom DHT protocol) | Single-wire digital (custom DHT protocol) | I2C / SPI | 1-Wire standard protocol |
| Features | Humidity sensing | Humidity sensing | Pressure + humidity | Blank |
| Library / Compatibility | Arduino, Raspberry Pi | Arduino, Raspberry Pi | Arduino, Raspberry Pi | Arduino, Raspberry Pi |
| Operating Voltage | 3–5.5V | 3.3–5.5V | 3.3–5V | 3–5.5V |
| Temperature Accuracy | ±2°C | ±0.5°C | ±1°C | ±0.5°C |
| Humidity Accuracy | ±5°C | ±2°C | ±1°C | NA |
| Precision / Resolution | 1°C | 0.1°C | 0.01°C | 0.5°C |
| Measurement Range | 0–50°C | -40–80°C | -40–85°C | -55–125°C |
| Response Time | ~6-15s | ~2s | Depends on sampling rate | ~750ms |
| Current Draw | ~0.5mA (2.5mA max) | ~1mA (1.5mA max) | ~1mA (2mA max) | ~1mA (1.5mA max) |
| Sensor Type | Temp & humidity | Temp & humidity | Temp, humidity & pressure | Temp only |
| Physical Form / Durability | Plastic, small | Plastic, small | Chip, small, solderable | Waterproof probe, generally prewired and longer |
| Multiple Sensors on Bus | No | No | Yes, with I2C addresses or SPI CS pins | Yes, multiple DS18B20 on same 1-Wire bus |
| Cost / Availability | Low | Low | Medium | Low-medium (depending on length) |
| Environmental Limitations | Indoor use | Outdoor ok, avoid condensation | Blank | Can handle wet conditions |
Current draw values are approximate and represent typical usage during measurements, with real consumption varying based on how often and how the sensor is read. DS18B20 pricing varies because it is sold as both a bare sensor and as a waterproof metal probe, with longer cable lengths increasing cost. Response time affects how quickly temperature changes are reflected in readings, slower sensors may lag in rapidly changing environments, while faster sensors suit control or real-time monitoring. The BME280 response time depends on the configured sampling rate and filtering rather than a fixed hardware value. Precision or resolution indicates the smallest change a sensor can report, while accuracy shows how close the reading is to the true value. A sensor can be very precise but less accurate, so both should be considered when choosing a sensor for a project.
DHT11

The DHT11 is an entry-level digital temperature and humidity sensor suitable for beginners experimenting with Arduino or other microcontrollers. It communicates through a single-wire digital protocol using one digital pin per sensor and cannot be daisy-chained.
Its accuracy is limited to around ±2°C, resolution is 1°C, and response time is 1–2 seconds. It operates reliably between 0°C and 50°C and should be used indoors to avoid moisture damage.
The DHT11 is generally not recommended where accuracy matters but is suitable for simple indoor monitoring or testing new ideas.
DHT22 (AM2302)

The DHT22, also known as AM2302, is an upgraded version of the DHT11 with improved accuracy and resolution for a small increase in cost. It uses the same single-wire digital protocol and library as the DHT11, requiring one dedicated pin per sensor.
The measurement range is wider, from -40°C to 80°C, with ±0.5°C accuracy and 0.1°C resolution. Response time is approximately 2 seconds, and it provides reliable humidity readings.
The DHT22 is suitable for indoor or outdoor applications where condensation is avoided, making it appropriate for projects requiring higher precision than the DHT11.
BME280

The BME280 from Bosch measures temperature, humidity, and barometric pressure in a single compact sensor. It communicates via I2C or SPI, allowing multiple sensors on the same I2C bus or separate SPI chip-select lines.
Temperature accuracy is around ±0.5°C with 0.01°C resolution, and readings are fast and continuous.
The BME280 is suitable for more advanced projects such as weather stations, indoor air quality monitoring, or applications where multiple environmental parameters need to be tracked. The sensor requires protection in harsh environments as it is not waterproof.
DS18B20 (Waterproof)

The DS18B20 is a digital temperature-only sensor that uses the 1-Wire protocol, allowing multiple sensors to be connected on the same bus, each with a unique address. It is often available in a waterproof, prewired probe form, which facilitates temperature measurement in water or outdoor environments.
Its range is -55°C to 125°C with ±0.5°C accuracy, and readings take approximately 750ms at full resolution. The prewired probe simplifies measuring temperature at a distance or from multiple locations in the same vicinity, making multi-point monitoring easier than wiring and waterproofing other sensors.
The main limitation is that it only measures temperature and does not provide humidity or pressure data, unlike some of the previous sensors.
Which is best?
Ultimately, the choice of which digital temperature sensor to choose depends on your skill level and requirements. The DHT11 is great for novices learning how to use microcontrollers and different sensors, DHT22 is best for more experienced users that prioritise accuracy while maintaining affordability, BME280 is ideal for projects requiriing detailed environment data, such as humidity and pressure sensing, and the DS18B20 is perfect for measuring temperature in wet and harsh conditions. We hope with this guide we've helped you choose which sensor is best for your project. Happy tinkering!