DS18B20 on long cable return wrong temp values

Hello,

  1. Arduino Mega2560
  2. DS18B20
  3. UTP cat5e 28AWG twisted pair cable (50meters)
  4. 2.2k pullup resistor
  5. Non-parasitic mode. 2 pairs used. data line paired with ground.

Sensor return wrong temp value over this long cable (+13.5C instead of +7C actual (checked with 2 other thermometers)

May long cable affect temp accuracy and results?

d187:
May long cable affect temp accuracy and results?

It shouldn't. The data are digital. But, you cable is adding capacitance to the data line. See https://www.allaboutcircuits.com/technical-articles/i2c-design-mathematics-capacitance-and-resistance/ for more information.

The I2C spec allows for the data line to have a maximum of 400pF to ground. You don't show your wiring, but if the data is in a twisted pair with ground, then your data is likely being corrupted.

The capacitance of CAT-5E is 52pF per meter, so at 50-meters the cable will add way more than the 400pF max, so I2C should deliver erratic data.

It certainly can but it would appear that you already know that and seem to be doing all the right things.

I do wonder if it would be simpler to just use the cable for power, and send the data back by wireless, via ESP-01.

If you're using the DS18B20 parasitic power mode, I'd strongly recommend supplying 5 V to the DS18B20 via another twisted pair of your cable (both ground wires connected at both ends).

I'd try also using a 2.4 k Ohm pullup at both the Arduino and DS18B20 at both ends of the cable.

Sensor return wrong temp value over this long cable (+13.5C instead of +7C actual (checked with 2 other thermometers)

This is unusual; the data is digital, as mentioned.

If you read the data 100 times is it consistent, or changing values??

Does a local-connected DS18B20 give right results with exact same code???

Let us know!

[LOTS of DS18B20 info here: Brick-Temperature-DS18B20 - ArduinoInfo

terryking228:
This is unusual; the data is digital, as mentioned.

Yes, expected -127 and I'm getting it occasionally.

terryking228:
If you read the data 100 times is it consistent, or changing values??

Here is a log for last 2 hours (10 mins interval):
13.19
13.63
13.75
13.94
14.19
14.25
13.63
14.00
13.06
12.94
12.81
13.88
13.56
14.19
(actual air temp is around +7 (+-0.5)

terryking228:
Does a local-connected DS18B20 give right results with exact same code???

Yes, I confirm, that I checked the sensor connected directly to arduino without long cable, but with 4.7k pullup and it was working well.

I read a lot on various Arduino forums regarding DS18 running on long cables.
I've read to:
a) avoid parasitic mode
b) use twisted pair cat5e (5vcc/ground, data/ground pairs)
c) use 2k pullup resistor on Arduino side

I didn't read about DS18 shifting result by some value.. Strange. Shound't it just return -127?

Sensors are from China, not original from from MAxim.

Hold the sensor in my hand which warmed up to 27C. And then returned to 13-14C back after some time. So there is some type of value shift..

Sensors are from China, not original from from MAxim.

Try using the genuine item instead.

Data are digital and there is a checksum so I have strong doubts that the problem is in a cable. No way. It is something with a sensor.
Try another sensor and the best is the genuine one as was mentioned.

d187:
I read a lot on various Arduino forums regarding DS18 running on long cables.
I've read to:
a) avoid parasitic mode
b) use twisted pair cat5e (5vcc/ground, data/ground pairs)
c) use 2k pullup resistor on Arduino side

I didn't read about DS18 shifting result by some value.. Strange. Shound't it just return -127?

Sensors are from China, not original from from MAxim.

B is incorrect. Don't use the pairs as pairs. Put the same signal on both paired wires. 5V/5V, Gnd/Gnd and Data/Data.

For C, it is not totally wrong but I would expect better performance with the correct 4.7K pullup close to the sensor. But usually you have many sensors on one cable so you can't do that.

Yes, you would expect a checksum error (-127) instead of an erroneous value. Maybe something else is wrong?