Problem DS18b20 with very long cable.

Can not find any in the data sheet from the maxim about the maximum length of cable (bus)
Trying to connect the multiple sensors on a bus, it runs fine up to 20 meters, but when the next 20 meters in length connected to stopping it. Have tested the two systems separately and it works fine …
DS18b20 is connected to Vcc (not parasitic mode) gnd and DQ are connected to one twisted pair (cat5). (Found the solution somewhere)

The resistance of 4.7 k is placed at one end of the bus, but wonder if there will be a resistance for each sensor ?

Would it be okay to let the two buses connected to each port ?
Will there be a comprehensive omprogramering ?

(A beginner who just came

Many questions in a thread.

Thank you in advance.

Has anyone tried solution with multiple inputs?

Can you define the bus several places in the program?

define ONE_WIRE_BUS 3

Or will the line be replaced with a variable?

Thank you:)

Can not find any in the data sheet from the maxim about the maximum length of cable (bus)

Guidelines for Reliable Long Line 1-Wire® Networks

My English is not good: (
I need 2 or preferably 3 cables with sensors. (Are problems with my 2 X 20 meters)

Can this program be rewritten so I can use 2 (or 3) I/O lines ( ex PORT 3, PORT4 and PORT5 to independent buses ) ?

You CAN....

Connect 3 DS18B20s to an Arduino by using three pins, and a ground connection.

You SHOULD... if not terribly difficult... use non-parasitic powering for the system....

However... if you don't mind working (much) harder on the software side, put 3 (or more) DS18B20s on a single pin of the Arduino. This means just 3 wires, instead of 5....

1-Wire data

You then get into the 1-Wire techniques of chip addressing. The three devices remain "quiet" until you send a "tell me the temperature" command out on the 1-Wire data line... but you have to say WHICH chip you are sending that command to.

The simpler technique, using 5 wires....

and a separate 1-Wire data wire to each chip

... works in a similar way, but as there is only one temperature sensor on each data wire, you can skip the addressing part.

(Much) more on 1-Wire at...

The solution I hope to do is that of the image.
But instead of relay using multiple Arduino pin.


Hope also again the program I use can be rewrite.
The program was taken from here

You’ll need to instantiate 3 separate instances of the one-wire object.

Untested, just duplicating lines inside my working 1-wire sketch, and adding alpha suffixes to the variable names.

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wires plugged into digital pins 2,3,4 on the Arduino
#define ONE_WIRE_BUSA 2
#define ONE_WIRE_BUSB 3
#define ONE_WIRE_BUSC 4

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWireA(ONE_WIRE_BUSA);
OneWire oneWireB(ONE_WIRE_BUSB);
OneWire oneWireC(ONE_WIRE_BUSC);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensorsA(&oneWireA);
DallasTemperature sensorsB(&oneWireB);
DallasTemperature sensorsC(&oneWireC);

Then you can read your sensors using the usual functions, e.g.


Of course, your code will be much neater if you define arrays for these. Hmmm. I’m not sure how the declaration would look for that. You’d want the equivalent of

int sensors[3];

Except int would be the DallasTemperature type, and I don’t know about doing that without the one-wire reference. I’m an okay C programmer, C++ not so much.

nice, thanks :slight_smile: