Multiple DS18B20 Thermometers on Single OneWire Bus

Hi Folks

I’m new here and liking the look of XOD.

My project uses multiple DS18B20 sensors connected to a OneWire bus, each one addressable using it’s unique OneWire address.

I have seen the XOD node to read a single DS18B20 but haven’t found a nodes (or nodes) that support my use case. Does anyone know if this is possible?

Many thanks.

Sorry for the bump. Just thought I’d try one more time to see if anyone has thoughts on this topic? Thanks for any guidance.

If it is possible with Arduino IDE, it is probably possible in XOD. That does not mean it will be easy…

If you can find existing nodes or library for one wire communication, that would be a good starting point, but I don’t know that there are any. If it is a simple protocol, you could code it yourself. If it is more complicated and there is an existing IDE library for it, it might be easier to write a XOD wrapper for the library (information about this on the XOD document page, but it is not trivial).

Many thanks for your reply @gweimer . It certainly is possible in the Arduino IDE and there are libraries for it. There is the ‘OneWire’ library for the bus itself and the ‘DallasTemperature’ library for the DS18B20 thermometers.

I’m not yet familiar with XOD to understand how it would handle/represent multiple devices connected to a bus (connected to a single Arduino pin) or how to handle the instantiation of the bus itself. I’ll give it a go when I get some time though.

I would start with a project that can be built using existing nodes and libraries to get a feel for XOD before trying to dive in and write your own nodes. When you are ready, the built-in i2c nodes can give you an idea how to organize and configure communication nodes that address multiple devices on a bus.

@spuj, I’ve just published a library for working with multiple DS18B20 thermometers on a single 1-wire bus:
https://xod.io/libs/wayland/ds18b20/

I followed the wiring instructions in this guide:

I have the waterproof version of the thermometers:
ds18b20
red = VDD
black = ground
yellow = signal

The first thing you need to do is determine the eight byte address of each of your thermometers. Connect just one of your thermometers and run the example-read-address patch in the debugger:
Screenshot 2020-09-11 at 18.01.15
Make a note of the eight byte address of your thermometer. Repeat process for each of your other thermometers. I label my thermometers so that I can match them to their addresses.

Once you know the addresses of all of your thermometers you can connect them all in parallel. To check that you can get a temperature reading from all thermometers, use patch example-read-temp-multi-devices:


The ds18b20-bus node represents the 1-wire bus connecting your thermometers. You can change the resolution of all thermometers on the bus using the set-resolution node. The request-temperatures node has to be pulsed before using the get-temp-c nodes to read each thermometer. You’ll obviously need a get-temp-c for each of your thermometers. get-temp-c output the temperature in degrees Celsius. If you prefer Fahrenheit you can use get-temp-f.

A note of caution: if any of the get-temp-c nodes output the value 85, check your wiring (see discussion here: https://www.raspberrypi.org/forums/viewtopic.php?t=63085). Initially I was using relatively heavy test leads in my circuit and I frequently got these erroneous 85 readings. After replacing the test leads with short dupont wires the dodgy readings disappeared. If a sensor becomes disconnected its get-temp-c will output -127.

2 Likes

Hi @wayland

I saw that XOD 0.35.1 is availabel include the fix for ds18b20.
If I upload those code ( example-read-temp-multi-devices) to an UNO it works perfect, but if I tried to do that with an DUE and I can’t compile your example.

I get this error:

C:\Users\MDHL\AppData\Local\Temp\xod_temp_sketchbookl42hxR\xod_1600187780038_sketch\xod_1600187780038_sketch.ino: In instantiation of ‘void xod::wayland__ds18b20__set_resolution::Node<typeof_DEV>::evaluate(xod::wayland__ds18b20__set_resolution::Node<typeof_DEV>::Context) [with typeof_DEV = DallasTemperature*; xod::wayland__ds18b20__set_resolution::Node<typeof_DEV>::Context = xod::wayland__ds18b20__set_resolution::Node<DallasTemperature*>::ContextObject*]’:
C:\Users\MDHL\AppData\Local\Temp\xod_temp_sketchbookl42hxR\xod_1600187780038_sketch\xod_1600187780038_sketch.ino:2176:37: required from here
C:\Users\MDHL\AppData\Local\Temp\xod_temp_sketchbookl42hxR\xod_1600187780038_sketch\xod_1600187780038_sketch.ino:1469:40: error: invalid conversion from ‘xod::identity<DallasTemperature*>::type {aka DallasTemperature*}’ to ‘uint8_t {aka unsigned char}’ [-fpermissive]
sensors->setResolution(getValue<input_DEV>(ctx));
^

In file included from C:\Users\MDHL\AppData\Local\Temp\xod_temp_sketchbookl42hxR\xod_1600187780038_sketch\xod_1600187780038_sketch.ino:1084:0:
C:\Users\MDHL\AppData\Local\Temp\xod_temp_sketchbookl42hxR\libraries\Arduino_Temperature_Control_Library/DallasTemperature.h:114:7: error: initializing argument 1 of ‘void DallasTemperature::setResolution(uint8_t)’ [-fpermissive]
void setResolution(uint8_t);

Hi @m-b,

Thanks for letting me know about the problem. There was an error in my set-resolution node. It’s fortunate that you received an error message when compiling for the DUE, because I did my testing on the Uno and the bug slipped through undetected. I’ve just published an updated version (0.4) of the library in which the bug is fixed.

1 Like

Many thanks @wayland this is just what I was looking for. I will give it a try later.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.