simpic01
Posts: 7
Joined: Thu Dec 19, 2013 2:07 pm

Multiple DS18B20 reading isues

Fri Dec 27, 2013 5:35 pm

Hello,

I have a series of DS18B20 temp sensors hooked up to a Pi and am collecting the data in a RRD to graph.

All is working fine for a max of seven sensors then the issues start, I can not seem to connect any more sensors as when I run the cat command...

Code: Select all

cat /sys/bus/w1/devices/28-*/w1-slave


The sensors start to fail with a NO and then it stops getting a reading from any of them.

I have tried with several different sensors to ensure it is not a duff one. Seems to be too many.

Between GPIO 4 and 3.3v there is a single 4.7k pullup resistor.

Would using a different resistor help?

anita2r
Posts: 226
Joined: Sun Dec 23, 2012 6:55 pm
Location: Ottawa, Canada

Re: Multiple DS18B20 reading isues

Fri Dec 27, 2013 6:48 pm

Hi,

The first thing I would look at is the wiring.

1. What type of cable are you using for the 1-wire network
2. If you are using a twisted wire pairs cable such as cat 5 ethernet cable, which connections from the Pi use which wires
3. If using cable with unused wires, have you left them unattached or are they grounded
4. What is the connection pattern - are all 7 sensors on one long cable, or are they individually wired in a star formation.

Small improvements in the 1-wire network can make big differences to performance. There should be no problem with ten sensors on the network if the cabling is OK.

Also are you confident that the power supply to the Pi is sufficient. Although the sensors use very little power, a marginal power supply might be the culprit.

I wouldn't change the resistor value until you have got the wiring into shape.

Regards

anita2R

simpic01
Posts: 7
Joined: Thu Dec 19, 2013 2:07 pm

Re: Multiple DS18B20 reading isues

Sat Dec 28, 2013 9:54 am

Hello,

I had wondered about the wiring.

It's a little fudged to say the least.

Straight from the breadboard there are three five way connectors linked to the five sensors in the tank.

Also an 'extension' runs from there to where the other sensors are. It's about 2m of standard three core flex you might see on any electrical device plug tail. This then splits into the other two sensors.

When I try and either add another sensor to that extension or direct to the bread board it all messes up.

I have a big roll of CAT5e that I could use instead, what is the best way of doing all the splits for the connectors? Happy to spend some money on proper connectors. I have RJ45 plugs and a crimping tool, but I'm not too sure how to 'link' them, could you use a switch dedicated for this only? With no power to it?

Thanks in advance.

anita2r
Posts: 226
Joined: Sun Dec 23, 2012 6:55 pm
Location: Ottawa, Canada

Re: Multiple DS18B20 reading isues

Sat Dec 28, 2013 3:05 pm

Hi,

From your description I would put my money on your cabling being the issue. The system can 'just' cope with the line conditions, but just one more sensor and it goes out of specification and fails.

Use the Cat5 cable.

Use one pair for data and ground and use one wire from another pair for 3.3volts
Leave all other wires unattached - don't connect them to ground
Don't be tempted to 'double up' wires to reduce the resistance - it increases the capacitance of the network which is a real killer

You do not need any special connectors - just solder wires together - but keep the untwisted wire to a minimum at the joints.

As far as possible, design your network so that there is a single route from the Pi or the breadboard to close to each sensor, with sensors on short stubs of Cat5 wire off the main route.

Once you have it wired-up and working, you will likely still see random errors & these can be handled in software with automatic re-reads.

If you are interested in a bash script for handling the data and the errors look at the code posted in this response:
http://www.raspberrypi.org/phpBB3/viewt ... 21#p467921 and the notes following the code.

It includes an error log which may help identify if one part of the network or one sensor is causing more problems.

Regards

anita2R

User avatar
FLYFISH TECHNOLOGIES
Posts: 1750
Joined: Thu Oct 03, 2013 7:48 am
Location: Ljubljana, Slovenia
Contact: Website

Re: Multiple DS18B20 reading isues

Sat Dec 28, 2013 6:08 pm

Hi,
anita2r wrote:Leave all other wires unattached - don't connect them to ground
Ok, it is obviously why connecting them to ground on both sides must be avoided, but how about connecting them on one side only ?

I can briefly remember one article years ago about this one-side connection guideline. Additionally, it listed a detail that this junction should be at the receiver side in case of simplex communication, else on the side closer to the power supply.

What do you think ?


