paddyjoy
Posts: 3
Joined: Sun May 26, 2013 9:29 am

Trouble getting reliable one wire network

Sun May 26, 2013 12:32 pm

Hi,

I'm having trouble getting a reliable one wire network up and running on my raspberry pi and would appreciate any help.

I have 8 x DS18B20 temperature sensors installed at various points in my house. The sensors are connected back to a central location using cat5 cable. There are 4 lengths of cat5 cable between 5-15m long. Each cable has two sensors wired like this:

Orange - Vcc
White/Orange - Gnd
Brown - Data sensor 1
White/Brown - Not connected

Blue - Vcc
White/Blue - Gnd
Green - Data sensor 2
White/Green - Not connected

As I installed each sensor I tested it and they all worked correctly however when I connect all 8 sensors together (in a star configuration) no sensors are detected. When I add sensors one by one I can get about 4 sensors working together before the interface stops working. Doesn't matter which sensors I add and in which order it will always fail once I get to the fifth sensor. I am assuming that with more than 4 sensors connected there is too much interference/echoes on the network. I have also learned that the star configuration is the worst topology to use and that I probably should have put the data and gnd in the same twisted pair.

Does anyone have any what I can do other than rewiring the network, which will take me 2 days :-(

I was thinking of the following options.

1. Add an additional one wire bus on the pi so I have 4 sensors on each bus.
2. Multiplexing so I can read 4 sensors then switch the data line to read the other 4.

Any thoughts?

Thanks

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12661
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Trouble getting reliable one wire network

Sun May 26, 2013 12:40 pm

Any thoughts?
Use an oscilloscope to figure out what happens to the signal when you attach so many devices, then you can make an enlighted effort to solve it, instead of just trying things.

That said, its probably a power issue, as the single wire bus isn't only about communication, but also about power distribution.

Its really hard to "buffer" one wire networks, but you might try the level shifter technique used in I2C transfers, that might work.

paddyjoy
Posts: 3
Joined: Sun May 26, 2013 9:29 am

Re: Trouble getting reliable one wire network

Sun May 26, 2013 12:58 pm

mahjongg wrote:
Any thoughts?
Use an oscilloscope to figure out what happens to the signal when you attach so many devices, then you can make an enlighted effort to solve it, instead of just trying things.

That said, its probably a power issue, as the single wire bus isn't only about communication, but also about power distribution.

Its really hard to "buffer" one wire networks, but you might try the level shifter technique used in I2C transfers, that might work.
Thanks, unfortunately an oscilloscope is still on my wish list!

I did try increasing the voltage on the network to counter act any voltage drop but it didn't make a difference.

repton
Posts: 91
Joined: Sat Mar 17, 2012 6:06 pm
Location: North Yorkshire, UK.
Contact: Website

Re: Trouble getting reliable one wire network

Mon May 27, 2013 7:48 am

paddyjoy wrote:I have also learned that the star configuration is the worst topology to use and that I probably should have put the data and gnd in the same twisted pair.

Does anyone have any what I can do other than rewiring the network, which will take me 2 days :-(
As you've already worked out the issue is that the 1-Wire network is designed to work with a bus topology and not a star one.

Personally I would seriously consider rewiring it as even if you can get it so all the sensors are detected, you might well still find that when you come to take readings you get repeated errors making your data far less useful. I would wire the sensors as a bus with one pair for data and ground (blue for data and blue/white for ground if you're following the "standard" colour scheme that most 1-Wire vendors use) and another cable for power (orange to stick with the standard).

If that isn't an option, your options are a little limited, especially if you are on a budget.

One option would be to ditch the kernel based driver and use a Sheepwalk Electronics RPI3 bus master. That gives 8 1-Wire channels so you could connect one sensor to each channel and it should work perfectly. See http://www.sheepwalkelectronics.co.uk/RPI3.shtml.

Another would be to ditch the kernel based driver and use a DS9490R USB based 1-Wire master and Hobby Boards Hub (http://www.hobby-boards.com/store/produ ... l-Hub.html). That gives you 4 channels and you would probably find it works with two sensors connected to each.

HTH,
Paul

(Disclaimer: I run Sheepwalk Electronics so I'm probably biased towards that option.)
UK Supplier of 1-Wire components, kits and modules:
http://www.sheepwalkelectronics.co.uk/

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Trouble getting reliable one wire network

Mon May 27, 2013 9:17 am

Since the DS18x20 thermometers use a peak of 1.5mA when they are writing to their rom, and micro amps the rest of the time, power is rarely an issue (a thermometer doesn't work too well if it has a self heating effect). They don't like long runs of cable. The capacitance of the cables can screw up the communication. I've had some success with reducing the value of the pull up resistor(s) to 1k rather than the recommended 4.7k. Star topologies can work but put a pull up resistor on each leg at the end away from the host. (I'd stay with 4.7k for starters). My experience with them is mainly on Arduino, but I would imagine a lot of it will transfer to the Pi. (I think I bought most of mine from Sheepwalk, but I didn't put a board in just to handle them).
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

paddyjoy
Posts: 3
Joined: Sun May 26, 2013 9:29 am

Re: Trouble getting reliable one wire network

Mon May 27, 2013 1:48 pm

Thanks for all the suggestions, I managed to get this working reliably tonight by using a 1K pull up resistor, I previously had a 10k pull up. Amazing the difference changing the pull-up makes, all the data has been coming in error free for a couple of hours now compared to yesterday when it wouldn't even pick up the sensors.

Unless any major problems develop I won't do any rewiring and chalk this one up as a lesson learnt.

Thanks

repton
Posts: 91
Joined: Sat Mar 17, 2012 6:06 pm
Location: North Yorkshire, UK.
Contact: Website

Re: Trouble getting reliable one wire network

Mon May 27, 2013 7:40 pm

paddyjoy wrote:I managed to get this working reliably tonight by using a 1K pull up resistor
Well that's me having learnt something today then, I wouldn't have expected that to work!

Paul
UK Supplier of 1-Wire components, kits and modules:
http://www.sheepwalkelectronics.co.uk/

david.pearce
Posts: 1
Joined: Wed Oct 23, 2013 9:42 am

Re: Trouble getting reliable one wire network

Wed Oct 23, 2013 9:44 am

Hi, I am looking to setup the same sort of temperature capture network.
Would you be able to post the wiring diagram of how you connected the sensors please.
Many thanks
Dave

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: Trouble getting reliable one wire network

Wed Oct 23, 2013 11:30 am

david.pearce wrote: Would you be able to post the wiring diagram of how you connected the sensors please.
There is a circuit diagram in this blog post.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

Return to “Interfacing (DSI, CSI, I2C, etc.)”