Up 1-wire の有効化 作成: 2021-03-24
更新: 2021-03-24


  • 1-wire 用ピンは,デフォルトで GPIO4 (7番ピン)
    $ cat /boot/overlays/README
     ‥‥ Name: w1-gpio Info: Configures the w1-gpio Onewire interface module. Use this overlay if you *don't* need a GPIO to drive an external pullup. Load: dtoverlay=w1-gpio,<param>=<val> Params: gpiopin GPIO for I/O (default "4") pullup Now enabled by default (ignored) Name: w1-gpio-pullup Info: Configures the w1-gpio Onewire interface module. Use this overlay if you *do* need a GPIO to drive an external pullup. Load: dtoverlay=w1-gpio-pullup,<param>=<val> Params: gpiopin GPIO for I/O (default "4") extpullup GPIO for external pullup (default "5") pullup Now enabled by default (ignored)  ‥‥


  • 1-Wire を有効に設定
    1-Wire は,デフォルトでは有効化が設定されていない: $ cat /boot/config.txt | grep w1 (w1 を含む行は無し)
    $ sudo raspi-config
      → 5 Interfacing Options
      → P7 1-Wire
      → "Would you like the one-wire interface to be enabled?" に対し <Yes>
      → "The one-wire interface is enabled" に対し <Ok>
      → "The one-wire interface is enabled" に対し <Ok>
      → raspi-config を<Finish>
      → "Would you like to reboot now?" に対し <Yes>


  • 1-Wire が有効になったことを確認:
    $ cat /boot/config.txt
    最終行が,つぎになっている:
      dtoverlay=w1-gpio

    $ lsmod  ‥‥ w1_gpio 16384 0 wire 45056 1 w1_gpio  ‥‥ $ ls -la /sys/bus/w1/devices lrwxrwxrwx 1 root root 0 Mar 24 19:30 28-3c01a816532c -> ../../../devices/w1_bus_master1/28-3c01a816532c lrwxrwxrwx 1 root root 0 Mar 24 19:30 w1_bus_master1 -> ../../../devices/w1_bus_master1 $ cd /sys/devices/w1_bus_master1/28-3c01a816532c $ ls -la lrwxrwxrwx 1 root root 0 Mar 24 19:30 driver -> ../../../bus/w1/drivers/w1_slave_driver drwxr-xr-x 3 root root 0 Mar 24 19:30 hwmon lrwxrwxrwx 1 root root 0 Mar 24 19:30 subsystem -> ../../../bus/w1 -rw-r--r-- 1 root root 4096 Mar 24 19:30 uevent

  • 1-Wire 用ピン (デフォルト: GPIO4) を GPIOn ピンを変更するときは,/boot/overlays/README の指示通りに,/boot/config.txt の「dtoverlay=w1-gpio」の行をつぎに書き換える:
      dtoverlay=w1-gpio,gpiopin=n