Best wishes, Ivan Zilic.
Running out of GPIO pins and/or need to read analog values?
Solution: http://www.flyfish-tech.com/FF32

anita2r
Posts: 226
Joined: Sun Dec 23, 2012 6:55 pm
Location: Ottawa, Canada

Re: Multiple DS18B20 reading isues

Sat Dec 28, 2013 7:12 pm

Hi Ivan,
Leave all other wires unattached - don't connect them to ground
This information comes from a document about 1-wire networks http://www.1wire.org/Files/Articles/1-W ... 20v1.0.pdf
This is the relevant sentence:
Because grounding unused wires or shields in a cable adds capacitance, which
can significantly increase the RC time constant, they should be left disconnected. You
want to limit capacitance throughout a 1-wire system as much as possible to maximize
cable length and limit RC effects.
I am aware that in many systems, grounding at one end is appropriate - but for 1-wire it's the capacitance effect that is critical, rather than any shielding benefit.

From what I have read, increasing capacitance changes the timing and waveform shape. Added capacitance increases the time it takes the line to change from zero to its high voltage (3.3 or 5v) which means that the transition and resultant pulse exceed the limits for the slave devices (sensors), so they don't respond.

Using an active pull-up rather than the passive pull-up resistor helps overcome this. On large or long cable run networks, an active pull-up device becomes essential, for example Embedded Systems HA7s device.
The active pull-up allows a higher current flow just when needed - rather like charging a capacitor directly from a supply rather than through a resistor. As a result the voltage change is more rapid and the transition and pulse remain within specification.

I am not an electronics engineer, so what I have posted is my interpretation of what I have read :)

Regards

anita2R

simpic01
Posts: 7
Joined: Thu Dec 19, 2013 2:07 pm

Re: Multiple DS18B20 reading isues

Sat Jan 04, 2014 2:09 pm

Hello,

I'm still having issues with more than six sensors now.

I have changes the wiring to be as follows.

Pi
=> Breakout GPIO Board
=> Three wires from the jumpers (3.3v, GND & PIN4, 4.7k Resistor across 3.3v & PIN4 in the jumpers) to three CAT5 strands soldered
=> Short CAT5 to patch panel, the three connected wires are connected via the punch down terminals on the back of the patch panel across 10 sockets (all tested individually with one sensor to prove the connections. Test passed)
=> Each sensor is soldered to a CAT5 cable on one end with a RJ45 connector on the other, then plugged into the patch panel

So effectively I have a bus wiring system. The CAT5 from the patch panel to the sensors ranges from 500mm to 3000mm.

The issues start when I connect more than six sensors, doesn't matter which sensor or in which socket, I lose the readings when using the cat command on the Pi.

I have changed the power supply to the Pi and this has made no difference.

Next option it to look at using a powered breadboard rather than drawing power from the Pi. Do you think this will help?

Or do I need to look at using a different wiring system?

Any suggestions are most welcome as this is doing my head in!!!

achrn
Posts: 408
Joined: Wed Feb 13, 2013 1:22 pm

Re: Multiple DS18B20 reading isues

Sat Jan 04, 2014 4:00 pm

You've got a star topology (which 1wire doesn't like) and you're running at 3.3V (DS18B20 min voltage is 3V). Both are things that should work if other matters are good, but you're near the edge of the performance envelope in multiple parameters, then bit-banging with passive pull-ups.

Personally, I'd put an active bus-master on the Pi.

Actually, I have put an active bus-master on my Pi, to run a 10-sensor bus. I use http://www.sheepwalkelectronics.co.uk/p ... ucts_id=33 which has eight 1-wire buses, but for what you've described I think http://www.sheepwalkelectronics.co.uk/p ... ucts_id=30 with one bus will do what you want. £14 assembled, £9 if you think you can solder the SMD chips yourself (presumably plus P&P). This uses a dedicated hardware driver for the 1-wire bus that does clever stuff like active pull-up with slew-rate control, and so on, and drives the 1-wire bus at 5V (with level shifters on-board for the I2C to the Pi).

You will need to change your software, but if you use OWFS the sensors will still show up as devices in the filesystem, so anything that works by reading a file to get a temperature should still work if you can tell it a different place to find the file.


anita2r
Posts: 226
Joined: Sun Dec 23, 2012 6:55 pm
Location: Ottawa, Canada

Re: Multiple DS18B20 reading isues

Sat Jan 04, 2014 7:01 pm

Hi,

