PyRaspBeta

← All practice problems

Raspberry Pi practice problem · I²C, SPI, UART & 1-Wire

Probes on a chain

HardBudget $12Python · gpiozero

1-Wire lets many probes share one data pin: each has a unique 64-bit ROM code and gets its own /sys/bus/w1/devices/28-… folder.

Build: two DS18B20s, both with their data pin on GPIO4, powered from 3V3, with one 4.7 kΩ pull-up from the data line to 3V3.

Program: in a loop, read every 28-* device (don't hard-code the codes; skip a reading whose CRC line doesn't end in YES). After each full pass print one line per probe, then the spread between warmest and coldest:

28-0123456789ab: 4.00 C
28-ba9876543210: 21.00 C
Spread: 17.00 C

The test keeps one probe at 4 °C and the other at 21 °C, then warms the cold one to 10 °C at 4 s (spread 11). Each read takes 0.75 s.

More in I²C, SPI, UART & 1-Wire