DS18B20 probe module
The DS18B20 probe module is the DS18B20 digital thermometer with its 4.7 kΩ pull-up resistor fitted, the value the 1-Wire bus wants. It costs $6 and is for accurate temperature sensing over a long cable: thermostats, hot water, soil, any probe that has to sit away from the Pi. Wire VDD to 3.3 V, DQ to GPIO4 and GND to ground, then read the kernel's 1-Wire files.
What's inside
| Part | Qty | Price each |
|---|---|---|
| DS18B20 thermometer | 1 | $4 |
| Resistor | 1 | $0.25 |
| Total | 2 | $4.25 |
- The DS18B20 converts on demand and reports to 0.0625 °C resolution (±0.5 °C accuracy), identifying itself with a unique 64-bit ROM code.
- The 4.7 kΩ resistor pulls
DQup to the supply, because 1-Wire devices only pull the bus low; 4.7 kΩ is the datasheet's value.
| Exposed pin | Inside the kit |
|---|---|
| vdd | t:VDD |
| dq | t:DQ |
| gnd | t:GND |
DQ must reach GPIO4: that is the Pi's default 1-Wire pin and the only one the simulator (and the dtoverlay=w1-gpio default on a real Pi) answers on. The kit has no chain ends.
Wiring it in circuit.py
from wiring import *
pi = Pi()
probe = kits.DS18B20Module()
pi.V3_3 >> probe.vdd
pi.GPIO4 >> probe.dq
probe.gnd >> pi.GNDDriving it in main.py
import glob
from time import sleep
device = glob.glob("/sys/bus/w1/devices/28-*/w1_slave")[0]
while True:
lines = open(device).read().splitlines()
if lines[0].endswith("YES"):
millidegrees = int(lines[1].rsplit("t=", 1)[1])
print(f"{millidegrees / 1000:.1f} C")
sleep(1)Why buy the kit
Loose parts cost $4 + $0.25 = $4.25, against $6 — $1.75 for the pull-up fitted and the probe terminated on a board. On a breadboard the 4.7 kΩ resistor is easy to miss and the bus quietly returns nothing; the module turns the three connections into the whole job.
Simulator vs real hardware
- The 1-Wire bus is simulated at the transaction level:
/sys/bus/w1/devices/28-*folders appear when the program starts (the wiring cannot change mid-run), and each read re-samples the probe and waits the conversion time — 750 ms at the default 12 bits. - About 1 % of reads come back with a bad CRC (
crc=.. NO), so real code checks theYESline as above and retries; a bad read is not an error, just a skipped sample. - Each part draws one fixed ROM code from its seed, so it stays the same probe across the run.
Further reading
- Kernel driver w1_therm — what
w1_slavecontains and how the kernel exposes 1-Wire devices on a real Pi.