- Edited
I tried adding a DS18B20 based on this sample: https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/sensor/ds18b20/arduino_serial.overlay . It redirects to the DS18B20 docs (page 10) that these sensors can be interfaced via a serial interface: https://www.analog.com/media/en/technical-documentation/data-sheets/ds18b20.pdf . If it isn’t possible in any other way I would do it like that. But just using a regular pin would be preferable. For that I tried this:
ds18b20 {
compatible = "maxim,ds18b20";
gpios = <&gpio0 7 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH)>;
pinctrl-names = "default";
pinctrl-0 = <&ds18b20_pin>;
status = "okay";
};
fragment@0 {
target = <&gpio0>;
__overlay__ {
ds18b20_pin: ds18b20_pin {
brcm,pins = <7>;
brcm,function = <0>; // Input
brcm,pull = <2>; // Pull-up
};
};
};
But it is still not buildable. In the proj.conf I specifically added these settings:
# sensor config
CONFIG_SENSOR=y
CONFIG_GPIO=y
CONFIG_W1=y
I also was looking into interfacing multiple sensors, there I found some useful code: https://github.com/zephyrproject-rtos/zephyr/discussions/55743 but this also isn’t buildable. So now my overlay-file looks like this:
/ {
dht22 {
compatible = "aosong,dht";
status = "okay";
dio-gpios = <&gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
// dht22; // leave undefined to use dht11
};
// wire pins according to docs on pag 10 to rx and tx
// https://www.analog.com/media/en/technical-documentation/data-sheets/ds18b20.pdf
w1_0: w1-zephyr-serial-0 {
compatible = "zephyr,w1-serial";
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
testlabel: ds18b20 {
compatible = "maxim,ds18b20";
family-code = <0x28>;
resolution = <12>;
status = "okay";
};
testlabel2: ds18b202 {
compatible = "maxim,ds18b20";
family-code = <0x28>;
resolution = <12>;
status = "okay";
};
};
};
There I get the error: zephyr/include/zephyr/device.h:84:41: error: '__device_dts_ord_DT_N_S_w1_zephyr_serial_0_S_ds18b20_BUS_ORD' undeclared here (not in a function)
I’m pretty new to devicetrees. I was looking through the devicetree docs https://docs.zephyrproject.org/latest/build/dts/index.html but it’s so much information I don’t even know what would be the best place to start looking for solutions. Also the troubleshooting section: https://docs.zephyrproject.org/latest/build/dts/troubleshooting.html only vaguely says what the issue could be. For example in the generated zephyr.dts status="okay"
is set.