Extending 1-Wire interface - SONOFF Temperature Sensor

I’m using a SONOFF SNZB-02LD Zigbee Temperature Sensor to monitor my pool temperature. To make it convenient for both reading and good zigbee, I have extended the probe with a 20 meters of 22 gauge wire. This worked for a number of months, but has stopped working reliably now.

It’s not a 10K thermistor, but seems to be digital, I assume it’s using I2C communication or 1-Wire interface based on the 3 wires. (I’m not sure.) I’ve read that 1-wire can stretch up to 100 meters with proper cable selection of bus capacitance to maintain signal integrity.

I might give up, but the 20 meters has worked for me, and I don’t want to ditch everything I’ve done for a new approach. It’s seems that the capacitance of the wire is the important issue, but I’m a bit out of depth on this issue and was wondering if others have dealt with this and can offer me advice on tweaks or better wire, etc. TYA - Paul

I2C uses 4 wires including supply, I’m pretty sure yours is 1-wire DS18B20 and probe has 3 wires including supply. For that long cable twisted pair would likely perform better, data line twisted with gnd.
But since your sensor worked for long time, your problem might be bad connections on extension like oxidation. How was it done in practice?

All connections were soldered with heat shrink on each wire and and a bigger sleeve over the whole splice. I doubt the issue. Father research since i wrote the post confers with the DS18B20 as that seems to be very common. So you are suggesting using Cat5, one pair Vcc and Gnd, and the other Data and Gnd? The wire I was, and am now using is 4 wire (non twisted) alarm wire. Maybe not a great choice. I can try replacing that with cat-5 twisted. Thank you

Yes, both data and vcc can be paired with gnd.
Alarm wires are usually twisted.
I would carefully inspect the soldered connections. Cold solder joint could easily cause problem like this.

These are part of a time sensititive circuit where it has to report back in a certain amount of time. It is very sensitive to the size of pull-up and the quality of the power supply at longer distances. When I say longer distances I have not got them to work passed 12 feet in a shielded cable.

What I’m sayting is I think 20 meters has about 1 chance in hell of working. Not impossible, but not stable either.

Set-up an ESPHome closer by and wifi the data in…

20M is remarkably long for 1-wire interface. Yes, wire capacitance is the data killer, and the capacitance of bell/thermostat wire is far lower than CAT Ethernet cable. The only thing worse would be shielded cable.

Fine tuning of the pullup resistor requires an oscilloscope to get a clean square wave.

But, 20M? I would never expect it to work. I would just run 5V to an ESPHome device closer to the sensor. A Wemos D1 Mini shouldn’t cost more than $5. (I buy mine ten at a time for $2 each).

The Dallas Semiconductor (later Maxim and now Analog Devices) DS18B20 is used in your Sonoff and a lot of other industry devices. Been around for ever. Robust and often stainless steel capped and shrink wrapped to make the sensor end waterproof.

The datasheet and application notes for the DS18B20 discuss long cable runs and topology, and how you have to add a biasing pullup resistor for reliability for longer runs. This boosts the parasite power onboard.

A resistor value of around 4.7k should do if one is not already present. Cheapest you can find is ok. Any wattage should be fine.

The 1-wire is a misnomer - most DS18B20’s come with three wires inside a black protective sheath, often three feet/1 metre long with pigtails or a three pin connector. Wires are black for ground, usually yellow for data, and usually red for optional power. Sometimes these colors are mixed up, often cheap Chinese factory manufacturing rejects. Best check from your supplier to make sure.

The 1-wire protocol is neat, both power and data travelling down the same wire. If not enough reaches the other end or there is electrical interference, it becomes unreliable, as you have observed. 1-wire data clashes and retransmission protocol are handled on chip.

For commercial or extremely long runs in the hundreds of meters, active boosters are used. For hobby and home use, a resistor should be used for runs of ten metres or more.

Having said all that above, the external temperature probe of the Sonoff is already 1.5 metres long and the circuit board it is connected to internally already has a resistor connected.

Putting another external one in parallel with it is only going to reduce the overall resistance, not increase it, possibly improving the reliability and parasitic power being transmitted slightly. Maybe go for a higher value externally to prevent saturation.

The solution? Roll your own. Read the Dallas Semiconductor data and application notes. Go buy a cheap ESP32, add the resistor and DS18B20 yourself and just use the standard ESPHome solution Dallas Temperature Sensor - ESPHome - Smart Home Made Simple to measure whatever you need at the end of the long cable.

Thank you to everyone that replied. I ended up using 3 single wires of a cat-5 cable My multimeter had a capacitance function, so I used that to test various cables I had sitting around. My cheap 4 wire alarm cable (22 awg aluminum) was not that bad, way better than the higher priced thicker gauge (20 awg copper) I originally thought would be a better choice. As it turns out the Cat-5 I have had the lowest wire to wire capacitance measurements. I used just single wire of 3 pairs, because using both wires of a pair would of been higher capacitance. (I measured it.). And it’s not carrying / needing any current so no point in doubling wires up. Thinner wire is better, up to the point of physical stability. Now working great 20 meters for 4 days.

A few things i learned.
From my research, the sensor is a DS18B20 as others suggested.

From google AI Overview.
The 1-Wire interface is a half-duplex serial communication protocol developed by Dallas Semiconductor (Maxim Integrated). It uses a single data line plus a ground return to transfer data and, optionally, extracts operating power (parasitic power) over that same physical connection.

Standard speed operates around 15.4 to 16.3 kbit/s, while an overdrive mode reaches up to 125 kbit/s.

The data line typically requires an external pull-up resistor (around 4.7 kΩ) connected to a DC voltage source.

A standard 1-Wire network typically operates reliably up to 100 to 300 meters (330 to 980 feet) for linear topologies using a basic pull-up resistor. With specialized active pull-up driver chips or optimized impedance matching, maximum distance can extend up to 500 meters.

For the Sonoff SNZB-02LD:
It does not use parasitic power, but runs the 3.3 volts of the battery down the line on its own wire. The 3 wires that go from the main unit to the sensor are:
White: Vdd
Red: Vcc
Green: Data
The Sonoff SNZB-02LD has a built in 10k pull up resistor.
I was not able to figure out the speed, and not really relevant for me since i can’t change it. I did see that it’s sampling the temperature once every 5 seconds.

If you have an oscilloscope you can tune the pullup resistor for the best square wave. Use a 10K pot, tune for the best square wave, then measure the resistance.