ecurieecosse
Posts: 23
Joined: Mon Mar 09, 2015 4:12 pm

Multiple DS18B20 temperature sensors

Fri Dec 09, 2016 9:48 am

Hi,
I'm just wondering if anyone has come across this issue. Using a pi3 I have 4 of the digital temperature sensors measuring temperatures all of which is working perfectly on my bench. The live installation has the sensors in 4 areas and all of them are wired to individual cables between 15 to 10 metres long and are sharing the 3.3v, GND, and signal lines as normal. Once installed the system doesn't work correctly, as random sensors are being detected or not at all. All the sensors work individually and I seem to have ascertained that any 2 will work fine, but when I add the third that's when seemingly random sensor detection starts to occur.
I am now assuming that the combination of cable length/resistance and power needs are exceeding the pi's 3.3v capacity and thus I'm not getting consistent detection of the sensors' presence.
Has anyone experienced this issue or have any suggestions that my analysis of the issue is incorrect.
Many thanks.
Colin
original pi model A
series 2 - B+
original pi zero
several pi zeroW
several series 3 B

User avatar
rpdom
Posts: 12948
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: Multiple DS18B20 temperature sensors

Fri Dec 09, 2016 10:01 am

ecurieecosse wrote: all of them are wired to individual cables between 15 to 10 metres long
Do you mean that you are using a star topography layout? Those sensors work best if they are chained rather than on individual cables.

ecurieecosse
Posts: 23
Joined: Mon Mar 09, 2015 4:12 pm

Re: Multiple DS18B20 temperature sensors

Fri Dec 09, 2016 10:10 am

hi rpdom,
The sensors share common 3.3v gnd and signal like the diagram attached. The key issues that evrything works fine except when all sensors are on the end of long cables. Hence my guess about resistance and power.
connect-multiple-ds18b2-i2c-sensors-raspberry-pi.jpg
wiring layout
connect-multiple-ds18b2-i2c-sensors-raspberry-pi.jpg (30.55 KiB) Viewed 9706 times
Colin
original pi model A
series 2 - B+
original pi zero
several pi zeroW
several series 3 B

User avatar
StevenP
Posts: 56
Joined: Tue Aug 14, 2012 7:55 pm
Location: Germany / UK

Re: Multiple DS18B20 temperature sensors

Fri Dec 09, 2016 10:41 am

You can check if voltage drop at the end of the cable is a problem by measuring the supply voltage at the sensor itself. It should not be too much less than 3.3V.

Another possibility is the capacitance of the cable, causing the rise/fall times of the I2C waveforms to be slowed down. You could check that at by measuring at the RPi end using an oscilloscope. The waveforms should be clean square waves. If that is a problem, then the solution is either a slower I2C clock, or alternatively reducing the value of the 4k7 pullup resistor. Say 2k2 or 1k but you need to check whether the RPi and the sensor are OK with the extra loading.

A further possibility is electrical noise. Try the cables somewhere free of electrical noise and see if the problem goes away.

Best of luck - let us know what the solution was!
StevenP
"The time has come," the Walrus said,
"To talk of many things..."

ecurieecosse
Posts: 23
Joined: Mon Mar 09, 2015 4:12 pm

Re: Multiple DS18B20 temperature sensors

Fri Dec 09, 2016 11:08 am

Steven,
Thanks for the suggestions, some of which will be tricky to try in situ - cables in ceiling voids etc.
My thoughts were simply to split the sensors into 2 groups of 2 and supply each group with seperate 3.3v/GND but still bring the signal leads together.
Hopefully someone else may have experienced this issue before me and know the answers :) If not I'll do more investigations and report back here as they progress
Colin
original pi model A
series 2 - B+
original pi zero
several pi zeroW
several series 3 B

User avatar
rpdom
Posts: 12948
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: Multiple DS18B20 temperature sensors

Fri Dec 09, 2016 9:35 pm

StevenP wrote:You can check if voltage drop at the end of the cable is a problem by measuring the supply voltage at the sensor itself. It should not be too much less than 3.3V.

Another possibility is the capacitance of the cable, causing the rise/fall times of the I2C waveforms to be slowed down. You could check that at by measuring at the RPi end using an oscilloscope. The waveforms should be clean square waves. If that is a problem, then the solution is either a slower I2C clock, or alternatively reducing the value of the 4k7 pullup resistor. Say 2k2 or 1k but you need to check whether the RPi and the sensor are OK with the extra loading.
That may work if the DS18B20s were I2C, but they are Dallas One-Wire bus instead.

However the type of cable may cause issues.

The recommended resistance for the pull-up is 5K, so 4K7 is the best practical value to use.

User avatar
StevenP
Posts: 56
Joined: Tue Aug 14, 2012 7:55 pm
Location: Germany / UK

Re: Multiple DS18B20 temperature sensors

Sat Dec 10, 2016 5:38 pm

OK, sorry I did not realise it was Dallas one-wire, although you are using it with separate 3V3 which is a very good idea.

As rpdom said, the star topology will be the worst, a daisy chained the best.

