Darranking
Posts: 46
Joined: Thu May 31, 2012 9:14 pm
Location: UK

Joining multiple DS18B20 sensors

Sun Jan 13, 2019 4:11 pm

I have been looking at using multiple 1 wire temp sensors to read temperatures in some vivariums, I am ok with the Pi end and reading the sensors, but looking for some advise on the cabling side.

The internet suggest I should daisy chain these, and as my overall lengths are not great distance use cat 5 cable. I have sensors that are already on 1m cables but nothing attached to the other end.

So if I run cat 5 to the first vivarium, then join the sensorcable to it and then more cat 5 to the next one and repeat is that daisy chaining. I would use a small junction box with screw clamp connectors to join the incoming cable with the sensor cable and the outgoing cable.

Or am I creating a star set up doing it this way.

Help appreciated.

User avatar
rpdom
Posts: 17447
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Joining multiple DS18B20 sensors

Sun Jan 13, 2019 4:17 pm

That sounds like the correct way to do it.

JohnsUPS
Posts: 182
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Joining multiple DS18B20 sensors

Sun Jan 13, 2019 7:51 pm

You want to wire all of the sensors in parallel. This will avoid the star topology, and you can go quite a distance. I currently have an installation of five DS18B20 sensors along 369 feet of CAT6, and they are working flawlessly.

Wired like so:
At each sensor, there is a 10ufd tantalum capacitor across Vcc & Gnd. These are NOT the parasitic type sensors.
CAT6 cable (CAT5e would also be fine). The pairs within the cable are connected together:
ORG/ORG+WHT connected together, and is used for 5V Vcc to each sensor.
BLU/BLU+WHT connected together, and is used for the data connection.
BRN/BRN+WHT & GRN/GRN+WHT all connected together and is the ground connection.
Notice that the twisted pairs are connected together. This is done to reduce inter-electrode capacitance, especially on the data line.
A DS2482-100 1-wire driver (using 5V Vcc) for driving the data line.
The chip uses I2C, so 5v to 3.3V level shifting is done on the I2C lines to the Pi.
Small Python script then reads then data and populates an RRDTool Database.

As an alternate solution, there is a DS2482-800 driver chip with eight channels. You could run one sensor off of each channel. This may provide more flexibility in your layout if the number of sensors is likely to change, or if the sensor locations are moved.

chadk5utc
Posts: 10
Joined: Wed Dec 26, 2018 4:34 pm

Re: Joining multiple DS18B20 sensors

Sun Jan 13, 2019 9:26 pm

mutitempcircuit (1).jpg
mutitempcircuit (1).jpg (20.41 KiB) Viewed 2919 times
add cat5 or other wire as needed

User avatar
rpdom
Posts: 17447
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Joining multiple DS18B20 sensors

Sun Jan 13, 2019 9:35 pm

chadk5utc wrote:
Sun Jan 13, 2019 9:26 pm
mutitempcircuit (1).jpg add cat5 or other wire as needed
Wrong! Only one 4.7K Ohm resistor is required. Using more than one will cause problems.

Darranking
Posts: 46
Joined: Thu May 31, 2012 9:14 pm
Location: UK

Re: Joining multiple DS18B20 sensors

Sun Jan 13, 2019 9:46 pm

JohnsUPS wrote:
Sun Jan 13, 2019 7:51 pm
You want to wire all of the sensors in parallel. This will avoid the star topology, and you can go quite a distance. I currently have an installation of five DS18B20 sensors along 369 feet of CAT6, and they are working flawlessly.

Wired like so:
At each sensor, there is a 10ufd tantalum capacitor across Vcc & Gnd. These are NOT the parasitic type sensors.
CAT6 cable (CAT5e would also be fine). The pairs within the cable are connected together:
ORG/ORG+WHT connected together, and is used for 5V Vcc to each sensor.
BLU/BLU+WHT connected together, and is used for the data connection.
BRN/BRN+WHT & GRN/GRN+WHT all connected together and is the ground connection.
Notice that the twisted pairs are connected together. This is done to reduce inter-electrode capacitance, especially on the data line.
A DS2482-100 1-wire driver (using 5V Vcc) for driving the data line.
The chip uses I2C, so 5v to 3.3V level shifting is done on the I2C lines to the Pi.
Small Python script then reads then data and populates an RRDTool Database.

As an alternate solution, there is a DS2482-800 driver chip with eight channels. You could run one sensor off of each channel. This may provide more flexibility in your layout if the number of sensors is likely to change, or if the sensor locations are moved.
Cool, so how is each sensor connected in this setup do you wire in and out cat 6 to the pins of the sensor ?

