DS18B20 wire length & pullup resistor q's

Hello,

Unfortunately all relevant topics are closed so I have to make the new one.

I'd like to attach a Dallas temperature sensor to my MCU suing normal powering scheme (all 3 pins are used, providing Vcc to the Dallas chip) on a 70meter long ethernet CAT5 cable. The same cable is used to attach other sensors as well.

  1. Do I need a pullup resistor attached to the data output pin of my temperature sensor? Is there anything I should think of given that cable length (resistance, capacitance, ...) ?

  2. Is writing HIGH on a MCU pin which is used to receive data from DS18 will have the same effect as having a pullup?

  3. Is it ok to have 70m cable for a 1Wire sensor?

Sorry if I am asking for obvious or stupid things - I am a software engineer, not electronics engineer :slight_smile:

Thanks!

The 1-Wire bus needs a pullup resistor for the data signal.
A HIGH output is a strong high level, a pullup is just a weak high level.
70 meters is too long in my opinion. With a genuine DS18B20, about 5 or 10 meters is reasonable for a reliable project.

Can you tell what your project is ? Please give us a broader view.
Perhaps there are other solutions.

The manufacturer of the DS18B20 and the creator of the 1-Wire bus talks about even longer lengths: https://www.analog.com/en/resources/technical-articles/guidelines-for-reliable-long-line-1wire-networks.html

1 Like

I have an ESP32 board with a SIM800L on it. It is located on an island (actually just rock). There are weather station mesauring wind speed and water turbidity. Powered by lead-acid battery + solar combo.

The turbidity sensor is located in seawater, 70 meters away from the ESP board, and CAT5 is used to receive data from the sensor. There are unused free wires in the cable

I would like to add a water temperature sensor to this setup. Data is measured every 2 hours and transmitted via SMS.

There is no way I can decrease the cable length.

Any ideas? Repeater somewhere in the middle? Don't use 1Wire DS sensor and just use temperature-depended resistor or pn-junction?

So there are no motors or relays or something that sparks nearby ? Not even wires from the main voltage ?
What are the other signals ? Are they 100% twisted pair signals ?
That link talks about 200 meters with 1k resistor pullup.
It might work.

If you add a Arduino board at the end of cable and use RS-485 through the cable, then it will work for sure. You can always fall back on that.

If you buy a DS18B20 from AliExpress/Amazon/TEMU/Ebay, then it is a counterfeit. They do not work according to the specifications.
If you buy a waterproof DS18B20 from one of those webshops, then you have a counterfeit DS18B20 with a housing that starts to leak after a week.

A repeater makes it more complex, that decreases the reliability.
A NTC temperature probe might work. It will take some effort to get rid of all the noise. Why not use a DS18B20 and a NTC as backup ? The NTC needs two wires, the GND wire for the NTC may not be shared with something else over such a distance.

1 Like

No relays nothing.
Other signals are voltage 0..5 volt from a wind speed sensor (close to the board)
Turbidity sensor has an analog pin as well, so no problem there.
DS is from China yes plain chip, i will make my own housing for it. The only digital interfaces are sim800l via UART and temperature sensor :(.

You have to immediately throw away those counterfeit DS18B20 sensors.

1 Like

I have several of these. They're not as accurate as the original ones, but they work fine. Be aware of the main limitation, which is a +/-3C accuracy 'problem' that can be compensated for by calibrating them and applying an adjustment in software. As to throwing them away...I wouldn't agree. To each their own.

+-3 degrees is actually alot. The need for the sensor arose from recent catastrophic event in Thailand. Massive coral bleaching. Which is triggered by temperature. And when water was 30 celsius it was ok, but at 33 corals had died. But thats ok, I can heat up the sensor in controlled manner with 0.1 celsius accuracy and read values to calibrate it perfectly.

However I am starting to think that analog device would be more suitable for this. Also medical electronic thermometers are quite precise in the range of temperatures I am interested in - may be it is a good source of a sensor.

Yes, you can calibrate it against a known-good thermometer.

If absolute accuracy is critical, evidently don't rely on a counterfeit $0.50 sensor. There are plenty of good digital temperature sensing solutions around. It's a common function and thousands of implementations are available in varying degrees of accuracy.

I think a pure analog system will be challenging to combine with your (implied) desire to automatically collect and display data. Of course, only you can decide this. I imagine it's difficult to measure temperature 70m out into the ocean with an analog thermometer and somehow read the temperature from the rock/island.

It is not about the temperature, it is about what I read on this forum about troubles with longer cables. If the room temperature has to be measured with a project on a breadboard, then they can be used. For something serious, a genuine DS18B20 is required.

I can only reflect on my own use or what I've directly been involved in. I've never went beyond a few meters with these, but in a noisy environment. My father has used a setup for a few years with 10-20m cable; a single trunk with 4 or 5 sensors on one end and an Arduino on the other. Neither of us ran into problems that related to the sensors being counterfeit. It's conceivable that there are quality differences in this regard as well, but they're not necessarily deal-breakers.

Evidently, long cables bring potential problems of their own in terms of noise and stray capacitance. On a 70-meter connection I'd be tempted to start experimenting with active pullups and/or active line drivers, regardless of the (perceived or objective) quality of the sensors.

1 Like

Have you thought of moving the processor to the rock with the sensors and using WiFi to send the data back? Use the cable to just send power.

There may be environmental or other factors that would make this impractical, but I thought I'd make the suggestion.

1 Like

Hello, I would ditch the digital sensors and the coarse NTC sensor. I would suggest a PT100 sensor in a stainless steel tube, welded in one end and sealed in the other end. Connection to be done by four wires.Cable, shielded CAT6, grounded in both ends. The four wire configuration accounts for the wire length. MAX31865 is then used against your MCU, quite easy. This is a robust setup and is used in the industry and give very good precistion.

2 Likes

Yes the board, wind sensor and solar panel + battery is attached to the pole which is located on the rock. I stick to analog sensors (LM35DZ for temp) and it is all ok except for turbidity sensor which has low sensitivity :-. I used standart sensor for washing mashines but it seems it is a bad choice for a seawater. Looks like I have to mcgyver my own sensor :frowning:

Is this ok to connect 5v output of a sensor straight to ESP32 board pins? Do I need to add a voltage divider to clamp it down to 3.3?

So far it works without any level shift. But may be it is bad for the hardware I do not know

No.

1 Like

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