As achrn says, you have created a Star topology. In my previous post I suggested that you use a single route:
As far as possible, design your network so that there is a single route from the Pi or the breadboard to close to each sensor, with sensors on short stubs of Cat5 wire off the main route.
Did you use a twisted pair for the data and ground? Your description:
to three CAT5 strands
sounds as though you have used three independent wires
The cat5 cable is only of value if you use a twisted pair for the data circuit - data & ground.

When you used the RJ45 connectors did you connect all 8 wires to the RJ45.
If so you have not left the unused wires unconnected - the advice is clear - leave unused wires unconnected.

As to 3.3v - I have run 11 sensors off a Pi - albeit with some temperature read failures - but all 11 devices were consistently detected over a period of many months, reading the sensors every 5 mins, 24 hours a day. So I doubt that using 3.3volts is your issue.

As before - use a single cable route.
A single cable route is better than using star or branching arrangements even if it results in a greater total length of cable.

You can use an active 1-wire bus master - such as one connecting through I2C as mentioned by achrn, a usb device or one that communicates with the Pi through the serial connection (UART) as I mentioned before. These devices may allow a poorly designed 1-wire network to work, but later on when you add more sensors, your problems will start again. It is really worthwhile getting the cabling right from the start.

Regards

anita2R

simpic01
Posts: 7
Joined: Thu Dec 19, 2013 2:07 pm

Re: Multiple DS18B20 reading isues

Sun Jan 05, 2014 10:40 am

Thanks for the advice again folks.

anitaR2,

I have used white/blue for the data and blue for the GND with brown for the power 3.3v. The white/blue and blue are twisted, as are the rest of the strands still.

On the connectors I have inserted all eight strands as it was easier to do, but there are no connections on the back of the patch panel apart from the three connected strands. I will practice making a couple of three stand only RJ45 connections then change them to see the difference.

It appears that the method of connecting all the sensors to the patch panel making a star topology could be the real issue. If I change to a single route I have one question? Do I need to join the end back to the start to make a loop or just have the furthest sensor and the end connection?

In practice this would be one long run of CAT5 cable cut where the sensors are and the sensor tail soldered there in a three way connection?

Regards,

Simpic

achrn
Posts: 408
Joined: Wed Feb 13, 2013 1:22 pm

Re: Multiple DS18B20 reading isues

Sun Jan 05, 2014 5:15 pm

simpic01 wrote: It appears that the method of connecting all the sensors to the patch panel making a star topology could be the real issue. If I change to a single route I have one question? Do I need to join the end back to the start to make a loop or just have the furthest sensor and the end connection?
If you're doing it with networking cable, yes.

When I've done that I wire as follows:

At the panel:
pin 2 all sockets together in parallel, connected to +5V supply
1-wire data to pin 4 of first socket
1-wire ground to pin 5 of first socket
pin 6 of first socket to pin 4 of second socket
pin 3 of first socket to pin 5 of second socket
pin 6 of second socket to pin 4 of third socket
pin 3 of second socket to pin 5 of third socket
etc.

My sensor cables at the patch panel end are wired up with standard T-568B network cables, which means 2-orange, 3-green/w, 4-blue, 5-blue/w, 6-green.

My sensor cables at the sensor end are wired orange to sensor power (5V), blue and green both to sensor data pin, blue/w and green/w both to sensor ground pin.

This basically gives you a bus with the blue pair is taking signals from the patch panel to a sensor and the green pair is bringing it back to the patch panel. At the patch panel you either need shorting plugs which are just dummy cables with blue and green shorted together and blue/w and green/w shorted together, or you need to make sure you populate the sockets from the first upwards with no gaps.