Alex Konshin
Posts: 46
Joined: Sun Jan 29, 2017 10:02 pm
Location: Boston MA, USA

Re: Joining multiple DS18B20 sensors

Sun Jan 13, 2019 10:57 pm


prairietech
Posts: 28
Joined: Wed Mar 20, 2013 9:22 pm

Re: Joining multiple DS18B20 sensors

Mon Jan 14, 2019 2:52 am

Is the DS2482 used to obtain the 369' or is it just the DS18B20 sensors driving this distance?

JohnsUPS wrote:
Sun Jan 13, 2019 7:51 pm
You want to wire all of the sensors in parallel. This will avoid the star topology, and you can go quite a distance. I currently have an installation of five DS18B20 sensors along 369 feet of CAT6, and they are working flawlessly.

Wired like so:
At each sensor, there is a 10ufd tantalum capacitor across Vcc & Gnd. These are NOT the parasitic type sensors.
CAT6 cable (CAT5e would also be fine). The pairs within the cable are connected together:
ORG/ORG+WHT connected together, and is used for 5V Vcc to each sensor.
BLU/BLU+WHT connected together, and is used for the data connection.
BRN/BRN+WHT & GRN/GRN+WHT all connected together and is the ground connection.
Notice that the twisted pairs are connected together. This is done to reduce inter-electrode capacitance, especially on the data line.
A DS2482-100 1-wire driver (using 5V Vcc) for driving the data line.
The chip uses I2C, so 5v to 3.3V level shifting is done on the I2C lines to the Pi.
Small Python script then reads then data and populates an RRDTool Database.

As an alternate solution, there is a DS2482-800 driver chip with eight channels. You could run one sensor off of each channel. This may provide more flexibility in your layout if the number of sensors is likely to change, or if the sensor locations are moved.

JohnsUPS
Posts: 182
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Joining multiple DS18B20 sensors

Wed Jan 16, 2019 2:27 am

Prarietech, yes, the DS2482 is driving the line the whole distance. Also keep in mind that some of the time the driver chip is driving the wire, and sometimes the DS18B20 is driving the wire, so the devices at each end have to be able to drive the whole distance at some point in time. This is why the driver chip and sensors are powered from 5 volts instead of 3v3. This is also the reason that I use a driver chip, and do not drive from the GPIO pin directly. The driver chip also protects the GPIO pin in case a transient were to find its way back down the line towards the Pi.

Because the DS18B20's also have to drive the line the whole way back that I put a capacitor at each sensor (10ufd/16v tantalum). The capacitor supplies an extra bit of power to the sensor (right AT the sensor - this is important) when needed to drive the line.
Each sensor was wired like the pic, and a regular RJ45 plug attached to to a pigtail on the sensor per AT568B. The keystone is wired the same way, so sensors can be added/removed/replaced as needed just by plugging them in. Note that in the picture that the keystone is just tapped into the line. I stripped about four inches of insulation off, separated the wires and carefully punched it down. This effectively puts all of the sensors in parallel. My installation has five keystones along the 369 foot length. Along this length, there is a sensor at the end, and ones spaced at about ~340, ~320, ~300 and ~280 foot marks from the driver chip. The far end of the wire goes to the DS2482 (data wires), and of course +5 and ground.

When I was initially designing and testing this, I was using 470 feet of CAT6 wire, and it worked perfectly at that distance too.

The first pic shows the soldering detail of one sensor. An 8 inch pigtail was being soldered onto the sensor.
The second pic shows the keystone tap detail. I took this when I was doing the actual installation.

Image
Image

prairietech
Posts: 28
Joined: Wed Mar 20, 2013 9:22 pm

Re: Joining multiple DS18B20 sensors

Wed Jan 16, 2019 3:54 am

Great information! Several months ago I spent a far amount of time googling how to extend the distance of ds18b20s. But never found anyone with your success. I understand the cat5 pairs wiring configuration but am not clear on the physical layout of the ds18b20s in relationship to the ds2482?

You mention sometimes the ds2482 is driving and also the ds18b20s. But doesn't the ds2482 convert data from the 1-wire format to i2c so isn't it the only device pushing data to the RPi?

Sorry to be dense but maybe a simple drawing showing the physical relationship between devices might clear the fog in my head.

JohnsUPS
Posts: 182
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Joining multiple DS18B20 sensors

Wed Jan 16, 2019 12:14 pm

