DS18B20 won't work with 10m cable

Hello, I have 3 temperature sensors, model DS28B20
When I connect the sensors straight to the ESP32 board, temperature are read correct.
my application needs to read to temperature from 10 m away. I used a cable of 10m of 3x0,22 with both sensors connected at the end.
unfortunately, I do not receive any temperature, sensors are unavailable,

21:29:47][W][dallas.sensor:261]: ‘Temperature #1’ - Scratch pad checksum invalid!
[21:29:47][D][sensor:094]: ‘Temperature #1’: Sending state nan °C with 1 decimals of accuracy
[21:29:47][W][dallas.sensor:261]: ‘Temperature #2’ - Scratch pad checksum invalid!
[21:29:47][D][sensor:094]: ‘Temperature #2’: Sending state nan °C with 1 decimals of accuracy
[21:29:47][W][dallas.sensor:261]: ‘Temperature #3’ - Scratch pad checksum invalid!
[21:29:47][D][sensor:094]: ‘Temperature #3’: Sending state nan °C with 1 decimals of accuracy
[21:30:47][W][dallas.sensor:261]: ‘Temperature #1’ - Scratch pad checksum invalid!
[21:30:47][D][sensor:094]: ‘Temperature #1’: Sending state nan °C with 1 decimals of accuracy
[21:30:47][W][dallas.sensor:261]: ‘Temperature #2’ - Scratch pad checksum invalid!
[21:30:47][D][sensor:094]: ‘Temperature #2’: Sending state nan °C with 1 decimals of accuracy
[21:30:47][W][dallas.sensor:261]: ‘Temperature #3’ - Scratch pad checksum invalid!
[21:30:47][D][sensor:094]: ‘Temperature #3’: Sending state nan °C with 1 decimals of accuracy



What do you think is the problem and solution?

Have you measured the VCC/GND voltage where the sensor is located? Perhaps you have too much of a drop at that distance?

I have not measure it. Anyway, is there any possibility to measure the temperature on a 10m wire ?

It’s a digital signal, so I would think it would be fine, but I’ve also never used one of those sensors.

For what it’s worth, the Adafruit listing explicitly says it works well for long distance runs:

What pullup resistor are you using? For short runs, 4k7 is usually OK. For longer runs try 3k3 or 2k2.

As i use the adaptor for connecting to the ESP, it has 4k7. Could this cause the errors ?

Try using shielded or twisted pair cable.

2 Likes

As I said, for long runs you need a smaller resistor. If the module has a 4k7 already, just add another 4k7 in parallel (effectively 2k35). Your wire type also makes a difference since there is a specification limit to the total capacitance of the data line to ground. I don’t recall the exact amount but it’s in the pf range. If you can find the specs for the wire you are considering, pick the one with the lowest pf per foot. Ethernet wire is pretty high within pairs (green-green/white for example), but the capacitance between non-paired wires (green to blue for example)is not specced, but I would expect it to be lower than the data pairs. What happens is that the perfect square wave data gets smoothed by the cable capacitance, making it harder for the protocol to discriminate the correct data. You would need an oscilloscope to see the effect of cable capacitance.

Long distances is open for interpretation.
The website list this length for the cable.

Cable is 36" long / 91cm

There have been issues with Dallas temp sensors since platform timing changes in 2022.12 of ESPhome. It seems to be hit and miss, some have had success using the dallasng custom component:

I’d first figure out if it’s the long cable by connecting the sensor directly to the dev board. If that works then it’s your cable. If it doesn’t work, then it’s either your cable or your sensor.

I’m pretty sure adafruit doesn’t intend for you to use it over 30ft but it’s possible that it would still work.

Second line of original post…

Is that shielded cable? You could try also connecting the shield to ground at the esp end.

Are you supplying the sensor with 3.3 or 5V?
3.3 is not good idea to pass long pulls. The board inputs are 5V tolerant so try changing the supply to 5V. And the internal 3.3v regulator is not very powerfull.

Alternatively if possible, have only the power supply connected where you have the esp and move esp to where you have the sensor. Then those two are closer. And use 2x wires for plus and 2x for minus to have more cross section.

I have it working over 35 meters of Ethernet cable so yes it’s possible

Hello,
I will try to add another 4k7 resistor in parallel with the adaptor i have.
When i connect the sensors directly to the board, they work fine. I connected all 3 of them and reading is correct.
So i suspect 2 problems:

  1. cable is not suitable for what i need (i use alarm cable 4x0.22 )
  2. the resistor 4k7 is to big. I will add another 4k7in parallel to see if is any change

Is enough to add the 4k7 resistor as in the pic above ?
data

I do not have an oscilloscope to test any signal, so i can not provide detailed information about it

I have Dallas running at 25m; used external grade shielded twisted cat7. It does occasionally drop out, but is usuable. I seem to remember I ran the Data line on its own twisted pair; i.e. the other twist not connected to Ground. I seem to remember the pullup didn’t make much difference.

Hello, i have added the resistor of 4k7. Bow i got the temperature but value is bot correct, and is constantly measured at 85C
Have any ideea


how to move on ?

Hello, i have added the resistor of 4k7. Bow i got the temperature but value is bot correct, and is constantly measured at 85C
Have any idea how to solve ?

Where did you put the resistor? It should be at the sensor end of the cable. Do you know anyone with an oscilloscope? The data at the sensor in perfect conditions will be a square-ish waveform. Long cables will skew and round the data, making it unreliable. One-wire works by the controller (the ESP) pulling the data line to ground in a pattern with the device address, releasing the data line then the device sends the data by pulling the data line to ground in a series of pulses that the controller can read. If the pullup resistor at the sensor is too big or missing, then the data will mostly be zero because there isn’t enough power to pull the data line back to “1”. If the resistor is too small, then the controller can’t pull the data line to “0”.

I just had a thought- remove the added resistor, and remove all of the other DS sensors. Try your test with just one sensor connected. If you have all sensors connected and they all have a 4K7 built-in, then your effective data line pullup is 1.175K, which may be too low.

Somehow i have managed to get the temperatures:
I did added / removed the resistors step by step, and according with sketch below values started to appear. I am not sure how correct and reliable it is.
A general question, the 4k7 resistor should be added at the end of the network or should be added ar the end of 0.9meter sensor cable ? Makes any difference ?

Thank you !