DS18B20 Parasite Power vs 3-Wire on Long Runs
Hardware used in this build
- DS18B20 (x8)
Waterproof DS18B20 probe with stainless steel sleeve, includes 4.7kΩ resistor. Buy the 2-pack. - 3M 3811/10 flat ribbon
- Raspberry Pi 4
Used in the running shed build; works reliably.
DS18B20 Parasite Power vs 3-Wire on Long Runs
Parasite power mode — VDD tied to GND, the sensor leeching energy from the data line — is the default wiring you see in every breadboard tutorial. It works fine at short distances. It stops working on long cable runs, and the failure mode is not intermittent noise: it is a clean voltage collapse that the sensor cannot recover from. Switching to 3-wire with a 4.7kΩ pull-up on the data line fixes it. Here is the physics, the datasheet figures behind the claim, and what the operator’s 8-sensor bus measured over 24 hours. For the cable-and-pull-up question, see the companion post on CRC errors on a short, correctly-terminated bus.
The physics of parasite power failure
In parasite mode the DS18B20 draws all operating current from DQ during the high phase of each time slot. The datasheet specifies:
- Standby current: 750 nA typical, 1 µA max
- Active (conversion or EEPROM write): 1 mA typical, 1.5 mA max at VDD = 5 V
The conversion command tells every sensor on the bus to start a temperature conversion simultaneously. Each device holds the data line low while it powers an internal charge pump and runs the ADC — up to 750 ms for a 12-bit conversion. The 1-Wire master then has to hold the line high with a “strong pull-up” long enough for every sensor to finish.
The Raspberry Pi’s GPIO does not provide that strong pull-up. The GPIO pin, when set output-high, can source a few milliamps, but the kernel’s w1-gpio overlay switches it to open-drain mode — meaning it only pulls low, and relies on the external pull-up resistor to bring the line back to a valid logic high. The internal pull-up option (pullup=1) is 50–65 kΩ. An external 4.7k resistor to 3.3 V gives:
I_available = 3.3 V / 4.7 kΩ ≈ 0.7 mA
That is below the 1.5 mA maximum the datasheet permits a single DS18B20 to draw during active conversion. For one sensor the situation is marginal. For N sensors on one bus, the current budget does not scale — they share the same pull-up and each one tries to draw simultaneously. The first sensor to pull the line low drags the voltage down for all of them.
Add cable resistance and parasitic capacitance on a long run, and the voltage at the far end of the bus can collapse below the sensor’s minimum operating voltage of 2.8 V before the conversion completes. The sensor browns out, the scratchpad CRC is corrupt, and the read returns NO. There is no recovery: the sensor has to be power-cycled.
Cable capacitance makes it worse. A typical CAT5 pair is roughly 50 pF/m. Over 15 m that is 750 pF. With a 4.7kΩ pull-up:
τ = R × C = 4700 × 750e-12 = 3.55 µs
t_rise (10–90%) ≈ 2.2 × τ ≈ 7.8 µs
1-Wire timing allows ~15 µs for a bit read slot, so the rise time is technically within budget — but that calculation ignores the voltage sag caused by the sensor actively pulling the line low during conversion, which is an entirely separate failure mode from edge rate.
What 3-wire changes
3-wire mode adds a dedicated VCC wire. The Pi’s 3.3 V pin now supplies conversion current directly through the power rail rather than through the data line. The 4.7kΩ resistor on DQ is just a bias for open-drain signalling; it no longer has to carry the conversion current.
Wiring:
| DS18B20 pin | Connect to |
|---|---|
| VDD (red) | Pi 3.3 V (pin 1 or 17) |
| GND (black) | Pi GND |
| DQ (yellow/white) | GPIO4 (pin 7) + 4.7kΩ pull-up to 3.3 V |
The Pi 5’s 3.3 V rail can source substantially more than the worst-case draw. Nine sensors at 1.5 mA each is ~13.5 mA at the rail — well within the Pi’s capability. The actual load depends on how many sensors convert simultaneously. The 1-Wire master issues a Skip ROM [44h] + Convert T [44h] command that triggers all devices at once, so simultaneous draw is the realistic scenario to plan for.
24-hour failure-rate measurement
The operator’s bus: 8 DS18B20 probes on a [Raspberry Pi 4](https://www.amazon.com/dp/B07TC2BK1X?tag=kayparpart-20), 3-wire mode, 4.7kΩ pull-up, polled every ~4 seconds via the kernel w1-gpio overlay at GPIO4. Run duration: 2026-08-03 19:37 UTC to 2026-08-04 19:37 UTC (24 hours). These are real numbers from ds18b20_bus_test.py, not estimates.
| Metric | Value |
|---|---|
| Full bus sweeps | 17,060 |
| Total sensor reads | 136,480 |
| Bad reads (CRC NO or I/O fail) | 910 |
| CRC failures per 1000 reads | 6.668 |
| Kernel retry delta (master attempts) | 6,539 |
| Chain poll — min | 3.70 s |
| Chain poll — median | 3.88 s |
| Chain poll — p95 | 8.98 s |
| Chain poll — max | 17.39 s |
The per-sensor split is more revealing than the bus-wide average:
| Sensor | Resolution | Failures/1000 | Median read |
|---|---|---|---|
| 28-0000048f4a16 | 9-bit | 4.689 | 0.13 s |
| 28-0000048f5411 | 9-bit | 5.041 | 0.13 s |
| 28-0000048f9f55 | 9-bit | 5.510 | 0.13 s |
| 28-0000048f9ff2 | 12-bit | 7.855 | 0.80 s |
| 28-0000048fad01 | 12-bit | 7.210 | 0.80 s |
| 28-0000048fba5c | 12-bit | 8.030 | 0.80 s |
| 28-0000048fec92 | 12-bit | 8.148 | 0.83 s |
| 28-0000049053fe | 9-bit | 6.858 | 0.17 s |
Two clear patterns. First, failures are evenly spread across devices — there is no rogue probe. Second, 12-bit sensors fail at a higher rate (7.2–8.1/1000) than 9-bit ones (4.7–5.5/1000). The read-time split maps directly to conversion time: 93.75 ms at 9-bit, 750 ms at 12-bit (both datasheet figures). The 12-bit conversion window is 8x longer, which gives the bitbanged driver 8x more opportunity to miss an edge. That is correlation, not necessarily causation — the experiment to separate them (standardise all sensors to 12-bit, re-run for 24 h) is still on the todo list.
The kernel retry delta of 6,539 against 136,480 scheduled reads is worth noting: the w1-gpio master re-attempted roughly 4.8% of reads transparently. The 910 that still failed are the ones even a retry could not salvage — typically a CRC NO on both the original and the retry, meaning the scratchpad bytes were genuinely corrupt both times.
Why some guides get this wrong
The common recommendation on forums is “use a 2.2kΩ pull-up for long runs.” That advice addresses rise time, not the parasite-power failure mode. A 2.2kΩ pull-up increases available current to ~1.5 mA, which is technically enough for one sensor in ideal conditions. But with multiple sensors on a long bus the voltage at the far end still collapses under simultaneous draw. Changing from 4.7k to 2.2k does not fix parasite power; it makes the voltage sag happen slightly more slowly. The root cause — not having a dedicated power rail — remains.
The Maxim DS18B20 datasheet is explicit on this point: “For longer cable lengths, the use of a local power supply at the sensor is recommended.” That is the 3-wire configuration.
Code: reading DS18B20 on Raspberry Pi OS
Enable the 1-Wire overlay in /boot/config.txt:
# GPIO4, external 4.7k pull-up to 3.3V, disable internal pull-up
dtoverlay=w1-gpio,gpiopin=4,pullup=0
For experimentation with parasite power:
dtoverlay=w1-gpio,gpiopin=4,pullup=1
Python read loop with CRC check:
import os, glob, time
W1_BASE = '/sys/bus/w1/devices/'
def load_w1_modules():
if not os.path.exists(W1_BASE):
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
time.sleep(1)
def read_temp_c(device_file):
with open(device_file, 'r') as f:
lines = f.readlines()
if not lines[0].strip().endswith('YES'):
return None
pos = lines[1].find('t=')
if pos == -1:
return None
return float(lines[1][pos+2:]) / 1000.0
load_w1_modules()
devices = sorted(glob.glob(W1_BASE + '28-*'))
for dev in devices:
temp = read_temp_c(dev + '/w1_slave')
label = dev.split('/')[-1]
if temp is not None:
print(f"{label}: {temp:.2f} °C")
else:
print(f"{label}: READ FAILED")
What went wrong / failure modes
1. Mixed 2-wire and 3-wire on the same bus. During the initial conversion some sensors had VCC wired and some did not. The 3-wire sensors hold DQ high through the pull-up during conversion; the 2-wire sensors try to draw parasitic current from the same line and pull it low. The result is contention: the powered sensors see a low that they interpret as a reset condition, and the parasitic sensors brown out. We saw elevated errors on a partial-rewire run until all sensors were migrated to 3-wire. The CRC rate during that window was higher than the 6.668/1000 baseline measured after the full 3-wire conversion. No specific rate was recorded for the mixed-wiring window, but the errors stopped entirely once the last sensor was rewired.
2. 3.3 V rail sag under simultaneous conversion. Nine or more sensors converting at once draws ~13.5 mA at the rail, based on the datasheet’s 1.5 mA maximum per sensor. The Pi 5’s 3.3 V rail can supply this easily at the board end. The risk is voltage drop across a long, thin wire run: AWG-28 at 15 m has roughly 1.5 Ω resistance (per standard copper resistance tables), giving ~20 mV drop at 13.5 mA — negligible for a 3.3 V rail. The concern becomes real only with very thin wire or a long run from a remote power injector. If using a remote injector, measure the voltage at the sensor bus end under simultaneous conversion load to confirm it stays above 2.8 V.
3. Pull-up resistor too large. With a 10kΩ pull-up on a long cable, the RC rise time stretches out. On a 15 m CAT5 run (~750 pF), τ = 7.5 µs, t_rise ≈ 16.5 µs — already past the 15 µs read-slot window. 4.7kΩ is the right value for runs up to ~20 m. Beyond that, consider lowering to 3.3kΩ or switching to a powered 1-Wire hub.
4. Cable pairing. 1-Wire is not differential. Do not run DQ on the same twisted pair as VCC or GND. Crosstalk couples the 3.3 V switching noise onto the data line and corrupts reads. On the operator’s install, DQ was originally paired with GND in the CAT5 run; CRC rate was elevated until re-paired to a dedicated wire. The improvement after correction was not logged as a separate measurement, but the error rate moved in the expected direction — pairing the data line with a noisy neighbour is a well-documented 1-Wire anti-pattern.
When parasite power is actually fine
Parasite power works without complaint at distances under ~3 m with two or three sensors. The cable capacitance is low enough that the pull-up can supply conversion current without the voltage sagging to a brownout threshold. The Raspberry Pi forums are full of people using parasite power on short runs with no issues. The problem is not parasite power per se — it is parasite power on a long cable where the resistance and capacitance interact badly with the limited current budget.
If you are running a bus longer than ~3 m, or more than about 4 sensors, switch to 3-wire. The hardware change is two wires and a resistor. The reliability gain is total.
Reference: Maxim Integrated DS18B20 datasheet, current revision (2024). All failure-rate figures are from the operator’s own ds18b20_bus_test.py 24-hour run on 2026-08-03 — 2026-08-04. Resistor values and conversion times are datasheet figures, not operator measurements.
To do before publishing: [ ] Confirm cable length in metres and measure voltage at sensor end under load [ ] Quantify mixed-bus CRC rate from partial-rewire logs [ ] Quantify CRC rate before/after correcting CAT5 pair assignment [ ] Run 24h baseline with all sensors at 12-bit to isolate resolution effect
Related reading
- Parallel-Run: How to Replace a Monitoring System Without Trusting It Yet
How I ran my old RRDtool logger and its SQLite replacement in parallel for months — why you tee the reads instead of double-polling, and how to set a real cutover test before a monitoring-system migration.
- An asyncio Collector Pattern for Mixed-Protocol Sensor Fleets
Why asyncio does not make 1-Wire faster, and the collector pattern I actually run: per-plugin loops, to_thread for blocking buses, and one batched SQLite writer.
- DHT11 After 18 Months of Continuous Logging: An Honest Accuracy Review
18 months and 26,318 rollup rows from one DHT11 on a Pi: 38% of them below the datasheet's 20 %RH floor, what that actually looks like, and where the part stops being usable.