DS18B20 and long distance

Hi all, I have done some research on the forum, someone says has used DS18B20 over 200m cables, but he doesn't give a circuit or the way to accomlish that.

I have the problem to read temperature from a DS18B20 about 50m far. I've tried with a CAT-5 cable, direct power (3-wires) and a pull-up resistor of 4.7K between Vdd and Data.

But I receive many errors, many times the reading is not possible.. other few times it gives the right value. And sometimes the sensor is not detectable.

I've used twisted pair of CAT-5 for Vdd and Gnd and another cable for DQ.

Could someone help me? It can be a voltage drop to the cable? Infact I noticed that on the terminal of the cable I read about 4.5V and not 5V.

I've thought to use a buffer near the sensor, is it possible?

Thanks for your helpful information...


are you using the sample code?

ds.reset(); ds.select(addr); ds.write(0x44,1); // start conversion, with parasite power on at the end

delay(1000); // maybe 750ms is enough, maybe not // we might do a ds.depower() here, but the reset will take care of it.

present = ds.reset();

you might try turning the parasite power off if you're not running in that mode ds.write(0x44,0);

and try playing with the delay()

I have shorter runs I had issues trying to run parasite and non-parasite at the same time so I went to the non-parasite mode for all mine - running 5 I was also able to reduce my delay() as it appeared to be needed more to charge up the parasite mode - but I did still needed a delay as I would get a drop out every now and then until I bumped it up a bit

Have you read Application Note 148?

I too have only used these devices over relatively short distances.

I had problems running long cables to DS1820s. I used a local arduino (well homebrew anyway) and used serial to get the data back to 'base' It was only 50m in my case though. I used 4 cores in the cat 5 for power and 2 way serial and used fairly short cables (~ 10m ) for the DS1820s.

The voltage drop across cables for a device that consumes micro amps is negligible. Its the capacitance that screws up the hi-lo switching of the communications protocol.


Hope someone can help me. I've read Application Note 148 and Appendix A shows a 200m solution using a 2N7000 MOSFET.

There isn't much in the way of an explanation in appendix A, just the diagram.

It looks to me (not an electronics expert) that the 2N7000's job is to sink current supplied through the 1K resistor. There are two connections into the micro controller, one drives the one wire to the DS18B20 the other switches the 2N7000 via the 3.3K resistor.

My question is, does the second connection go to a data pin on the arduino?

If so then I'm guessing I would need to modify the oneWire library to drive the second data pin.

As the DS18B20 will have to drive the oneWire to send data back the the arduino then I'm further guessing that the wire will be tri- state in nature, so the second data pin would need to be more than just the inverse of the first pin, the states would be:

oneWire 2N7000 Write a high 1 0 Write a low 0 1 Float detach 0

Any advice or alternative solution gratefully received.

Thanks Ian.

Try to lower the 4k7 to 3k3 or 2k2 - I had the same problem with the long wires and that solved it. Don’t go to low, because of the current the arduino has to deliver.

Couldn’t be this easy, but just in case…

How OFTEN do you read the sensor? I would be disappointed if it failed to give good results if read even as “rapidly” as once every ten seconds… but if you have your Arduino in a loop, reading it again, and again, and again… quickly… that would “strain” the system.

Also, you SPEAK of only one temperature sensor. Are things really that simple? (1-Wire doesn’t like “star topologies” for multiple sensors.)