I'll try tp post a schematic. Can't do it right now though.
When I was referring to "driving the wire", I am referring to the long length of wire from the driver to the sensors. The Pi only talks to the driver chip (DS2482-100 in this case) using I2C through a couple of level shifters, as the chip is powered from 5V.

Basically wired like so:
[Pi] ------(level shifter/I2C)-----> [DS2482] ------------(1 wire over CAT cable)-------------------------------->[sensor] ----->[sensor] ----->[sensor] ----->........

Note that the sensors are not wired to any GPIO pin directly, but via the driver. In a real world installation, you really don't want to connect long wires in an electrically noisy environment directly to the Pi. It is OK for develoment purposes and non-critical short run installations, but personally I like to protect the inputs on the Pi in some way or another, either with a resistor, transister buffer, or in this case a driver chip made for that purpose. I also have protection diodes on the data line (low capactance types) also.

prairietech
Posts: 28
Joined: Wed Mar 20, 2013 9:22 pm

Re: Joining multiple DS18B20 sensors

Wed Jan 16, 2019 1:19 pm

Thanks! A picture is worth a 1000 words as they say.
In your application, is the ds2482 close to the RPi or is it a distance down the line?
A schematic would be great too. I appreciate your information and sure there are other readers that do too.

JohnsUPS
Posts: 182
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Joining multiple DS18B20 sensors

Thu Jan 17, 2019 4:05 am

Prarietech, The driver chip is at the end of the line, near the Pi. In my application, it is in the same project enclosure as the Pi. I2C is a protocol that isn't designed to work over distance. It was developed for inter-chip communication, implying that the runs are generally short - on the order of inches to a few feet usually. Maybe someone out there has experimented with this, but I haven't.

This is how I have things wired:
I omitted the category color code on the schematic, but the twisted pairs are connected as I have described in previous posts.
Image

Good luck!

prairietech
Posts: 28
Joined: Wed Mar 20, 2013 9:22 pm

Re: Joining multiple DS18B20 sensors

Thu Jan 17, 2019 1:30 pm

Thanks!! Now your design is perfectly clear. I'm going to order a 3.3v to 5v level shifter and a ds2482-100 and give it a try. I've been saving reel end scraps of cat5 just for something like this.
Thanks again!

VirenS
Posts: 4
Joined: Sat Aug 15, 2020 2:01 am

Re: Joining multiple DS18B20 sensors

Sat Aug 15, 2020 4:54 am

JohnsUPS wrote:
Thu Jan 17, 2019 4:05 am
Prarietech, The driver chip is at the end of the line, near the Pi. In my application, it is in the same project enclosure as the Pi. I2C is a protocol that isn't designed to work over distance. It was developed for inter-chip communication, implying that the runs are generally short - on the order of inches to a few feet usually. Maybe someone out there has experimented with this, but I haven't.

This is how I have things wired:
I omitted the category color code on the schematic, but the twisted pairs are connected as I have described in previous posts.
Image

Good luck!
Hi John,

I have gone thru your all the posts regarding your data Center temperature monitoring project using DS18B20 sensors,, I must say, I’m very impressed with your research and knowledge on the subject!
I’m a beginner on Raspberry Pi and currently working on my first project.
I think your advice will be very beneficial for me in designing my solution which is very similar to yours but I will be using about 17 to 20 temp sensors to monitor temp in various refrigerators and freezers. pls suggest what’s the best mode to contact you? can you share your contact details where you are online most of the time??

Thanks
Or else you can ping me on my email Virender.s.thind@gmail.com

Thanks

JohnsUPS
Posts: 182
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Joining multiple DS18B20 sensors

Sun Aug 16, 2020 11:10 pm

Thank you VirenS for the kind words....
I frequent these forums on a regular basis to keep up with whats new, and to also learn from those with much more experience. There is a wealth of information on this site.

With that said, I would encourage you to post here where others can assist you as well. There are some really good/sharp people here that will steer you in the right direction if there is a problem. Of course I will chime in if needed.

17 to 20 sensors seems like a lot, but I recall that someone out there has about this many working. If the circuitry is right, I'm sure this can be achieved along one wire.

cleverca22
Posts: 1016
Joined: Sat Aug 18, 2012 2:33 pm

Re: Joining multiple DS18B20 sensors

Mon Aug 17, 2020 2:27 am

JohnsUPS wrote:
Wed Jan 16, 2019 2:27 am
Prarietech, yes, the DS2482 is driving the line the whole distance. Also keep in mind that some of the time the driver chip is driving the wire, and sometimes the DS18B20 is driving the wire, so the devices at each end have to be able to drive the whole distance at some point in time. This is why the driver chip and sensors are powered from 5 volts instead of 3v3. This is also the reason that I use a driver chip, and do not drive from the GPIO pin directly. The driver chip also protects the GPIO pin in case a transient were to find its way back down the line towards the Pi.
that likely explains why i had a lot of reliability issues with a bare pi+ds18b20, even over short distances