I had a look at the Dallas datasheet, the device is OK with sinking 4mA. This means they will be OK down to a 1k pull-up resistor at a 3V3 supply (3.3V / 1k = 3.3mA). Your problem will most likely be either be due to reflections or slow rise times on the data line. If it were my system, I would try a 2k2 resistor instead of the standard 4k7 and see if it's more reliable. This will improve the rise time of the data signal. As I said, 1k should also be safe, although it's much lower than the standard 4k7.

To really find out what's going on, you need an oscilloscope on the data line at RPi and also at the Dallas, but that's probably advanced debugging. If you Google around, people have best success the cat5 or twisted pair telephone cable. If you are using twisted pair, run the ground and data lines as a twisted pair.

Cheers
"The time has come," the Walrus said,
"To talk of many things..."

brian59
Posts: 4
Joined: Fri Dec 02, 2016 9:43 am

Re: Multiple DS18B20 temperature sensors

Thu Dec 15, 2016 11:08 am

My 10x DS18B20 system has been very reliable over the last 2 years.
I use bt phone plugs and cables.
I am able to plot all of my 1 minute interval data in Excel.
However I added an 11th sensor today and a sensor on one of the longest lines drops out about 80% of the time.
If I disconnect the 11th then all is ok as before.
I use 5v from gpio pin 2.
I have one 4.7K resistor in my circuit.
I have tried using 2.2K as suggested and it gets a little worse. 9K drops all of them.
So I am back on 4.7K.
Is it the voltage that is being pulled down? What is the best way of curing this?
Any help would be appreciated.

ecurieecosse
Posts: 23
Joined: Mon Mar 09, 2015 4:12 pm

Re: Multiple DS18B20 temperature sensors

Thu Dec 15, 2016 12:34 pm

I haven't yet had an opportunity to do any further investigation as the system is now back in my home and the long cables are installed in the studio. My belief is that the problem is voltage drop over the cable runs so my plan is to try 2 different things -
1. Use 5v supply as Brian is doing as he seems to have 10 sensors running in this way
2. Pick up a second 3.3v supply and split the sensors into 2 pairs of 2 each with their own 3.3v supply
I'm hoping to find time to test this in the next few days and will post any relevant results.
Colin
original pi model A
series 2 - B+
original pi zero
several pi zeroW
several series 3 B

JoeSoap
Posts: 57
Joined: Sun Oct 28, 2012 4:58 pm

Re: Multiple DS18B20 temperature sensors

Fri Dec 16, 2016 4:26 pm

There is a AN148.pdf from dallas
"TUTORIAL 148 - Guidelines for Reliable Long Line 1-Wire Networks"

which may be useful. It talks about the various topologies and some ways to
mitigate problems .

an earlier poster referred to
- capacitance which could be a problem which would depend on the type of cable .
- mains interference and routing your cables away from mains cables, motors, fluorescent light fittings , probably LED lights , and any other electronics (mobile phones?).

JoeSoap

ecurieecosse
Posts: 23
Joined: Mon Mar 09, 2015 4:12 pm

Re: Multiple DS18B20 temperature sensors

Fri Dec 16, 2016 5:01 pm

Joe,
Thanks for that info - a link wold have been helpful, but I have managed to track down the pdf you mention and am now reading it. For anyone else interested in this topic here is the link -
https://www.maximintegrated.com/en/app- ... mvp/id/148
There is a lot to consider in this paper.
Colin
original pi model A
series 2 - B+
original pi zero
several pi zeroW
several series 3 B

R-A
Posts: 50
Joined: Sun Sep 11, 2016 4:59 pm
Contact: Website

Re: Multiple DS18B20 temperature sensors

Mon Jan 16, 2017 8:37 pm

Did you ever get the 11th sensor to work more reliably?
I'm using a Raspberry Pi 3 Model B with 7" LCD Touch screen and Mini USB Wireless Keyboard

ecurieecosse
Posts: 23
Joined: Mon Mar 09, 2015 4:12 pm

Re: Multiple DS18B20 temperature sensors

Wed Jan 18, 2017 9:53 am

A quick update as I've found some time after the holiday period to do further investigations.
1. I ascertained that one of the sensors was not working - that turned out to be miswired at the end of the 15m cable. Easily resolved but did not make any difference to the detection of all sensors.
2. I spent a bit of time reading and understanding the document described above and concluded that the basic problem was that I had in effect created a star network. This was dictated by the physical nature of the premises with the pi which is in the centre of an array of rooms, so I had each room sensor on its own cable. Clearly the 1-wire network is hardest to make work relaibly in this configuration so ....
3. I've removed the original cabling and now made up a daisy chain with a length of about 15m and with several 3m stubs to additional sensors. This now works reliably on the bench with all sensors being detected and working correctly.
4. Assuming I have estimated the correct cable lengths this new cable loom now has to be installed (this could be difficult to feed through the various ceiling voids) and I expect this will work fine, unless there is some other factor at work such as em interference.
In conclusion, like many projects the transition from bench to actual installation can throw up expected issues that have to be worked through.
Colin
original pi model A
series 2 - B+
original pi zero
several pi zeroW
several series 3 B

