Hello,
I am currently working on a project using the nRF52840 DK, where I am trying to connect multiple DS18B20 temperature sensors to a single One-Wire bus. I am using Zephyr OS 3.5.99 for this project.
Here is the relevant part of my Device Tree configuration:
&arduino_serial {
status = "okay";
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";
};
};
};
When I compile, I receive the following error: <err> DS18B20: ROM required, because multiple slaves are on the bus
Here is the C code I am using to interact with the sensors:
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/sensor.h>
static const struct device *get_ds18b20_device(void) {
const struct device *const dev = DEVICE_DT_GET_ANY(maxim_ds18b20);
if (dev == NULL) {
printk("\nError: no device found.\n");
return NULL;
}
if (!device_is_ready(dev)) {
printk("\nError: Device \"%s\" is not ready; check the driver initialization logs for errors.\n", dev->name);
return NULL;
}
printk("Found device \"%s\", getting sensor data\n", dev->name);
return dev;
}
int main(void) {
const struct device *dev = get_ds18b20_device();
if (dev == NULL) {
return 0;
}
while (1) {
struct sensor_value temp;
sensor_sample_fetch(dev);
sensor_channel_get(dev, SENSOR_CHAN_AMBIENT_TEMP, &temp);
printk("Temp: %d.%06d\n", temp.val1, temp.val2);
k_sleep(K_MSEC(2000));
}
return 0;
}
I'm struggling to incorporate the readings from both sensors into a single output. I am a beginner, so I would appreciate any help or guidance on how to resolve these issues.
Thank you!