Multiple DS18B20 temperature sensor issues

Hello

I'm having issues with a setup where I'm trying to read 5x DS18B20 temperature sensors. I'm pretty sure this isn't a code issue, but here's the basics.

// sensor addresses
DeviceAddress sensorAddr[5] = {
  {0x28, 0x2D, 0x56, 0x46, 0x92, 0x02, 0x02, 0x48},
  {0x28, 0x40, 0x5B, 0x79, 0x97, 0x08, 0x03, 0x73},
  {0x28, 0xA6, 0x94, 0x79, 0x97, 0x07, 0x03, 0xBD},
  {0x28, 0xD6, 0x69, 0x79, 0x97, 0x05, 0x03, 0xFE}, 
  {0x28, 0x24, 0x08, 0x77, 0x91, 0x01, 0x02, 0x9F}
};
// Data wire for temperature sensors
#define ONE_WIRE_BUS 13
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);
// get temps
sensorActualCount = 0; 
sensors.requestTemperatures();
for (int i = 0; i < sensorCount; i++) {
  temps[i] = sensors.getTempC(sensorAddr[i]);
  if (temps[i] > -127) {sensorActualCount++;}
}

All of the sensors are connected in a star topology to anArduino Uno Wifi Rev 2 with a 4.7k pullup resistor. The reason I've added the sensor addresses is because it's important to know which sensor is which if one of them cannot be read for some reason.

I have used high quality cat5e cable as follows :-

  • Brown - W/Brown - GND
  • Orange - W/Orange - +5V
  • Blue - Data

Approximate lengths of cable are as follows :-

  • Sensor 1 - 3m
  • Sensor 2 - 2m
  • Sensor 3 - 7m
  • Sensor 4 - 11m
  • Sensor 5 - 15m

The issue I have is that when a 5th sensor is connected, I lose the data for all of the sensors. Usually, the readings are all 0. I've tried various combinations, sometimes adding the 4th sensor in to mix kills the sensor readings. I thought it was the longest cable causing the issues but it's not. e.g. if I start at sensors 5 and work backwards, sensor 1 ends up killing the readings.

I have checked this link regarding long cable lengths and I understand that it doesn't recommend a star topology but I have no choice in this setup. I simply want to understand the electronics side of things and try and resolve the issue on the setup I already have.

Am I using the incorrect resistor value for this type of setup? Do I need to add other resistors to the endpoints near the sensors?

Appreciate any help and if I've missed anything out that anyone feels is relevant please let me know and I'll supply the information.

Thanks,

Matt

We always prefer a working sketch: https://snippets-r-us.com/.

3 + 2 + 7 + 11 + 15 = a lot

You can compensate for the capacitance with a lower value for the pullup resistor. It is in that link you gave.
According to the datasheet, the DS18B20 can sink at least 4.0 mA.
5V / 4mA = 1250 Ω
You can try 2k2, but I suggest to use 1k5 and if that works, keep the 1k5.

Some add a capacitor at 5V and GND at the ends of each cable to dampen the noise.

djmattc:
. . .

I have used high quality cat5e cable as follows :-

  • Brown - W/Brown - GND
  • Orange - W/Orange - +5V
  • Blue - Data

. . .

Try using Blue - W/Blue for your GND to take advantage of the twisted pair for your data.

EDIT: I messed that one up: Try using W/Blue for your GND to take advantage of the twisted pair for your data.

Don

And .....Check each of the sensors work on their own, separately , in case one is a dud .
If running a star network , you could also try two separate networks and splitting your devices between them

hammy:
you could also try two separate networks and splitting your devices between them

O, that's it !
@djmattc, create a 1-Wire bus on more pins. For example five 1-Wire busses. One for each section. Search the forum for "multiple OneWire busses" to find examples.

Thanks everyone!

I've tried a 2K resistor and all of the sensors pick up a value. However, some odd readings start happening on one of the sensors (about 10C higher than actual) after a few seconds.

I've attempted the multiple OneWire bus before I came to the forums but couldn't get it to work correctly. I'm sure this was user error so I'm going to search for "multiple OneWire busses" as recommended then report back with an update.

My tips for reliable DS18B20 bus:

  1. Don't use parasite power if possible, its much less robust.

  2. Use the standard multidrop connection, not a star network, 4k7 pullup at each end of the bus, add a 100nF decoupling capacitor between Vcc and ground at each sensor and a 100 ohm series resistor between Arduino pin and the bus.

  3. Do not connect the bus ground to anything except the Arduino, sensors and decoupling caps

That should maximum the chance of good signaling. Ideally use twin-core shielded cable, or two twisted pairs (signal+ground, 5V+ground). Ribbon cable can work if the signal wire is sandwiched between two ground wires
to shield it.

I've had a 20 sensor network working 24/7 without error following these rules.

Thanks MarkT.

If I have to use a star network (due to current cabling already in place), would you still recommend the 100nF capacitor and 100ohm resistors?

MarkT:
2) Use the standard multidrop connection, not a star network, 4k7 pullup at each end of the bus, add a 100nF decoupling capacitor between Vcc and ground at each sensor and a 100 ohm series resistor between Arduino pin and the bus.

What is the purpose of the 100 ohm resistor in series?

Its a crude hack to minimize reflections on the ~100 ohm transmission line. On a long cable reflections back and forth can cause multiple-clocking (OneWire is probably fairly immune to this, but it can't hurt).