Dallas 1-Wire Support

  • Support for Dallas 1 Wire is included on Kernel 4.9.141 and upwards. Make sure you are updated.
  • Will cover an example of a temperature sensor well known DS1820 other 1 wire IC's are supported too.

Default GPIO for 1-Wire is Pin #7 (GPIOA.BIT13)

  • Connection: With External-Supply

Pin 1 (Left): Ground (-)

Pin 2 (Middle): Pin #7 N2 (GPIOA.BIT13)

Pin 3 (Right): VCC (3.3V)

You also need to add a resistor from 4.7k to 10k between pin 2.

  • Connection: Supplying the Parasite-Powered

Pin 1 (Left): Ground (-)

Pin 2 (Middle): Pin #7 N2 (GPIOA.BIT13)

Pin 3 (Right): Ground (-)

You also need to add a resistor from 4.7k to 10k between pin 2.

  • To enable the 1wire bus, you need to modify the DT(Device Tree) file.
  • Install required packages.
    root@odroid:~$ sudo apt-get install device-tree-compiler
  • Make a backup of DTB file.
    root@odroid:~$ cp /media/boot/meson64_odroidn2.dtb /media/boot/meson64_odroidn2.dtb.org
  • Change the DTB file for 1wire bus
    root@odroid:~$ fdtget /media/boot/meson64_odroidn2.dtb /onewire status
    disabled
    root@odroid:~$ fdtput -t s /media/boot/meson64_odroidn2.dtb /onewire status "okay"
    root@odroid:~$ fdtget /media/boot/meson64_odroidn2.dtb /onewire status
    okay
    root@odroid:~$ 
  • When the DTB modification is finished, reboot.
    root@odroid:~$ reboot
  • Check if your sensor is working:
    root@odroid:~$ lsmod
    w1_therm               16384  0
    w1_gpio                16384  0
    wire                   45056  2 w1_gpio,w1_therm
    root@odroid:~$ cd /sys/bus/w1/devices
    root@odroid:/sys/bus/w1/devices# ls
    10-000802f38c57 w1_bus_master1
    root@odroid:~$

    As you can see my sensor is detected as 10-000802f38c57, each sensor has a different id. So yours will be different.

  • Read the temperature:
    root@odroid:/sys/bus/w1/devices$ cd 10-000802f38c57
    root@odroid:/sys/bus/w1/devices/10-000802f38c57# cat w1_slave
    33 00 4b 46 ff ff 03 10 30 : crc=30 YES
    33 00 4b 46 ff ff 03 10 30 t=25562
    root@odroid:/sys/bus/w1/devices/10-000802f38c57#

Temperature is t=25562 or 25.562 degree's Celsius.

  • Multiple sensors can be connected on the same line as the draw below.

odroid@odroid64:/sys/bus/w1/devices# ls
10-000802f38c57  10-000802f41d67  w1_bus_master1

Two sensors in parallel.

Change the Default GPIO pin for 1-Wire interface

Ex) Default GPIO pin change to GPIOX.BIT3
Please refer to below links for details related to gpio mapping in the device-tree.
N2 gpio mapping in the device-tree

root@odroid:~$ fdtget /media/boot/meson64_odroidn2.dtb /onewire gpios
25 63 0
root@odroid:~$ fdtput /media/boot/meson64_odroidn2.dtb /onewire gpios 25 69 0
root@odroid:~$ fdtget /media/boot/meson64_odroidn2.dtb /onewire gpios
25 69 0
root@odroid:~$ reboot

If the reboot doesn't affect the dtb update, you need a hard reset(power off/on).

Use the first number in the fdtget command output when you run fdtput command.
For example, 25(0x19) is the GPIO group number.

DS1820 is connected to Pin #11

Pin 1 (Left): Ground (-)

Pin 2 (Middle): Pin #11 N2 (GPIOX.BIT3)

Pin 3 (Right): Ground (-)