# Sensor wire length

**URL:** <https://forum.arduino.cc/t/sensor-wire-length/1065281>\
**Category:** Sensors\
**Created:** [December 14, 2022, 3:12am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281 "2022-12-14T03:12:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![logichc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/logichc/32/1126574_2.png) [@logichc](https://forum.arduino.cc/u/logichc)\
**Post date:** [December 14, 2022, 3:12am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/1 "2022-12-14T03:12:06Z")

</div>

I am using 3 DS18B20 sensors to connect to a ESP8266 board.  
All works well. then put the system at my other house. Two sensors are about 20 feet away and third one at about 100 feet away. When I connect all three, I get no readings from the sensors. I noticed that if I use the 2 closer ones, all works well. But when I connect the one at 100 feet, all three fail to give readings.  
I am using a cellphone charger to power my system. I can't figure out what is the problem. Thanks.

---

<div class="post-metadata">

**Author:** ![the\_3d6](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@the\_3d6](https://forum.arduino.cc/u/the_3d6)\
**Post date:** [December 14, 2022, 3:22am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/2 "2022-12-14T03:22:57Z")

</div>

At such distance you can't ignore inductance of the wire anymore (and possibly its capacity as well, depending on the cable) - most likely it distorts signal fronts too much and DS18B20 can't recognize the command or produce the response.  
Are you using them in 3-wire configuration or in 2-wire?  
In 2-wire case I suggest switching to 3-wire. If you are already using 3 wire option, maybe using lower value of pullup resistor would help

---

<div class="post-metadata">

**Author:** ![xfacta](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfacta/32/1013044_2.png) [@xfacta](https://forum.arduino.cc/u/xfacta)\
**Post date:** [December 14, 2022, 3:29am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/3 "2022-12-14T03:29:10Z")

</div>

100ft is a long way for those sensors, see if this helps though

Pullup Resistor guide  
Length 5.0 Volt 3.3 Volt  
10cm (4") 10K0 6K8  
20cm (8") 8K2 4K7  
50cm (20") 4K7 3K3  
100cm (3'4") 3K3 2K2  
200cm (6'8") 2K2 1K0

---

<div class="post-metadata">

**Author:** ![logichc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/logichc/32/1126574_2.png) [@logichc](https://forum.arduino.cc/u/logichc)\
**Post date:** [December 14, 2022, 3:49am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/4 "2022-12-14T03:49:21Z")

</div>

> [@the\_3d6](#):
>
> 2-wire

Thanks. I am using them in 3-wire config. I will try a lower pullup tomorrow and see what happens. I tried with shielded wires thinking that may be a problem but same result. Also I was thinking maybe my charger was not giving enough amps to reach all the way to the sensor. Now I will try a 2.2k pullup resistor and try again tomorrow. if I use a low pullup resistor, will that not cause a loss in current?

---

<div class="post-metadata">

**Author:** ![logichc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/logichc/32/1126574_2.png) [@logichc](https://forum.arduino.cc/u/logichc)\
**Post date:** [December 14, 2022, 3:51am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/5 "2022-12-14T03:51:05Z")

</div>

Thank you. I will try that tomorrow. I read somewhere on the internet that the DS18B20 can be connected upto 100 meters, which is encouraging. Hoping that is true, I am only 100 feet, a third the 100 meter distance. But I doubt that is true and only hoping. I will try tomorrow again with a 2.2k pullup. Thanks again.

---

<div class="post-metadata">

**Author:** ![xfacta](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfacta/32/1013044_2.png) [@xfacta](https://forum.arduino.cc/u/xfacta)\
**Post date:** [December 14, 2022, 4:01am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/6 "2022-12-14T04:01:48Z")

</div>

There's some reading here too, people have got long runs with multiple sensors

> <https://raspberrypi.stackexchange.com/questions/41234/max-length-of-wire-w-3-3v-or-other-issue>

---

<div class="post-metadata">

**Author:** ![the\_3d6](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@the\_3d6](https://forum.arduino.cc/u/the_3d6)\
**Post date:** [December 14, 2022, 4:21am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/7 "2022-12-14T04:21:37Z")

</div>

There is a great advice in that discussion: adding a small-ish resistor on the data line - they used 80 Ohms there, and it looks very reasonable (probably anything in 50-100 Ohms range would be ok). The reason is that resistor in series damps oscillations caused by wire inductance and capacitance - and them could be indeed the biggest problem here.

---

<div class="post-metadata">

**Author:** ![logichc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/logichc/32/1126574_2.png) [@logichc](https://forum.arduino.cc/u/logichc)\
**Post date:** [December 14, 2022, 4:22am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/8 "2022-12-14T04:22:46Z")

</div>

> [@the\_3d6](#):
>
> s a great advice in that discussion: adding a small-ish resistor on t

Thank you so much! that is a very interesting and encouraging read.

---

<div class="post-metadata">

**Author:** ![logichc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/logichc/32/1126574_2.png) [@logichc](https://forum.arduino.cc/u/logichc)\
**Post date:** [December 14, 2022, 4:23am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/9 "2022-12-14T04:23:27Z")

</div>

Thank you so much for the link, it is a very interesting and encouraging read.

---

<div class="post-metadata">

**Author:** ![the\_3d6](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@the\_3d6](https://forum.arduino.cc/u/the_3d6)\
**Post date:** [December 14, 2022, 4:25am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/10 "2022-12-14T04:25:09Z")

</div>

> [@logichc](#):
>
> maybe my charger was not giving enough amps to reach all the way to the sensor

Definitely impossible scenario: those sensors would take only about 1 mA of current regardless of the wire length. And it means that wire resistance itself is negligible comparing to sensor impedance. So it's not a power problem for sure - it's a signal shape problem.  
Smaller pullup would apply "stronger force" so to say to a data line, making it harder for oscillations to break logical levels. But damping resistors mentioned in the discussion linked above would work much better for that purpose

---

<div class="post-metadata">

**Author:** ![logichc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/logichc/32/1126574_2.png) [@logichc](https://forum.arduino.cc/u/logichc)\
**Post date:** [December 14, 2022, 4:25am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/11 "2022-12-14T04:25:22Z")

</div>

Should I put the low-ish resistor only at the ends on the longest run sensor or do I need to put on all 3? I would assume only on the longest run as that is causing the problem, but I am fairly new to arduino and dont want to make any mistakes.

---

<div class="post-metadata">

**Author:** ![the\_3d6](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@the\_3d6](https://forum.arduino.cc/u/the_3d6)\
**Post date:** [December 14, 2022, 4:28am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/12 "2022-12-14T04:28:40Z")

</div>

I would start with putting it on the ESP side of the longest wire, in this point it would make the biggest impact - possibly it would solve the problem already. Then maybe on ESP side of other wires. After that, on the other side of those wires

---

<div class="post-metadata">

**Author:** ![xfacta](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfacta/32/1013044_2.png) [@xfacta](https://forum.arduino.cc/u/xfacta)\
**Post date:** [December 14, 2022, 4:33am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/13 "2022-12-14T04:33:48Z")

</div>

Try to pullup resistor first, then if required add two 80 ohm resistors in series with the signal wire, 1 close to the arduino, 1 close to the most distant sensor.  
Twisted pair wire, like Cat5 networking cable will help.  
Use one twisted pair for ground and signal, and another twisted pair for ground and 5v

---

<div class="post-metadata">

**Author:** ![buckfast\_beekeeper](https://avatars.discourse-cdn.com/v4/letter/b/74df32/32.png) [@buckfast\_beekeeper](https://forum.arduino.cc/u/buckfast_beekeeper)\
**Post date:** [December 14, 2022, 10:09am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/14 "2022-12-14T10:09:20Z")

</div>

Are you using the DS18B20 with 5V or 3V3? Use 5V with pullup to 3V3 or use a level converter like TXB0101

Placing an 47µ/100µ and 100n capacitor near the DS18B20 can help.

---

<div class="post-metadata">

**Author:** ![logichc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/logichc/32/1126574_2.png) [@logichc](https://forum.arduino.cc/u/logichc)\
**Post date:** [December 14, 2022, 12:09pm UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/15 "2022-12-14T12:09:37Z")

</div>

I am using the pull up on the sensor to +5 volt and using the Gnd/5V to power the sensors, as I assumed the distance might need the higher voltage. I will try the 2.2k pullup resistor this morning. Then I will try to put the 80 ohm resistor like you mentionned. For wire, I used alarm wire first, then I replaced it with shielded wire, both with same results. I will try the cat5/6 also today if the pullup and resistors doesnt solve the problem. Also if I need the capacitors, do they have to be in series or parallel to the data line/ground or data/+5v? Thank you.

---

<div class="post-metadata">

**Author:** ![logichc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/logichc/32/1126574_2.png) [@logichc](https://forum.arduino.cc/u/logichc)\
**Post date:** [December 14, 2022, 12:35pm UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/16 "2022-12-14T12:35:41Z")

</div>

Ok will try that today. Thank you for helping.

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [December 14, 2022, 1:32pm UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/17 "2022-12-14T13:32:58Z")

</div>

> [@logichc](#):
>
> I am using them in 3-wire config.

You might think that but power and ground do not count. This is in fact a 1 wire device from the point of view of signal wires. Therefore you must use the 1 wire library, nothing else. 1 Wire devices take a long time to respond in the order of seconds or so.

This is a link to help you use them.  
[https://www.elprocus.com/ds18b20-temperature-sensor/](https://www.elprocus.com/ds18b20-temperature-sensor/)

> [@logichc](#):
>
> I am using the pull up on the sensor to +5 volt

Very bad idea. That means you are exceeding the 3V3 voltage level of the device. A great way to damage your processor.

---

<div class="post-metadata">

**Author:** ![logichc](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/logichc/32/1126574_2.png) [@logichc](https://forum.arduino.cc/u/logichc)\
**Post date:** [December 26, 2022, 5:52am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/18 "2022-12-26T05:52:26Z")

</div>

Do you mean I should power the DS18b20 with 3.3 v instead of 5V and use the pull up resistor between its sensor to 3.3? I have the thing online for about a week now.

I saw the wiring diagram here [https://lastminuteengineers.com/ds18b20-arduino-tutorial/](https://lastminuteengineers.com/ds18b20-arduino-tutorial/) which says to use the 5.5v. I hope I am not using my sensor wrongly wired and damage the processor.

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [December 26, 2022, 7:15am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/19 "2022-12-26T07:15:06Z")

</div>

> [@logichc](#):
>
> which says to use the 5.5v.

It does say that **but** that example is for a 5V processor, not a 3V3 processor. Nowhere does it say you connect it to 5V if your processor is powered by 3V3.

The pinout of the sensor on this page shows the power labelled as Vcc. In electronics, that means to the power supply of the processor itself.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [June 24, 2023, 7:16am UTC](https://forum.arduino.cc/t/sensor-wire-length/1065281/20 "2023-06-24T07:16:00Z")

</div>

Closed on June 24, 2023, 7:16am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
