I'd just like to document some of my journey on building and running what I thought was a simple 1-wire network. While most of the examples are very simple, and usually only 1 temperature sensor hooked up on a breadboard, this is a more real world example.
1-wire is a great protocol because it's simple, can be run over a variety of cable, and can run for relatively long distances (10s of meters). Compared with USB (maybe 3m), i2c and TTL logic (<1m), it provides a way to build a network that can easily encompass a room or multiple rooms of a house.
1-wire actually uses 3 wires. Power, ground, and 1 data wire. The 1-wire bus is a master/slave shared bus, in that all the devices are on the same bus, and can pull the bus low, or let it float high.
Of course, when the 1-wire bus is pulled low, either by a device, or by the host (a raspberry pi), this doesn't happen instantaneously, but goes quickly down each wire. The effects of the raising and lowering of the bus are different depending on the size of the network (how much conductive wire has to be pulled down), as well as the size of the network (longer wires take longer to propagate signals), and the shape of the network.
All of this can make things sound complicated, and they can be. The bible for these design considerations is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/148
Now I want to tell you about my 1-wire network, and what I've tried, and how it turned out.
First, cabling. Initially I started trying to use normal 4 conductor telephone wire. This stuff has proven to be a PITA. The gauge of wire is small, and hard to work with, strip, solder, or splice. I eventually went to CAT5 cable, which is much easier. The twisted pairs and increased wire gauge probably help with transmission problems. One important point is to only use 1 wire for the bus, don't use any wires you don't need. Tying those together is a recipe for wave reflections.
Junction boxes. 1-wire networks are supposed to not be in a star configuration per the document referenced above. But for short networks, it seems to be fine. I bought an RJ11 1-5 junction box, which allowed me to use RJ11 connectors and plug in individual sensors and remove them at will.
Overall, the junction boxes work great, but remember that each RJ11 junction crosses over wires 1-4 and wires 2-3. If you put a coupler and a junction box together, the crossovers cancel each other out, which is why I have a male cable from the pi. You can easily buy these boxes for <$10 at Home Depot.
Wiring. I picked the inside wires (2,3) to hold power and the signal, which are both 5V signals. GND is on pins 1-4. I did this because with any risk of crossover, you risk damaging or destroying the temperature sensors. If the 5V lines are crossed, you won't get connectivity, but the sensor will be fine.
Connectors. If you are running all your wires together, and splicing them yourself, you might not need connectors. I picked RJ11 connectors, because they allow me to use phone junction boxes. RJ45 connectors would require some kind of special board.
Interference. When you are running a 1-wire network, the biggest problems are related to interference. If your garden uses a high power lamp, try to route wires away from the ballast or the line from the ballast to the bulb. Both of these are quite noisy even on a good ballast. I've noticed that when the lights turn on, I have about 2 minutes until the network stabilizes, but it comes back on its own.
Waterproofing. I've noticed that some of the Adafruit DS18B20 sensors are not necessarily sealed completely. Putting one into a nutrient filled resevoir tank with a underwater pump has also caused interference. Sometimes the pumps themselves are not electrically sealed either, which can give just enough to knock the sensor off the network.
Length of wire. I've bought 100m of cable, and am using about half. I haven't noticed any problems with the length of wire of a sensor, and I could easily see it working over a house length. Try to avoid having all the sensors have the same length of wire, to avoid reflections gathering.
Parasitic power. One thing I wanted to do was be able to run on parasitic power. This means that the devices draw power from the data line (which floats high) instead of a dedicated 5V line. This would allow me to have an idiot proof connector where both pins 2-3 are data, and 1-4 are ground. Overall, I had nothing but trouble with this arrangement. DS18B20 sensors will draw extra current when doing a temperature conversion.
For the linux driver for ds18b20, you have to provide strong_pullup=1 as a kernel module parameter, otherwise your sensors will lose power during the conversion and return nothing. Even with that, adding extra instability wasn't worth it. I used an extra wire.
Overall I hope this real world 1-wire network example helps you design your own network, and feel free to ask any questions below.