Connect Multiple DS18B20 1‑Wire Sensors to a Raspberry Pi for Accurate Temperature Monitoring
In this expanded guide we show how to wire and program multiple DS18B20 1‑wire temperature sensors on a Raspberry Pi, a setup ideal for solar water‑heating controllers and any system that requires differential temperature monitoring.
The DS18B20 communicates over a single data line using the 1‑wire protocol, which means you can connect several devices to the same GPIO pin. The schematic below demonstrates a three‑sensor configuration: all units share a common 3.3 V supply, a ground reference, and one data line that returns the readings to the Pi.
Because each DS18B20 contains a factory‑burned unique serial number, the Raspberry Pi can distinguish every sensor on the bus. This makes it straightforward to read and identify multiple devices with minimal wiring.
Step 1: Prepare your Pi
- Enable the 1‑wire interface: edit
/boot/config.txtand adddtoverlay=w1-gpio. - Reboot the system.
Step 2: Connect the first sensor
- Wire the sensor’s VDD to 3.3 V, GND to ground, and DQ to GPIO4 (pin 7).
- Attach a 4.7 kΩ pull‑up resistor between VDD and DQ.
Step 3: Discover the device
Run ls -l /sys/bus/w1/devices in a terminal. You’ll see a directory named 28-XXXXXXXXXXXX, where the eight hexadecimal digits are the sensor’s unique ID.
Step 4: Label and repeat
- Mark the sensor’s serial number on a label and note its physical location.
- Add the second sensor, run the
lscommand again, and capture its ID. - Continue until all sensors are connected and catalogued.
Once you have identified each unit, you can address them individually in your Python or C programs by referring to the 28-XXXXXXXXXXXX directory that corresponds to the desired sensor.
For more in‑depth instructions, refer to the full guide Measure temperatures with a 1‑wire DS18B20 sensor and Raspberry Pi.
Manufacturing process
- How to Read Temperature with a DS18B20 on Raspberry Pi 2
- Build a Remote Temperature Sensor with Raspberry Pi and Python – Step‑by‑Step Guide
- How to Connect a DS1820 One‑Wire Temperature Sensor to a Raspberry Pi Using GPIO
- How to Connect a DS18B20 One‑Wire Digital Thermometer to a Raspberry Pi – A Step‑by‑Step Guide
- Build a Multi‑Sensor Temperature & Light Monitoring System with Raspberry Pi & DS18B20
- Build an Automated Aeroponics System with Raspberry Pi and Humidity Sensor
- Build a Raspberry Pi Home Temperature Monitor with MCP9808, InfluxDB & Grafana
- Arduino Ultrasonic Distance & Temperature Monitor with LCD Alarm System
- NASA Goddard’s Lab‑On‑Chip Sensor Delivers Real‑Time Flow & Temperature Monitoring
- DS18B20 1-Wire Digital Temperature Sensor: Pinout, Key Features & Practical Applications