brian59
Posts: 4
Joined: Fri Dec 02, 2016 9:43 am

Re: Multiple DS18B20 temperature sensors

Thu Feb 09, 2017 5:21 pm

I transferred my house temperature measuring program from my RPI 1 to my RPI 3 but it would not read any sensors.
I eventually got it going by adding dtoverlay=w1-gpio,gpioin=4 to the /boot/confi.txt file.

I get no dropouts now and it is reading 13 sensors without any errors. Plan to expand up to 20 and see what happens...
I am using the same wiring as before so I assume that the RPI 1 was struggling. Still investigating that at the moment.

The RPI1 has been measuring temperatures on and off since 2013. It has run continuously 24/7 for about 3months in 1 week runs and has been very reliable (apart from the usual problems). Plotting data in Excel on my PC laptop.

A radiator temperature control valve went wrong while I was away a couple of weeks ago and I was able to see clearly when it failed. One rad temperature dropped while the others were ok, so you could see it was local.

rogercw1
Posts: 3
Joined: Wed Dec 20, 2017 3:54 pm

Re: Multiple DS18B20 temperature sensors

Tue Mar 13, 2018 6:38 pm

In a past life I worked in environments which are electrically noisy, many comments above have noted the key issues:

Capacitance
Inductance
Resistance
Reflections off the end of an unterminated cable - that's why old-school Ethernet coax HAD to have a terminator resistor on the ends - to stop the high frequency waveform reflecting off the cable end and obscuring the next 'packet'.

Fundamentally signal transmission physics haven't changed..

The resistance of the cable drops the voltage over a long length [pretty obvious this one], but Capacitance and Cross-talk are killers to low voltage square waves.

Capacitance rolls the edges off the square wave, making the edge detection more difficult.
On untwisted cables you effectively have a long, or very long capacitor [of low value].

A star network puts variable length cables with different signal characteristics into the problem so that has the potential to mess with the signals even more than a daisy chain. If you have a mix of daisy and star, it makes calculating the effective impedance of the devices a lot more complicated.
Multiple devices need a lower value resistor because two resistors with the same value in parallel halve the impedance.

We installed screened twisted pairs at a much heavier gauge to get reasonable RS422 transmission distance and overcome the electrical noise, putting the cables in 20mm conduit, properly grounded AT ONE end only, if you ground at both ends you get an induced voltage owing to variations in earth potential - an Earth loop.

Despite CW1038 [telephone cable] not having a particularly low resistance [because its thin] it is at least in twisted pairs.

This cuts the crosstalk, reduces the effective capacitance, and keeps the signal waveform 'square', within the bounds of the technology.

When I started work in 1980, 1200bps, maybe 9600 was the best you could expect from a modem on a BT telephone pair, now my ADSL works at 70 megabits per second.

zidarsk8
Posts: 1
Joined: Thu Nov 01, 2018 7:12 pm

Re: Multiple DS18B20 temperature sensors

Thu Nov 01, 2018 7:21 pm

Hey, I'm sorry for not understanding this too well, but can someone show me how a daisy chain with one wire looks like?

I can't see from a topological sense how a single data wire can be linked to multiple sensors in anything but a star connection. Or are you talking about where the pullup resistor is set (like having a single one vs having one before each sensor)

Again sorry for being a noob but I am reading this trying to get my 11 sensors working but I feel like I'm missing one piece of the puzzle here.

nemo92
Posts: 2
Joined: Mon Nov 12, 2018 5:03 pm
Location: Slovenia

Re: Multiple DS18B20 temperature sensors

Mon Nov 12, 2018 5:40 pm

Hello,

I am having problem reading sensors after temperature starts to change. I am using them to measure temperature in boilers, rooms, outside temperature, and water storage tanks all together I use 8 sensors connected to 2 pins (4 and 17) two 4,7k pull-up resistors.

For example, when I turn the heating on after some time they start to read temperature -0.062°C, after a while they disappear out of /sys/bus/w1/devices. Only two sensors remain, always the same and they allways show the correct temperature.

When the temperature is constant all work fine.

I have tried:
  • 5V to VDC
  • 2,2k resistor
  • Clean install of raspbian on new SD card

pcmanbob
Posts: 4544
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Multiple DS18B20 temperature sensors

Tue Nov 13, 2018 12:34 pm

Hi.

Possible causes that spring to mind are:

1. A fault in your wiring, bad joint , bad cable etc
2 . Extremely long cables between pi and DS18B20
3. Interference when using log cables, were your sensor cable is picking up induced voltages from near by cabling/devices
4. Bad or wrong version of sensor, some versions don't have the power pin connected internally.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

nemo92
Posts: 2
Joined: Mon Nov 12, 2018 5:03 pm
Location: Slovenia

Re: Multiple DS18B20 temperature sensors

Tue Nov 13, 2018 8:00 pm

I solved the problem with rebalancing sensors per-pin based on cable length (5 sensors on pin 4 and 3 sensors on pin 17).
Thanks for the help.

Return to “Advanced users”