Close Menu
    Facebook X (Twitter) Instagram Pinterest YouTube
    Trending
    • Disable SSH Password Login on Raspberry Pi
    • Elecrow Meteor IPS Touchscreen with RGB LEDs
    • Pi Pico Pinout Display on the Command Line
    • How to Add a Raspberry Pi Pico Reset Button
    • Pi Pico Onboard LED
    • Pi Pico W Pinout and Power Pins
    • CrowPi L Raspberry Pi Laptop and Learning Platform
    • Pi Pico W Launched
    Mastodon YouTube Facebook Instagram Pinterest RSS
    Raspberry Pi SpyRaspberry Pi Spy
    • Home
    • Categories
      • General
      • Hardware
      • Programming
      • Python
      • Software
      • Tutorials & Help
    • BerryClip
      • BerryClip Instructions
      • BerryClip Plus Instructions
      • Videos & Reviews
    • Buy
      • Buy Pi
      • Buy Pi Accessories
      • Buy Books
    • Tools
      • Ultimate Raspberry Pi Alexa Skill
      • Pi Power Estimator App
      • Pi-Lite 14×9 LED Matrix Sprite Editor
      • RPiREF Pin-out Reference App
      • Simple Ohm’s Law Calculator
      • Web Sites & Links
    • Tutorials & Help
        Featured
        November 9, 20200

        Raspberry Pi Temperature Monitoring

        Recent
        February 16, 2024

        Disable SSH Password Login on Raspberry Pi

        December 23, 2022

        How to Add a Raspberry Pi Pico Reset Button

        November 20, 2022

        Pi Pico Onboard LED

      1. Contact Us
      2. Site Map
      Raspberry Pi SpyRaspberry Pi Spy
      You are at:Home»Hardware»Interfaces»1-wire»Enable 1-Wire Interface on the Raspberry Pi
      Raspberry Pi 2 Model B

      Enable 1-Wire Interface on the Raspberry Pi

      2
      By Matt on February 24, 2018 1-wire, Tutorials & Help

      The Raspberry Pi has a 1-wire bus which can be enabled on GPIO4. It provides low-speed data, signaling, and power over a single conductor.  This is commonly used on the Pi to connect low-cost sensors devices such as the DS18B20 temperature sensor.

      Step 1 – Enable 1-wire Interface

      The default Raspbian image disables the interface by default so before you can use it we must make a configuration change. This can be done using either of three methods. I’ll describe all methods but the first one is probably easier and quicker.

      Method 1 – Using “Raspi-config” on Command Line

      From the command line or Terminal window start by running the following command :

      sudo raspi-config

      This will launch the raspi-config utility. Select “Interfacing Options” :

      Raspi-Config - Interfacing

      Highlight the “1-wire” option and activate “<Select>” :

      Raspi-Config - Interfacing - 1-Wire

      Select and activate “<Yes>” :
      Raspi-Config - Interfacing - 1-Wire 1Highlight and activate “<Ok>” :

      Raspi-Config - Interfacing - 1-Wire 2

      When prompted to reboot highlight and activate “<Yes>” :

      Raspi-Config - Reboot Prompt

      The Raspberry Pi will reboot and the interface will be enabled ready for use.

      Method 2 – Using “Raspberry Pi Configuration”

      If your Pi boots to the desktop you can either open a Terminal window and use Method 2 or use the graphical tool “Raspberry Pi Configuration”. This is found under : Menu > Preferences > Raspberry Pi Configuration

      Raspberry Pi Configuration launch from menu

      Then you simply need to select the “Interfaces” tab and set 1-Wire to “Enabled” :

      Raspberry Pi Configuration - Interfaces Tab - 1-Wire

      Click the “OK” button. If prompted to reboot select “Yes” so that the changes will take effect.

      Raspberry Pi Configuration - Reboot Prompt

      The 1-Wire interface will be enabled when the Raspberry Pi has rebooted.

      Method 3 – Enabling By Editing A File Manually

      This process assumes you are using the latest Raspbian build from the official downloads page. You can update your current image using :

      sudo apt-get update
      sudo apt-get upgrade

      To enable the interface on the Pi we need to make a modification to a system file :

      sudo nano /boot/config.txt

      Add the following line at the bottom :

      dtoverlay=w1-gpio

      Use CTRL-X, then Y, then RETURN to save the file and exit.

      This will use Pin 7 (GPIO4) by default.

      Reboot using the following :

      sudo reboot

      Listing Attached 1-Wire Devices

      With the interface enabled you can list all discovered devices using the following command :

      ls /sys/bus/w1/devices/

      A full list of tutorials featuring this interface can be found by clicking here.

      Reading temperature with the popular DS18B20 temperature sensor is explained in the Using DS18B20 Digital Temperature Sensors with the Raspberry Pi post.

      Finally, there is more technical information about 1-Wire interfaces on the Wikipedia page if you are interested.

      Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
      Previous ArticleBasic Servo Use With the Raspberry Pi and GpioZero
      Next Article RC522 RFID Tag Reading with the Raspberry Pi

      Related Posts

      Disable SSH Password Login on Raspberry Pi

      How to Add a Raspberry Pi Pico Reset Button

      Pi Pico Onboard LED

      2 Comments

      1. Dennis Douglas on September 25, 2020 4:46 pm

        Can the 1-wire protocol be enabled for other GPIO pins? I have a project that has 18 DS18B20 probes mounted underground and now covered with cement. When I built the probe array, it worked fine but then–just before the array had to be placed in the ground, it began giving error values. In discussions with Maxim Integrated, it appears that the “star” configuration I was using was causing signal reflections to interfere with the read values. Breaking the “star” into three separate inputs would likely resolve the problem, but the literature suggests that only the Pi’s Pin 7 offers 1-wire. If I could use two other GPIO pins, I might be able to salvage the data I hope to gather….

        Reply
        • Matt on September 25, 2020 6:36 pm

          I think it is possible to enable the 1-wire protocol on more that one GPIO. If you edit the config.txt file you can add multiple overlay definitions. E.g.
          dtoverlay=w1-gpio,gpiopin=4 dtoverlay=w1-gpio,gpiopin=17

          Reply
      Leave A Reply Cancel Reply

      This site uses Akismet to reduce spam. Learn how your comment data is processed.

      Recent Posts
      February 16, 2024

      Disable SSH Password Login on Raspberry Pi

      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      December 23, 2022

      How to Add a Raspberry Pi Pico Reset Button

      November 20, 2022

      Pi Pico Onboard LED

      Categories
      • 1-wire
      • 3D Printing
      • Add-ons
      • BBC Micro:bit
      • BerryClip
      • Books
      • Camera Module
      • Cases
      • Events
      • General
      • Hardware
      • I2C
      • Infographics
      • Interfaces
      • Minecraft
      • Model A+
      • Model B+
      • News
      • Pi Models
      • Pi Pico
      • Pi Zero
      • Power
      • Programming
      • Python
      • Raspberry Pi OS
      • Raspbian
      • RetroGaming
      • Robotics
      • Sensors
      • Software
      • SPI
      • Tutorials & Help
      Tags
      Arduino audio battery berryclip Birthday bluetooth cambridge camera CamJam DigiMakers display games GPIO I2C interface Kickstarter Kodi LCD LED Linux media Minecraft Model A motionEyeOS PCB photography photos Pi-Lite Pi Pico power python Raspberry Jam Raspberry Pi Bootcamp raspbian Retrogaming retroPie screen SD card security sensor SPI SSH temperature ultrasonic video
      Raspberry PI Related
      • Adafruit Blog
      • Average Maker
      • Official RaspBerry Pi Site
      • Raspberry Pi Pod
      • RasPi.tv
      • RaspTut
      • Stuff About Code
      Tech Resources
      • MattsBits – Pi Resources
      • Microbit Spy
      • Technology Spy
      Archives

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2025 - All Rights Reserved - Matt Hawkins

      About

      Unofficial site devoted to the Raspberry Pi credit card sized computer offering tutorials, guides, resources,scripts and downloads. We hope to help everyone get the most out of their Pi by providing clear, simple articles on configuring, programming and operating it.

      Popular Posts
      September 19, 2014

      Top 5 Reasons The Raspberry Pi Sucks

      July 27, 2012

      16×2 LCD Module Control Using Python

      October 20, 2013

      Analogue Sensors On The Raspberry Pi Using An MCP3008

      Latest Posts
      February 16, 2024

      Disable SSH Password Login on Raspberry Pi

      March 13, 2023

      Elecrow Meteor IPS Touchscreen with RGB LEDs

      December 26, 2022

      Pi Pico Pinout Display on the Command Line

      Mastodon YouTube Instagram Facebook Pinterest RSS

      Entries RSS | Comments RSS

      This site is not associated with the official Raspberrypi.org site or the Raspberry Pi Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation.

      Copyright © 2025 - All Rights Reserved - Matt Hawkins

      mastodon.social@RPiSpy

      Type above and press Enter to search. Press Esc to cancel.