Author Topic: Issue connecting 20 DS18B20 sensors  (Read 1313 times)

0 Members and 1 Guest are viewing this topic.

Offline Hash BrakeTopic starter

  • Newbie
  • Posts: 7
  • Country: vn
Issue connecting 20 DS18B20 sensors
« on: July 02, 2021, 04:52:57 am »
Hello,

I trying to connect 20 DS18B20 temperature sensors together (for a soil monitoring project). The sensors are the 3m cabled, waterproof  versions of the DS18B20. I've connected all of them in parallel and am using an external source of power supply to power them (rather than powering them through the 5V pin on my Arduino Uno). The total cable weight/length is around 60.5m (20 x 3m + 0.5m for parallel wiring) and cable radius is 3.2m.

I've checked all of the sensors individually (and they all work fine) and hard-coded their addresses into the code to avoid having to search for their addresses every time I run the code.

Here's my issue. Let's say that sensor #1 is the one closest to the Arduino in the parallel circuit and sensor #20 is the farthest. When I only connect sensor #1 and read it, it works fine. But as soon as I connect the other 19 sensors, the reading immediately display -127C (ie. does not read).

So my question is, how do I make connect and read from 20 sensors?

** EDIT (SOLUTION) **
Thank you all for your amazing ideas and suggestions. After toying around with all the ideas, two of them worked for me.

- Splitting the sensors on more than one Arduino Pin: this works although it means that more cabling is required and the code becomes increasingly messy as more sensors are added.

- Decreasing the pull-up resistor value: this worked like a charm! I don't have the knowledge to do exact calculations but found that a 1k ohm resistor worked for 20 sensors on a single serial bus line.

I'm sure that the first solution has many added benefits to it but for the sake of simplicity, I went with the second option.
« Last Edit: July 03, 2021, 05:45:35 pm by Hash Brake »
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: gb
Re: Issue connecting 20 DS18B20 sensors
« Reply #1 on: July 02, 2021, 05:10:24 am »
Have a look at the following web tutorial. It deals with connecting multiply DS18B20 to a single bus. The author provided everything including the Arduino sketches and its output results. Starts with three sensors and works your way up to 20 in multiple steps.

https://lastminuteengineers.com/multiple-ds18b20-arduino-tutorial/

Added: Are you using 3-core cable to connect multiply DS18B20s as shown in its datasheet?
« Last Edit: July 02, 2021, 05:16:27 am by eblc1388 »
 

Offline Hash BrakeTopic starter

  • Newbie
  • Posts: 7
  • Country: vn
Re: Issue connecting 20 DS18B20 sensors
« Reply #2 on: July 02, 2021, 05:59:05 am »
I am actually following this website's instruction to wire and code my project. But say that I built my way from 3 sensors all the way to 20 and found out that the maximum is X number of sensors. How could I use this info to help me with my original problem?
 

Online magic

  • Super Contributor
  • ***
  • Posts: 7061
  • Country: pl
Re: Issue connecting 20 DS18B20 sensors
« Reply #3 on: July 02, 2021, 07:00:04 am »
Try to get some scope to check signal integrity, I guess.

Also, I once had a pair of fake DS18B20, out of which one failed to work with anything else on the bus. Even a small bus assembled on one row of a breadboard :-//
 

Offline Hash BrakeTopic starter

  • Newbie
  • Posts: 7
  • Country: vn
Re: Issue connecting 20 DS18B20 sensors
« Reply #4 on: July 02, 2021, 07:31:30 am »
I unfortunately don't have access to a scope. When I was checking their condition, I tested them out in groups of 3 sensors at a time (wired in star configuration). They all worked fine so I don't think there is an issue of having a fake sensor.
 

Online magic

  • Super Contributor
  • ***
  • Posts: 7061
  • Country: pl
Re: Issue connecting 20 DS18B20 sensors
« Reply #5 on: July 02, 2021, 08:03:38 am »
What's the exact topology of this networks, how are all the cables connected?
Is it a star of 20 3m cables and 0.5m to the controller?
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: gb
Re: Issue connecting 20 DS18B20 sensors
« Reply #6 on: July 02, 2021, 08:43:01 am »
I am actually following this website's instruction to wire and code my project. But say that I built my way from 3 sensors all the way to 20 and found out that the maximum is X number of sensors. How could I use this info to help me with my original problem?

If say 8 sensors works but fail with more sensors, then it can indicate problems like pull up resistor value, parallel capacitance of the bus, signal transfer speed etc..

Are these sensors obtained via Aliexpress?

The following quote is from the internet(https://www.pjrc.com/teensy/td_libs_OneWire.html): "OneWire requires a single 4.7K pullup resistor, connected between the pin and your power supply. When using very long wires, or with counterfeit DS18B20 chips and 3.3V power, a resistor in the 1K to 2.7K range may be required. "

« Last Edit: July 02, 2021, 08:52:10 am by eblc1388 »
 

Offline Hash BrakeTopic starter

  • Newbie
  • Posts: 7
  • Country: vn
Re: Issue connecting 20 DS18B20 sensors
« Reply #7 on: July 02, 2021, 09:56:26 am »
What's the exact topology of this networks, how are all the cables connected?
Is it a star of 20 3m cables and 0.5m to the controller?

I drew a topology diagram:
https://drive.google.com/file/d/1MMHQ3wZcfMrsiP0fdiTQDUFT8RwPIYRO/view?usp=sharing
 

Offline Hash BrakeTopic starter

  • Newbie
  • Posts: 7
  • Country: vn
Re: Issue connecting 20 DS18B20 sensors
« Reply #8 on: July 02, 2021, 09:59:57 am »
If say 8 sensors works but fail with more sensors, then it can indicate problems like pull up resistor value, parallel capacitance of the bus, signal transfer speed etc..

After some testing, I found that 7 sensors was the limit.

Are these sensors obtained via Aliexpress?

Not online, it was my local electronics hardware shop. I'm 99% sure they are clones though.

The following quote is from the internet(https://www.pjrc.com/teensy/td_libs_OneWire.html): "OneWire requires a single 4.7K pullup resistor, connected between the pin and your power supply. When using very long wires, or with counterfeit DS18B20 chips and 3.3V power, a resistor in the 1K to 2.7K range may be required. "

I'll try this. Why is it that non-original DS18B20s need different pulp resistors?
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 400
  • Country: gb
Re: Issue connecting 20 DS18B20 sensors
« Reply #9 on: July 02, 2021, 01:57:53 pm »
After some testing, I found that 7 sensors was the limit.

That's a very good result.

I have taken a look at your connection diagram. If 7 sensors works OK, then I'm confident decreasing the pull up resistor value will enable the rest of the sensors to work too.

I bet this has to do with the total capacitance of the cable & sensor, the leakage current of all the sensors combined and the worsening of the signal rising edge because of the high 4K7 pull up resistor value.
 
The following users thanked this post: Hash Brake


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf