Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

How to Connect a DS18B20 One‑Wire Digital Thermometer to a Raspberry Pi – A Step‑by‑Step Guide

While searching for a simple way to measure temperature with a Raspberry Pi, I discovered the DS18B20 1‑wire digital temperature sensor. Its accuracy—±0.5 °C at 0 °C—and minimal wiring make it ideal for beginners and seasoned makers alike.

The sensor is inexpensive, requires only a single 4.7 kΩ pull‑up resistor, and fits easily into a breadboard or a TO‑92 package that resembles common transistors.

Below is a quick wiring diagram and the steps to get your Pi talking to the DS18B20.

Pinout (TO‑92)

Connect the sensor to the Pi as follows:

A 4.7 kΩ resistor must be placed between the data line (Pin 2) and the 3.3 V supply (Pin 3). If you don’t have a 4.7 kΩ resistor, two 2.2 kΩ resistors in series will work fine.

After wiring, power up the Pi. It’s a good idea to use a fresh SD card with the latest Raspberry Pi OS (formerly Raspbian). Download it from the official Raspberry Pi Software page.

Keep the system updated with:

sudo apt-get update && sudo apt-get upgrade

Next, enable the 1‑Wire interface by editing /boot/config.txt:

sudo nano /boot/config.txt

Add the following line at the end:

dtoverlay=w1-gpio,gpiopin=4

Save the file (Ctrl + X, Y, Enter) and reboot:

sudo reboot

Once the Pi restarts, the DS18B20 will appear in the /sys/bus/w1/devices directory. To read the temperature, use:

cat /sys/bus/w1/devices/28-xxxxxxxxxxxx/w1_slave

Replace 28-xxxxxxxxxxxx with the sensor’s unique ID.

For detailed documentation, refer to the DS18B20 datasheet and the official Raspberry Pi GPIO guide.

Manufacturing process

  1. The Thermometer: From Galileo’s Thermoscope to Modern Digital Sensors
  2. DS18B20 Temperature Sensor – Precise 1‑Wire Digital Thermometer for Industrial & Consumer Use
  3. Build a Raspberry Pi Temperature Logger with a $5 I2C Sensor
  4. Connect Multiple DS18B20 1‑Wire Sensors to a Raspberry Pi for Accurate Temperature Monitoring
  5. How to Read Temperature with a DS18B20 on Raspberry Pi 2
  6. Build a Remote Temperature Sensor with Raspberry Pi and Python – Step‑by‑Step Guide
  7. Reading a Linear Hall Sensor with Raspberry Pi: Java Guide & ADC0832 Insights
  8. Build a Multi‑Sensor Temperature & Light Monitoring System with Raspberry Pi & DS18B20
  9. Build a Raspberry Pi Home Temperature Monitor with MCP9808, InfluxDB & Grafana
  10. DS18B20 1-Wire Digital Temperature Sensor: Pinout, Key Features & Practical Applications