I try to read a DS18B20 with a BeagleBone (BB green wireless) and encountered some problems with the device tree after switching to the latest available Debian version for BB.
I will describe the steps to make it with the default version first, the main problem description see the second posting
Wiring
BeagleBone -- DS18B20
----------------------------
P9.01 DGND -- GND
P9.03 VDD 3.3 V -- Vcc
P9.12 GPIO1_28 -- Data
and a 4K7 resistor between Vcc
and Data
Device Tree
I found this tutorials and device tree examples:
- device tree: DS18B20 With BeagleBone: Easy One-wire Interface Temperature Monitoring – Bone BrewsDS18B20 With BeagleBone: One-wire interface temperature monitoring
- or BBB and OneWire - Klaus' wiki
so I did
cd /lib/firmware
nano DS1820-00A0.dts
DS1820-00A0.dts
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";
part-number = "DS1820";
version = "00A0";
exclusive-use = "P9.12";
fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
ds1820_pins: pinmux_ds1820_pins {
pinctrl-single,pins = <0x78 0x37>;
};
};
};
fragment@1 {
target = <&ocp>;
__overlay__ {
onewire@0 {
status = "okay";
compatible = "w1-gpio";
pinctrl-names = "default";
pinctrl-0 = <&ds1820_pins>;
gpios = <&gpio1 28 0>;
};
};
};
};
First trial with Linux beaglebone 4.4.x
Linux beaglebone 4.4.9-ti-r25
In the Tutorial …
… you should build the tree with
sudo dtc -O dtb -o /lib/firmware/DS1820-00A0.dtbo -b 0 -@ DS1820-00A0.dts
and enable this part of the device tree (at every boot) with this command
sudo echo DS1820 > /sys/devices/bone_capemgr.*/slots
Problems and Solution
but
echo DS1820 > /sys/devices/bone_capemgr.*/slots
leds to
-bash: /sys/devices/bone_capemgr.*/slots: No such file or directory
seems that bone_capemgr is no loger in /sys/devices/
but in /sys/devices/platform/
So I tried /sys/devices/platform/bone_capemgr/slots
echo DS1820 > /sys/devices/platform/bone_capemgr/slots
Becauso of permission problems I tried it with sudo echo ...
with no success, but after switching to root it seems to work:
debian@beaglebone:/sys/devices/platform/bone_capemgr$ sudo su
root@beaglebone:/sys/devices/platform/bone_capemgr# echo DS1820 > /sys/devices/platform/bone_capemgr/slots
root@beaglebone:/sys/devices/platform/bone_capemgr#
You can see the successful change at
root@beaglebone:/sys/devices/platform/bone_capemgr# cat slots
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,DS1820
Now you should find the devices at
/sys/bus/w1/devices/
Minor (?) problem: Hmm, something went wrong, no real sensor ID in the form 28-0000065e9caf
there! I noticed in the tutorials that they wrote in the text GPIO1_28 but used in the code gpios = <&gpio2 28 0>;
So I changed in the dts file gpios = <&gpio1 28 0>;
After a reboot and the procedure above I got the sensor showing up: Yeah!!
debian@beaglebone:/sys/bus/w1/devices$ ls
28-0000065e9caf w1_bus_master1
And I can read the temperature with
debian@beaglebone:/sys/bus/w1/devices/28-0000065e9caf$ cat w1_slave
80 01 4b 46 7f ff 10 10 c6 : crc=c6 YES
80 01 4b 46 7f ff 10 10 c6 t=24187
What means that we have 24.2 °C!