1-Wire

One Wire
1-Wire is a device communications bus system designed by Dallas Semiconductor that provides low-speed data, signaling, and power over a single signal. 1-Wire is similar in concept to I²C, but with lower data rates and longer range. It is typically used to communicate with small inexpensive devices such as digital thermometers and weather instruments. A network of 1-Wire devices with an associated master device is called a MicroLan.

Linux kernel 3.4
Edit the script.fex file and set the gpio pin for 1-wire bus



[gpio_para] gpio_used = 1 gpio_num = 67 gpio_pin_1 = port:PG03<1> <1> .... gpio_pin_66 = port:PB10<1> <1>

[w1_para] gpio = 66

Connect the data pin of devices to gpio pin PB10 and in sys folder you have

/sys/bus/w1/devices/ 28-000004bfae30 28-000004c022c5

what are connect 2 DS18B20 devices

cat /sys/bus/w1/devices/28-000004bfae30/w1_slave 45 01 4b 46 7f ff 0b 10 84 : crc=84 YES 45 01 4b 46 7f ff 0b 10 84 t=20312

the temp is 20.312 °C

Read Data Sensor
simple bash script for read 1-wire temp sensor




 * 1) !/bin/bash

file="/sys/bus/w1/devices/28-000004bfae30/w1_slave" function find{ "$1" =~ "$2" && true || false }

while : do DATE=$(date +"%d-%m-%Y-%H:%M:%S") #read device CRC=false while read curline; do		#check crc if( find "$curline" "crc" && find "$curline" "YES" ) then CRC=true DEVICE=`echo $curline|cut -d':' -f 1` fi if($CRC && find "$curline" "t=") then TEMP=`echo $curline|cut -d'=' -f 2` echo $DEVICE ";" $DATE ";" `echo "scale=3;$TEMP/1000"|bc -l` fi done <$file sleep 10 done

Linux Kernel Mainline
Work in progress !!!!!!!!!!!!!!!!

Device Tree
example dt for beaglebone, adapt to sunxi Work in progress !!!!!!!!!!!!!!!!

 /dts-v1/; /plugin/;

/ {   compatible = "ti,beaglebone", "ti,beaglebone-black"; part-number = "BB-W1"; version = "00A0";

exclusive-use = "P9.15", "gpio1_16"; fragment@0 { target = <&am33xx_pinmux>; __overlay__ { bb_w1_pins: pinmux_bb_w1_pins { pinctrl-single,pins = < 0x040 0x37 /*pin P9_15 input with pullup mode 7  - w1-gpio */ >;            };        };    };

fragment@1 { target = <&ocp>; __overlay__ { onewire@0 { status         = "okay"; compatible     = "w1-gpio"; pinctrl-names  = "default"; pinctrl-0      = <&bb_w1_pins>;

gpios = <&gpio2 16 0>; /*grrr I think this means gpio1_16 (using 1 to 4 instread of 0-3)*/ };       };    }; };