Issue connecting 20 DS18B20 sensors - Page 1
Forum section: electronics / projects

author: Hash Brake
author_rank: Newbie
timestamp: July 02, 2021, 04:52:57 am
content: 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.

author: eblc1388
author_rank: Frequent Contributor
timestamp: July 02, 2021, 05:10:24 am
content: 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?

author: Hash Brake
author_rank: Newbie
timestamp: July 02, 2021, 05:59:05 am
content: 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?

author: magic
author_rank: Super Contributor
timestamp: July 02, 2021, 07:00:04 am
content: 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

author: Hash Brake
author_rank: Newbie
timestamp: July 02, 2021, 07:31:30 am
content: 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.

author: magic
author_rank: Super Contributor
timestamp: July 02, 2021, 08:03:38 am
content: 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?

author: eblc1388
author_rank: Frequent Contributor
timestamp: July 02, 2021, 08:43:01 am
content: Quote from: Hash Brake on July 02, 2021, 05:59:05 amIf 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. "

author: Hash Brake
author_rank: Newbie
timestamp: July 02, 2021, 09:56:26 am
content: Quote from: magic on July 02, 2021, 08:03:38 amI drew a topology diagram:https://drive.google.com/file/d/1MMHQ3wZcfMrsiP0fdiTQDUFT8RwPIYRO/view?usp=sharing

author: Hash Brake
author_rank: Newbie
timestamp: July 02, 2021, 09:59:57 am
content: Quote from: eblc1388 on July 02, 2021, 08:43:01 amAfter some testing, I found that 7 sensors was the limit.Quote from: eblc1388 on July 02, 2021, 08:43:01 amNot online, it was my local electronics hardware shop. I'm 99% sure they are clones though.Quote from: eblc1388 on July 02, 2021, 08:43:01 amI'll try this. Why is it that non-original DS18B20s need different pulp resistors?

author: eblc1388
author_rank: Frequent Contributor
timestamp: July 02, 2021, 01:57:53 pm
content: Quote from: Hash Brake on July 02, 2021, 09:59:57 amThat'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.