but when i use a bare 5v AVR, and telephone line going all over the house, it works perfectly

though i'm only driving 6 at once, not 20

VirenS
Posts: 4
Joined: Sat Aug 15, 2020 2:01 am

Re: Joining multiple DS18B20 sensors

Mon Aug 17, 2020 9:02 am

JohnsUPS wrote:
Sun Aug 16, 2020 11:10 pm
Thank you VirenS for the kind words....
I frequent these forums on a regular basis to keep up with whats new, and to also learn from those with much more experience. There is a wealth of information on this site.

With that said, I would encourage you to post here where others can assist you as well. There are some really good/sharp people here that will steer you in the right direction if there is a problem. Of course I will chime in if needed.

17 to 20 sensors seems like a lot, but I recall that someone out there has about this many working. If the circuitry is right, I'm sure this can be achieved along one wire.
Thanks for your response John!
My project requirements are: I want to monitor the temperature of 15 Freezers/Refrigerators and couple of Hotcases in a Grocery store.
1. All the fridges, Freezers and Hotcase are placed along the longer side (~20 mtr) as well as on the back wall (~8 mtrs) of the store and the controller / router are placed on the opposite side of the back wall, which means its a clean run of a single Cat5 cable starting from 1st device to the last and then enter into the controller.
2. I am expecting Cat6 cable length of max 50 mtrs (including vertical rise & drops) and the Temp sensors will be connected throughout the length of the CAT6 cable with an extension of about 1.5 mtr from the joint (for the wire to run inside the appliance where sensor will be placed). I have attached a highlevel floor plan of the store to show how various appliances are placed and how the cable will be run!
3. I have seen you Datacentre design where you have used 5 DS18B20 sensors along with a 1-wire master driver_DS2482S-100 where you have also mentioned that you have tested your setup successfully with the Cat6 cable spool of ~470 mtrs.
4. Now, pls suggest me if my setup will also work with the 1-wire sensors connected to RPi thru a 1-wire master driver?? And also, is your setup working fine since you have installed? I have already ordered the Maxim branded sensors & DS2482 driver- from digi-key!
5. Can you also share your code which you used for the data centre!

Looking forward for your comments and any further suggestions from you on my setup.

I am also very open and keen to hear from anyone on this forum to get some advise on a workable solution for my setup!
Store_floorplan.JPG
Store_floorplan.JPG (26.65 KiB) Viewed 445 times
thanks
Viren

JohnsUPS
Posts: 182
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Joining multiple DS18B20 sensors

Mon Aug 17, 2020 12:12 pm

I see this as doable, however my first concern would be to try to limit the length of the stubs that run off of the main trunk line, especially because there will be so many of them.

In the data center, I wanted to provide a service loop for each sensor. Instead of running an extended stub off of the main trunk line, I simply ran the main line an extra 15 feet or so down to the connector (an RJ45 keystone in my case) and then back up again. Doing so kept the stubs (length after the connector) down to less than a foot, and still created a 'stub' of sorts, allowing for the sensor to be relocated a distance from the run of the main trunk line if necessary.
This 'doubling up' of the trunk line in lieu of stubbing it out was to prevent unwanted signal reflections in the event the stubs were too long. I knew that the driver could drive the distance, so I wasn't too worried about the added length.
You may be able to do something similiar if you find that the stub length is getting long.

https://i.pinimg.com/originals/3a/f1/0d ... a80b24.jpg

What you could do prior to any kind of installation would be to experiment. Measure how long the main line is going to be, and then attach your stubs off of that at the approximate intervals you expect to see in the field. This will give you an opportunity (and some confidence) to know everything is working prior to installing. It would also be a good setup for developing your code.

Be wary of running the trunk line near motors and any wiring that is carrying high current, as this could corrupt the data.
Last edited by JohnsUPS on Wed Aug 19, 2020 10:27 pm, edited 1 time in total.

VirenS
Posts: 4
Joined: Sat Aug 15, 2020 2:01 am

Re: Joining multiple DS18B20 sensors

Tue Aug 18, 2020 2:23 pm

JohnsUPS wrote:
Mon Aug 17, 2020 12:12 pm
I see this as doable, however my first concern would be to try to limit the length of the stubs that run off of the main trunk line, especially because there will be so many of them.