There's something else you can try if you don't fancy re-wiring all your sensors - a trick for star topologies. Put a 150-ohm resistor at the base of each star arm on the data wire only. That is, on your setup, you'd disconnect your data wire from the back of each socket, and in its place punch in one leg of a 150 ohm resistor at each socket. Then you'd connect up all the other ends of the resistors with a wire that goes to the Pi. One and only one resistor should be in the signal path between the host adaptor (ie Pi) and each sensor, so if you had two sensors up a single wire, you'd still only have the single resistor at the panel. I don't know why it helps (my analogue electronics knowledge doesn't extend that far), but apparently it does.





This wiring scheme is compatible with a number of commercial systems - data on blue and ground on blue/w seems teh most common system, with power supply on orange. Some devices propose an auxillary 5V supply on teh green pair - by wiring using that pair as the 'data return' at least you don't introduce anything more than 5V onto teh data bus. Some devices propose teh brown pair as an auxillary 12V supply, so you don't want to use that pair.

anita2r
Posts: 226
Joined: Sun Dec 23, 2012 6:55 pm
Location: Ottawa, Canada

Re: Multiple DS18B20 reading isues

Sun Jan 05, 2014 6:24 pm

Hi,

I have not seen any advice that suggests looping the end back to the beginning.

I would leave it with the last sensor at the end of the last cable from your patch panel.

achrn's approach using out on one pair and back on another pair sounds good.

One other point: achrn refers to using 5volts - but as you are wiring direct to the Pi, use 3.3volts

Are all your sensors in totally different directions? If not wouldn't it be easier to run your cat5 cable from sensor to sensor, without going back to a patch panel each time.

Regards

anita2R

achrn
Posts: 408
Joined: Wed Feb 13, 2013 1:22 pm

Re: Multiple DS18B20 reading isues

Sun Jan 05, 2014 10:19 pm

Anita's answer made me re-read the question, and I realise I mis-read it teh first time. You need to loop from the patch to a sensor and back (which was the wiring I described) if you're going to make it a linear topology, but you should not make a complete loop from the last sensor back to the bus controller- just stop at the last sensor (or when you get back to the patch panel if you've wired all your sensors the same).

Also, yes - if you're driving direct from Pi GPIO all my references to 5V should be 3.3V - I meant 'power supply', it's just that I always drive at 5V (since I generally use dedicated driver hardware, or occasionally bit-banging from arduinos).

overheder
Posts: 4
Joined: Wed Jan 21, 2015 6:08 pm

Re: Multiple DS18B20 reading isues

Wed Jan 21, 2015 6:22 pm

This was a great read, I have done some experiments with my RPI and a bunch of DS18B20's.

I have found an interesting artefact, here's the setup

RPI- 10 meters of cat 6 - 10 K ohm, - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - 10 K ohm.
(all in parallell as described in various places)
Working like a charm!

When I move the first section to the RPI I get this configuration:
RPI- 10 K ohm, - DS 18B20 -10 meters of cat 6 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - 10 K ohm.

The system still works - for a few minutes, and then suddenly there are no sensors found anymore. I tried adding a small capacitor at the far end, I tried a few different resistor values, but it is pretty consistent, that when I add the sensor close to the RPI, the system fails. If I remove the first sensor or the last six sensors, the system springs to life.

Any ideas?

Henrik

anita2r
Posts: 226
Joined: Sun Dec 23, 2012 6:55 pm
Location: Ottawa, Canada

Re: Multiple DS18B20 reading isues

Thu Jan 22, 2015 2:54 pm

overheder wrote:This was a great read, I have done some experiments with my RPI and a bunch of DS18B20's.

I have found an interesting artefact, here's the setup

RPI- 10 meters of cat 6 - 10 K ohm, - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - 10 K ohm.
(all in parallell as described in various places)
Working like a charm!

When I move the first section to the RPI I get this configuration:
RPI- 10 K ohm, - DS 18B20 -10 meters of cat 6 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - DS 18B20 - 10 K ohm.

The system still works - for a few minutes, and then suddenly there are no sensors found anymore. I tried adding a small capacitor at the far end, I tried a few different resistor values, but it is pretty consistent, that when I add the sensor close to the RPI, the system fails. If I remove the first sensor or the last six sensors, the system springs to life.

Any ideas?

Henrik
Hi,
A number of questions:
1. Why are you using two 10K resistors.
The standard is a single 4.7K resistor at the Pi end of the cable
2. When you say parallel, do you mean that all the sensors are connected to a single cable.
3. How are the wires in your cable connected. Are you using one twisted pair as data and ground, with one single wire as power (3.3v) and are all the other wires disconnected (at both ends)

Comment re: capacitor:
Capacitance on a 1-wire system is a killer - more capacitance = poorer performance.

Comment on failure when arrangement of cabling/sensors is changed:
When a 1-wire system works, you don't know (unless you have sophisticated measurement equipment) whether the system is close to its limits, i.e. close to failure, but still working. A seemingly small change can make the difference between working and not working. So your change in arrangement suggests that your cabling/resistor setup, even when working, is marginal/close to failure.
I quote from a Maxim document, http://www.maximintegrated.com/en/app-n ... mvp/id/148 referring to failures when devices on the network disappear after minor changes, i.e. the Search function fails to find devices:
Search failures often appear to be highly sensitive to minor variations in the network; the slaves connected on the network; or "the phase of the moon," as some frustrated designers have been known to say. This sensitivity is because the network under scrutiny is in a borderline state, and very small network variations can cause searches to succeed or fail. Simply put, a network that appears to be successful because all the devices are reliably found in the search algorithm, can actually be near failure. Minor degradation can suddenly produce seemingly catastrophic failures—all it takes is one faulty bit to make a search stop, and parts disappear. Consequently, it is critical that the user adhere to published specifications and guidelines to assure reliable networks with good safety margins and tolerance of variations in cable, devices, and connections.
I suggest that you at least start with Dallas/Maxim's recommended configuration with a single 4.7K resistor at the source end of the cable. That should be fine for your setup with 6 or 7 temperature sensors. Use a single cable arrangement, with at most short stubs to each sensor along the main cable. Also just use one twisted pair for data and ground and one wire for 3.3V. Leave all other wires/ shields unconnected (at both ends).

I don't know enough about Cat 6 cable to know if it's better or worse than Cat 5 for 1-wire networks.

Regards

anita2R

overheder
Posts: 4
Joined: Wed Jan 21, 2015 6:08 pm

Re: Multiple DS18B20 reading isues

Thu Jan 22, 2015 7:30 pm

Thanks, good questions!
1 I started with a single 4.7k resistor, and changed to avoid 'mirroring'
2 yes, no star topology, the first sensor is two cm away, and using the same plug type
3 yes, that is my wiring up until the end of the cat 6, then there is 2meters of steel ribbon phone cable where the sensors are located to monitor my heating system

The capacitor was between 3.3v and ground. I have 3.3volts at the end of the cable

I tried looking at the signals with my scope, no luck/abilities

Henrik

Raspberry Paul
Posts: 85
Joined: Mon Jun 10, 2013 3:40 pm
Contact: Website

Re: Multiple DS18B20 reading isues

Thu Jan 22, 2015 8:28 pm

I was having similar issues when using 20 ds18b20's. They were connected randomly to stereo cables and Y splitters, lengths up to 20m. Started getting "NO", 85 degrees c etc

I bought an DS2482-800 8 Channel I2C to 1-Wire Master IC - http://www.sheepwalkelectronics.co.uk/p ... ucts_id=41

Some good documentation on their site on how to use it.

Each of the long cable runs is now attached to a dedicated port, with ones of similar distance sharing. No need for resisters etc.

Wish I'd done it sooner as I spent months trying to get it to work.
http://www.raspberrypaul.co.uk

User avatar
iinnovations
Posts: 621
Joined: Thu Jun 06, 2013 5:17 pm

Re: Multiple DS18B20 reading isues

Thu Jan 22, 2015 9:55 pm

I have seen this before. Cat5 is actually worse for 1Wire networks. Even flat cable is better.

If you must, you actually want to stay away from using the twisted pairs with the Data line at all. Twisted pair increases capacitance.

And, as mentioned previously, just use a 1Wire bus master. They're cheap and avoid all of this hullabaloo.

C
CuPID Controls :: Open Source browser-based sensor and device control
interfaceinnovations.org/cupidcontrols.html
cupidcontrols.com

overheder
Posts: 4
Joined: Wed Jan 21, 2015 6:08 pm

Re: Multiple DS18B20 reading isues

Sun Feb 01, 2015 8:29 pm

Buying extra equipment... nah, your tips led me to change the wiring: I had gnd on blue and signal on blue/white. I moved GND to green, so no twisted pairs used at all. This got the sensors working about 10% of the time. So I gave up, and disabled the near-RPI sensor, and got the system working

Thanks for the tips.

Henrik

brasta78
Posts: 7
Joined: Mon Sep 25, 2017 6:43 pm

Re: Multiple DS18B20 reading isues

Sun Oct 01, 2017 5:14 pm

I have unshielded CAT5 cable about 40m and 7 sensors DS18B20. GROUND is connected to 2 wires from different twisted pairs, last wires from these twist pairs are used for DATA and power. Between GPIO4 and 3.3v there is a 2.2k pullup resistor and I have correct data from last 2 sensors (one external) on the wire while one sensor in the middle always shows 85000. For me it started to work when I changed pullup resistor from 4,7k tu 2.2k. Below there is a grafh of this day and all days from start
Image

Return to “Automation, sensing and robotics”