DS18B20 Wrong Temperature
Your DS18B20 temperature readings are inaccurate too high, too low, or inconsistent. The sensor works but shows wrong values compared to a reference thermometer. This guide covers calibration, self-heating, sensor placement, resolution settings, and common causes of inaccurate DS18B20 readings.
Last updated: April 22, 2026 | 10 min read
Symptoms
- Temperature reads 0.5-2C higher or lower than actual
- Reading drifts slowly over time
- Inconsistent readings between multiple DS18B20 sensors
- Reading changes when device orientation changes
- Temperature accurate at one point but wrong at others
- Resolution too low
- Reading affected by nearby heat sources
Common Causes
- Self-Heating of DS18B20 Sensor warms itself during operation, reading 0.5-1.5C high after continuous use
- ESP32/ESP8266 Heat Proximity Board generates heat affecting nearby sensor
- Poor Thermal Contact Sensor not properly contacting measured surface
- Resolution Setting Too Low Default 9-bit resolution only shows 0.5C increments; 12-bit gives 0.0625C
- Sensor Manufacturing Tolerance DS18B20 specified accuracy is 0.5C, but individual sensors may vary
- Voltage Variation Unstable power supply affects conversion accuracy
- Long Wire Length Signal degradation on long 1-Wire bus can cause reading errors
DS18B20 Accuracy Specifications
| Temperature Range | Specified Accuracy | Real-World Typical |
|---|---|---|
| -10C to +85C | 0.5C | 0.3-0.7C typical |
| -55C to +125C | 2.0C | 1-2C typical |
| Repeatability () | 0.1C | Excellent () |
| Resolution () | 9-12 bits | 0.5C to 0.0625C step |
DS18B20 is more accurate than DHT22 for temperature-only applications .
DS18B20 Resolution Settings
| Resolution () | Bits () | Step Size () | Conversion Time () | Use Case () |
|---|---|---|---|---|
| 9-bit | 9 | 0.5C | 93.75ms | Fast, low accuracy (,) |
| 10-bit | 10 | 0.25C | 187.5ms | Balanced () |
| 11-bit | 11 | 0.125C | 375ms | Good accuracy () |
| 12-bit | 12 | 0.0625C | 750ms | Recommended for OceanRemote () |
OceanRemote firmware uses 12-bit resolution for maximum accuracy.
Step-by-Step Fixes
1. Use OceanRemote Offset Calibration
Apply offset to correct temperature reading:
- Log into OceanRemote dashboard
- Find your device card with DS18B20
- Locate the temperature card with offset input field
- Calculate offset = Reference Temperature - Current Reading
- Example: Reference 22.0C, Reading 22.8C Offset = -0.8C
- Enter offset value and press Enter
- Wait 5-10 seconds for dashboard to update
- Verify reading matches reference thermometer
// Formula used by OceanRemote:
// Calibrated Temperature = Raw Temperature + Offset
//
// Example with offset -0.8:
// Raw: 22.8C Calibrated: 22.0C
2. Move DS18B20 Away from ESP32/ESP8266
ESP32/ESP8266 generate significant heat:
- Keep DS18B20 at least 10-15 cm away from the board
- Use extension wires
- Mount DS18B20 on a small separate PCB away from main board
- Avoid placing DS18B20 above ESP32/ESP8266
- If using enclosure, add ventilation holes near sensor
- For waterproof DS18B20, extend wires to place sensor away from electronics
3. Verify Resolution Setting
Check and set resolution to 12-bit for best accuracy:
// Set DS18B20 to 12-bit resolution
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 15
OneWire oneWire;
DallasTemperature sensors;
void setup() {
Serial.begin;
sensors.begin();
// Set resolution to 12-bit for all devices
sensors.setResolution;
// Verify resolution
DeviceAddress address;
sensors.getAddress;
int resolution = sensors.getResolution;
Serial.print;
Serial.print;
Serial.println(" bits");
}
void loop() {
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex;
Serial.print;
Serial.print; // Print 4 decimal places
Serial.println;
delay;
}
4. Improve Thermal Contact
Poor contact causes inaccurate readings:
- Use thermal paste between sensor and measured surface
- Ensure sensor is pressed firmly against surface
- For pipe measurements, use zip ties or thermal tape
- Avoid air gaps they act as thermal insulation
- For waterproof DS18B20, immerse probe fully in liquid or press against surface
5. Calibrate with Ice Water
Two-point calibration for better accuracy:
- Fill container with crushed ice and water
- Insert DS18B20 probe into ice water
- Wait 10 minutes for stabilization
- Record reading should be 0C
- Calculate offset: Offset = 0C - Reading
- Apply offset in OceanRemote dashboard
- Verify at room temperature
- For high-temperature calibration, use boiling water
6. Reduce Self-Heating Effect
DS18B20 self-heating is minimal but measurable:
- Increase read interval to 5-10 seconds
- Use 3.3V power to reduce power consumption
- Add small heatsink to DS18B20
- Power sensor only when reading
7. Compare with Known Good DS18B20
Isolate sensor vs environmental issues:
- Test with a different DS18B20 sensor
- Place both sensors side by side in same environment
- If both read differently, manufacturing variation
- If both read same but wrong, environmental issue
- If new sensor accurate, original sensor is faulty
Offset Calculation Examples
| Reference Temp | DS18B20 Reading | Offset | Result After Offset |
|---|---|---|---|
| 22.0C () | 22.8C () | -0.8C () | 22.0C () |
| 22.0C | 21.3C | +0.7C | 22.0C |
| 18.5C | 19.0C | -0.5C | 18.5C |
| 30.0C | 29.4C | +0.6C | 30.0C |
Prevention Tips
- Mount DS18B20 away from ESP32/ESP8266
- Use 12-bit resolution for best accuracy
- Use thermal paste for surface temperature measurements
- Use OceanRemote offset calibration for final adjustment
- For critical applications, calibrate at two temperatures
- Use waterproof DS18B20 for liquid/outdoor measurements
- Recalibrate annually as sensor ages
Related Issues
- DS18B20 Not Detected No sensor found
- DS18B20 Reading -127C Communication error
- Temperature Offset Calibration General calibration guide
- Power Supply Not Enough Current Brownout issues
Frequently Asked Questions
Q: How accurate is DS18B20 compared to DHT22?
A: Both have 0.5C specified accuracy. DS18B20 has better repeatability , no humidity cross-sensitivity, and wider range . For temperature-only applications, DS18B20 is superior.
Q: My DS18B20 readings drift over time. Is this normal?
A: Minimal drift over time is normal . If drift is significant , check for moisture ingress or power supply instability. Recalibrate if needed.
Q: Can I use DS18B20 for freezer monitoring ?
A: Yes. DS18B20 is rated for -55C to +125C, making it perfect for freezers. Accuracy at -20C to -30C is within 0.5-1C. Use waterproof version for freezer environments.
Still having temperature issues? Contact Support or return to the Troubleshooting Hub.