Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:xu4_hardware_1wire [2017/07/13 13:42] ck.kim created |
en:xu4_hardware_1wire [2017/07/17 10:48] (current) luke.go |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Dallas 1-Wire Support ====== | ====== Dallas 1-Wire Support ====== | ||
- | * Support for Dallas 1 Wire is included on Kernel 3.14.29-29 and upwards. Make sure you are updated. | + | * Support for Dallas 1 Wire is included on Kernel 4.9.34 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. | * 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 #26 XE.INT16 (GPX2.0)** | ||
<WRAP left round tip 70%> | <WRAP left round tip 70%> | ||
- | You have to check **/etc/modprobe.d/w1_gpio.conf** file to enable the 1-wire driver. | + | XU3 / XU4 CON10(30 pin) All GPIO and AIN pins use VDD_IO (1.8V) for the signals. \\ |
+ | So the level converter is required to connect the sensor. | ||
+ | |||
+ | Hardkernel Shifter-Shield is not working well with multiple 1-wire devices due to a timing issue.\\ | ||
+ | So we used Sparkfun [[https://www.sparkfun.com/products/12009|Level converter board]] | ||
</WRAP> | </WRAP> | ||
- | \\ | ||
- | \\ | ||
- | \\ | ||
\\ | \\ | ||
\\ | \\ | ||
\\ | \\ | ||
- | Default GPIO for 1-Wire is **Pin #7 (GPIOX.BIT21)** | + | {{:en:1-wire_with_level_converter.png?750|}} |
+ | * **Connection: Level converter** | ||
+ | CON10 Pin 1 (P5V0): Level converter HV \\ | ||
+ | CON10 Pin 2 (GND): Level converter GND \\ | ||
+ | CON10 Pin 29 (VDD_IO): Level converter LV \\ | ||
+ | CON10 Pin 30 (GND): Level converter GND \\ | ||
+ | CON10 Pin 26 (XE.INT16): Level converter LV1 \\ | ||
+ | Sensor signal : Level converter HV1 \\ | ||
+ | {{:en:level_shifter.jpg?nolink|}} | ||
* **Connection: With External-Supply** | * **Connection: With External-Supply** | ||
{{:en:1-wire-external-power.png?750|}} | {{:en:1-wire-external-power.png?750|}} | ||
- | Pin 1 (Left): Ground (-) | + | Pin 1 (Left): Ground (-) \\ |
- | + | Pin 2 (Middle): Level converter HV1 \\ | |
- | Pin 2 (Middle): Pin #7 C2 (GPIOX.BIT21) | + | Pin 3 (Right): VCC (3.3V) \\ |
- | + | ||
- | Pin 3 (Right): VCC (3.3V) | + | |
You also need to add a resistor from 4.7k to 10k between pin 2. | You also need to add a resistor from 4.7k to 10k between pin 2. | ||
Line 30: | Line 40: | ||
{{:en:1-wire-parasite-power.png?750|}} | {{:en:1-wire-parasite-power.png?750|}} | ||
- | Pin 1 (Left): Ground (-) | + | Pin 1 (Left): Ground (-) \\ |
- | + | Pin 2 (Middle): Level converter HV1 \\ | |
- | Pin 2 (Middle): Pin #7 C2 (GPIOX.BIT21) | + | Pin 3 (Right): Ground (-) \\ |
- | + | ||
- | Pin 3 (Right): Ground (-) | + | |
You also need to add a resistor from 4.7k to 10k between pin 2. | You also need to add a resistor from 4.7k to 10k between pin 2. | ||
* Load the required kernel modules: <code>modprobe w1-gpio && modprobe w1-therm</code> | * Load the required kernel modules: <code>modprobe w1-gpio && modprobe w1-therm</code> | ||
- | * Check if your sensor is working: <code>odroid@odroid64:~$ cd /sys/bus/w1/devices/ | + | * Check if your sensor is working: <code> |
- | odroid@odroid64:/sys/bus/w1/devices# ls | + | odroid@odroid:~$ cd /sys/bus/w1/devices/ |
- | 10-000802f41d67 w1_bus_master1 | + | odroid@odroid:/sys/bus/w1/devices$ ls |
- | odroid@odroid64:/sys/bus/w1/devices#</code> | + | 10-000802f3be04 w1_bus_master1 |
+ | odroid@odroid:/sys/bus/w1/devices$ | ||
+ | </code> | ||
- | As you can see my sensor is detected as **10-000802f38c57**, each sensor has a different id. So yours will be different. | + | As you can see my sensor is detected as **10-000802f3be04**, each sensor has a different id. So yours will be different. |
- | * Read the temperature: | + | * Read the temperature: <code> |
- | <code> | + | odroid@odroid:/sys/bus/w1/devices$ cd 10-000802f3be04 |
- | odroid@odroid64:/sys/bus/w1/devices$ cd 10-000802f38c57 | + | odroid@odroid:/sys/bus/w1/devices/10-000802f3be04$ cat w1_slave |
- | odroid@odroid64:/sys/bus/w1/devices/10-000802f38c57# cat w1_slave | + | 37 00 4b 46 ff ff 06 10 da : crc=da YES |
- | 33 00 4b 46 ff ff 03 10 30 : crc=30 YES | + | 37 00 4b 46 ff ff 06 10 da t=27375 |
- | 33 00 4b 46 ff ff 03 10 30 t=25562 | + | odroid@odroid:/sys/bus/w1/devices/10-000802f3be04$ |
- | odroid@odroid64:/sys/bus/w1/devices/10-000802f38c57# | + | |
</code> | </code> | ||
- | Temperature is t=25562 or 25.562 degree's Celsius. | + | Temperature is t=27375 or 27.375 degree's Celsius. |
Line 63: | Line 72: | ||
<code> | <code> | ||
- | odroid@odroid64:/sys/bus/w1/devices# ls | + | odroid@odroid:/sys/bus/w1/devices$ ls |
- | 10-000802f38c57 10-000802f41d67 w1_bus_master1 | + | 10-000802f384e2 10-000802f3be04 w1_bus_master1 |
+ | odroid@odroid:/sys/bus/w1/devices$ | ||
</code> | </code> | ||
Two sensors in parallel. | Two sensors in parallel. | ||
- | |||
- | ====== Change the Default GPIO pin for 1-Wire interface ====== | ||
- | Ex) Default GPIO pin change to GPIOX.BIT19 \\ | ||
- | Please refer to below links for details related to gpio mapping in the device-tree.\\ | ||
- | [[https://github.com/hardkernel/linux/blob/odroidc2-3.14.y/include/dt-bindings/gpio/gxbb.h | C2 gpio mapping in the device-tree]] \\ | ||
- | |||
- | <code> | ||
- | odroid@odroid64:~$ sudo apt-get install device-tree-compiler | ||
- | odroid@odroid64:~$ fdtget /media/boot/meson64_odroidc2.dtb /onewire gpios | ||
- | 18 113 0 | ||
- | odroid@odroid64:~$ fdtput /media/boot/meson64_odroidc2.dtb /onewire gpios 18 111 0 | ||
- | odroid@odroid64:~$ fdtget /media/boot/meson64_odroidc2.dtb /onewire gpios | ||
- | 18 111 0 | ||
- | odroid@odroid64:~$ sudo reboot | ||
- | </code> | ||
- | 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, 18(0x12) is the GPIO group number.** | ||
- | |||
- | DS1820 is connected to Pin #11 | ||
- | |||
- | Pin 1 (Left): Ground (-) | ||
- | |||
- | Pin 2 (Middle): Pin #11 C2 (GPIOX.BIT19) | ||
- | |||
- | Pin 3 (Right): Ground (-) | ||