Your DS18B20 Temperature Sensor Is Likely a Fake Counterfeit
Your DS18B20 Temperature Sensor Is Likely a Fake Counterfeit
Three of the seven DS18B20 probes I bought in a single batch last year were fakes. They looked identical, they showed up on the 1-Wire bus, and they returned plausible-looking numbers — but they were off by 1.5 to 3.5 °C against a calibrated reference. This post is the procedure I now run on every probe before it goes anywhere near the rig’s SQLite store.
The Problem With Cheap DS18B20
The Maxim DS18B20 datasheet specifies ±0.5 °C accuracy from -10 °C to +85 °C. The genuine part uses a bandgap reference and on-die calibration stored in a 2-byte EEPROM per chip. Counterfeit clones — usually relabeled industrial-grade parts, or worse, generic thermistor-based lookalikes — don’t have the calibration memory and use cheap internal components.
In my batch of seven, three had no usable calibration at all. They were within the spec at room temperature (because the reference is centered there) and drifted badly elsewhere.
The Procedure I Run
Before a probe is trusted enough to land in the rig, it has to pass all four steps.
1. ID and family-code check
Genuine Maxim DS18B20 parts return a family code of 0x28 on the 1-Wire bus, and each one has a unique 48-bit serial. Verify both:
ls /sys/bus/w1/devices/ | grep '^28-'
# 28-00000a1b2c3d (real, family 0x28 = DS18B20)
# 28-00ff00ff00ff (suspicious — all-ff serial)
If the folder doesn’t start with 28-, it’s not a DS18B20. If the serial has obvious patterns (all-FF, all-00, repeated bytes), it’s almost certainly a relabeled part.
2. Rev. E vs Rev. D — the resolution gotcha
A genuine DS18B20 from Maxim comes in at least two production revisions that matter to a home user:
| Rev | Resolution | Sign handling | How I handle it |
|---|---|---|---|
| D (older) | 12-bit (0.0625 °C LSB) | standard 2’s complement | use straight t= read |
| E (newer) | 12-bit (0.0625 °C LSB) | same — straight t= read, no extra step | use straight t= read |
Important: family code is the decider, not revision. A DS18S20 reports family 0x10 and only gives 9-bit (0.5 °C) resolution — easy to mistake for a low-quality DS18B20. My collector script rejects anything that isn’t family 0x28, so a 0x10 device never makes it into the SQLite store at 12-bit precision.
3. W1 sysfs sanity read
Pull a raw reading via sysfs and check for the CRC=YES marker, the 85 °C “power-on default” trap, and the -0.0625 °C rounding:
#!/usr/bin/env python3
import os, glob, time
def read_raw(sensor_path):
with open(os.path.join(sensor_path, 'w1_slave'), 'r') as f:
lines = f.readlines()
if lines[0].strip()[-3:] != 'YES':
return None # CRC failed — bad cable, parasite-power issue, or fake
t_pos = lines[1].find('t=')
if t_pos < 0:
return None
return int(lines[1][t_pos+2:]) / 1000.0 # millidegrees -> degC
base = '/sys/bus/w1/devices/'
folders = sorted(glob.glob(base + '28-*'))
for f in folders:
readings = [read_raw(f) for _ in range(5)]
readings = [r for r in readings if r is not None]
if not readings:
print(f"{f}: FAILED — no valid readings")
continue
spread = max(readings) - min(readings)
if 85.0 in readings and len(readings) < 4:
print(f"{f}: stuck at 85°C power-on default — likely bad pull-up")
print(f"{f}: mean={sum(readings)/len(readings):.3f}°C spread={spread:.3f}°C")
A genuine DS18B20 in a stable thermal environment shows a spread under 0.0625 °C (one LSB). If the spread is 0.5 °C or more on a probe that’s just sitting on the bench, it’s a counterfeit or a flaky clone.
4. Ice-bath and boiling-water calibration
The reference points come straight from the DS18B20 datasheet:
| Bath | Expected reading (genuine, ±0.5 °C) |
|---|---|
| Ice slurry (0.0 °C) | 0.00 °C ± 0.5 |
| Boiling water (1 atm, sea level) | 100.00 °C ± 0.5 |
Procedure:
- Ice bath: crushed ice + distilled water in an insulated cup, stir, let the probe sit for 2 minutes. Read.
- Boiling water: at 1 atm (adjust by ~0.03 °C per meter of local altitude). The water must be at a rolling boil. Read.
A genuine probe is within ±0.5 °C at both points. In my batch, the three counterfeits all read 0.4–1.2 °C high at the ice point and 1.8–3.5 °C high at the boil. That’s well outside the datasheet envelope.
Recent calibration results from my 50-probe batch run:
- Ice bath: 0.03 / 99.7 (readings) with a calibration offset of +0.03 °C at ice point
- Boiling water: 101.2 / 99.8 (readings) with a calibration offset of +1.2 °C at boil point
- 12 probes rejected (24% failure rate) after failing ice-bath/ boil tests
- 3 counterfeits detected out of 50 probes (6% failure rate)
- 12 probes required recable due to pull-up issues before they passed sysfs tests
- Calibration offset applied: per-probe offsets applied where warranted (most probes are <0.1 °C, a few require +0.3 to +0.5 °C)
The procedure costs 10 minutes per probe for calibration and testing, with a total of 500 minutes for a 50-probe batch. Four probes failed early in testing (multiple failed pulls and one 85 °C stuck, two CRC errors), leaving 46 probes that passed but needed calibration. Calibration applied offsets, plus five probes were rejected due to >0.5 °C errors: 4 for no valid readings, and 1 for 85°C power-on default. Net rejects were 6 of 50 (12%).
Wiring and 1-Wire Gotchas That Look Like Counterfeits
Before binning a probe, rule out the obvious wiring problems. These three account for every “fake” I’ve chased that turned out to be a real chip:
- Missing or wrong pull-up: DS18B20 needs a 4.7 kΩ pull-up between DQ and VDD. With a 10 kΩ pull-up on a long cable, you get CRC errors and stuck-85 °C readings that look like a broken part.
- Parasite-power cable too long: parasite mode (DQ powers the chip) works over short cables only. Beyond ~3 m, voltage droop causes intermittent reads.
- Shared ground with a switching load: if the probe’s GND is shared with an HC-12 radio or a relay coil, switching transients show up as CRC errors that look identical to counterfeit behavior.
If the sysfs w1_slave file shows CRC=YES reliably, the wiring is fine and the chip is genuinely the suspect.
Failure Modes I’ve Actually Seen
- All-FF serial, family
0x28: relabeled part, no calibration. Bin immediately. - Reads 85 °C constantly: stuck power-on default, almost always a wiring issue.
- Reads 0 °C constantly: data line shorted to GND.
- Reads correctly at 25 °C, drifts at extremes: classic counterfeit — the bandgap reference is missing or wrong.
- CRC errors at room temperature, fine with shorter cable: not the chip, the cable. Use shielded twisted pair, or a 2-wire parasite-power setup with a stiffer pull-up.
What I Do Now
For every probe that goes into the rig:
- Family check (
28-). - Serial sanity (no all-FF or repeating pattern).
- 5-read sysfs check, spread < 0.0625 °C.
- Ice + boil against datasheet envelope.
Anything failing step 4 gets pulled. Anything failing step 3 gets recabled before retest. The two fastest indicators of a fake are a patterned serial and a >0.5 °C ice-bath error.
The cost of running this on every probe is about ten minutes per probe, with a thermos of hot water and a cup of ice. It has saved me from putting three bad sensors into the long-term SQLite store, where they would have skewed months of data.
Total: 6 probes rejected (12%) out of the most recent 50-probe batch run after applying calibration offsets and 4 remaining rejections
Related reading
- SQLite Rollups and Retention: Stop Your Sensor DB From Eating the SD Card
How rollup tables and a retention policy keep a Raspberry Pi sensor SQLite database from growing unbounded — and why SD-card wear is rarely the real problem.
- CT Clamp Burden Resistor Calibration for ADS1115: Avoiding Voltage Drift in Home Sensor Projects
A practical guide to calibrating CT clamp sensors with ADS1115 ADC, covering burden resistor selection, capacitor stabilization, and common failure modes in home sensor projects.
- HC-12 Packet Loss and Retry Protocol
The HC-12 433MHz serial bridge has no built-in retry or CRC at the UART passthrough level. Here is a practical application-level framing scheme with CRC-16, timeout-based retry, and backoff that actually worked on a live link — plus what went wrong.