In the data center, I wanted to provide a service loop for each sensor. Instead of running an extended stub off of the main trunk line, I simply ran the main line an extra 15 feet or so down to the connector (an RJ45 keystone in my case) and then back up again. Doing so kept the stubs (length after the connector) down to less than a foot, and still created a 'stub' of sorts, allowing for the sensor to be relocated a distance from the run of the main trunk line if necessary.
This 'doubling up' of the trunk line in lieu of stubbing it out was to prevent unwanted signal reflections in the event the stubs were too long. I knew that the driver could drive the distance, so I wasn't too worried about the added length.
You may be able to do something similiar if you find that the stub length is getting long.

What you could do prior to any kind of installation would be to experiment. Measure how long the main line is going to be, and then attach your stubs off of that at the approximate intervals you expect to see in the field. This will give you an opportunity (and some confidence) to know everything is working prior to installing. It would also be a good setup for developing your code.

Be wary of running the trunk line near motors and any wiring that is carrying high current, as this could corrupt the data.
That’s wonderful, I fully understand what you mean now.
I think it will be easy for me to take the trunk line inside the refrigerator unit (while keeping it away from the power line / motors) and keep sensor stub to be as short as possible.

Distance from 1 fridge to the other will be less than 2 Mtrs, what’s your suggestion on how much trunk cable length should be kept between any 2 sensors to avoid any signal reflections / harmonics.
I am expecting my material to arrive in a week or so,, I’m very eager to create a test bed and see the results.

John, can you pls share your codes as it will help me to understand the logical part properly,, specially codes/sketches used for the communications between Pi, ds2482 driver and the sensors.

Thanks
Viren

JohnsUPS
Posts: 182
Joined: Fri Jul 06, 2018 2:13 am
Location: USA

Re: Joining multiple DS18B20 sensors

Wed Aug 19, 2020 11:04 pm

VirenS,
These are the two guides that I used for reference when planning out the network.
I found the Springbok document helpful.
With regards to your network, look at the bottom of page 30 where it talks about reflected signals and the placement of the sensors along the trunk (avoid placing them at exact integer fractions of the line length). I suspect that these two topics are the root of many "unexplained" problems when it comes to 1-wire. Category cable is usually marked with its length about every two feet or so to make it easier to know where you're at.
I would suspect that a length of ~30 meters using a driver powered by 5 volts (be sure to have voltage level translators on the I2C lines to the Pi) should work fine.

FWIW, there are a lot of fake DS18B20's out there - be sure to source from a reputable chip house (someone who deals directly with Dallas/Maxim) and not from a secondary source such as eBay or Bangood. I ran into fakes that were way out of tolerance. Spend a buck more and save the headaches.

Do not use the parasitic type of sensor (DS18B20-PAR). While they may be OK in some instances, like space or wiring constrained applications, you buy better odds for reliable performance with the regular parts.

https://dutta.csc.ncsu.edu/csc453_sprin ... 20v1.0.pdf

https://www.maximintegrated.com/en/desi ... 1/148.html

VirenS
Posts: 4
Joined: Sat Aug 15, 2020 2:01 am

Re: Joining multiple DS18B20 sensors

Thu Aug 20, 2020 1:00 am

JohnsUPS wrote:
Wed Aug 19, 2020 11:04 pm
VirenS,
These are the two guides that I used for reference when planning out the network.
I found the Springbok document helpful.
With regards to your network, look at the bottom of page 30 where it talks about reflected signals and the placement of the sensors along the trunk (avoid placing them at exact integer fractions of the line length). I suspect that these two topics are the root of many "unexplained" problems when it comes to 1-wire. Category cable is usually marked with its length about every two feet or so to make it easier to know where you're at.
I would suspect that a length of ~30 meters using a driver powered by 5 volts (be sure to have voltage level translators on the I2C lines to the Pi) should work fine.

FWIW, there are a lot of fake DS18B20's out there - be sure to source from a reputable chip house (someone who deals directly with Dallas/Maxim) and not from a secondary source such as eBay or Bangood. I ran into fakes that were way out of tolerance. Spend a buck more and save the headaches.

Do not use the parasitic type of sensor (DS18B20-PAR). While they may be OK in some instances, like space or wiring constrained applications, you buy better odds for reliable performance with the regular parts.

https://dutta.csc.ncsu.edu/csc453_sprin ... 20v1.0.pdf

https://www.maximintegrated.com/en/desi ... 1/148.html
Thanks a lot for sharing the guides John,, really appreciate that! I will go thru them and design my network accordingly..

Return to “Automation, sensing and robotics”