odroid-c4:application_note:gpio:1wire

Dallas 1-Wire Support

  • 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 #15 (ODROID-N2 / C4 - GPIOX.BIT7 ODROID-M1 - GPIO3.B2)

  • Connection: With External-Supply

Pin 1 (Left): Ground (-)

Pin 2 (Middle): Pin #15 N2/C4: (GPIOX.BIT7) M1: (GPIO3.B2)

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 #15 N2/C4: (GPIOX.BIT7) M1: (GPIO3.B2)

Pin 3 (Right): Ground (-)

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

  • If you use the kernel version more than 4.9.230(N2/C4), you should edit /media/boot/config.ini file to enable 1-wire by adding onewire to overlays variable.
  • If you use the kernel version more than 5.15.x (N2/C4), or use ODROID-M1, you should only edit /boot/config.ini file to enable 1-wire by adding onewire to overlays variable.
; Device Tree Overlay
overlay_resize=16384
overlay_profile=myproject
overlays=""
 
[overlay_myproject]
overlays="onewire"
  • Check if your sensor is working:
    target
    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:
    target
    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.

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

Two sensors in parallel.

2020/03/19 15:43 · luke.go
  • odroid-c4/application_note/gpio/1wire.txt
  • Last modified: 2020/04/23 16:07
  • by luke.go