Elddis
Posts: 1
Joined: Sat Jan 11, 2020 5:26 pm

20x DS18B20 Temperature Sensors with 20M cabling each

Sat Jan 11, 2020 6:10 pm

Hi all,

I'm a new comer to the Raspberry Pi scene.

I'm looking to create a device that can monitor up to 20 temperature sensors every 1 minute with 20 meters of cabling per sensor for my mini green-houses. The green houses are only about 1x1meter in length/width and are placed in groups, i.e. down the left hand side of the garden, right hand side and some in the house.

I've seen that the DS18B20 sensor uses the 1-Wire bus that allows multiple sensors, but it's only supposed to be used over short distances. The hardware supplier had provided the following guidance, although I'm still finding it somewhat cryptic.
https://www.maximintegrated.com/en/desi ... 1/148.html.

Using 20 sensors with 20 meters of cabling each would essentially give 400 meters of weight, which seems incredibly heavy.

Instead, I saw on the "Switched Networks" section of the supplier guidance that I could potentially isolate the temperature sensors in smaller groups and switch them on and off to reduce interference. Perhaps reduce them down to 5 sensors per group? I'm not entirely sure how I would go about creating that functionality to turn each group on then off in sequence? I might be way off the mark here.

I've attached a diagram on how the physical layout of the sensors is grouped. The green squares are the green houses and the red square is the Raspberry Pi. The reason I'm looking for 20 meters, is because the green houses often get moved, so it wouldn't be ideal if the cables are a fixed length. This would mean there is a lot more cable mess around though...

Image

I was planning on using the following:

[*] Raspberry Pi 3 Model B+.
[*] Edimax Wifi USB adapter so I can place it about 30 meters from the Internet router in the house.
[*] 20 x DS18B20 (waterproof) with 20 meter cable of CAT5 cable.
[*] Breadboard for inserting the CAT5 cable ends and hooking up to the Raspberry Pi.
[*] 4.7k pull-up resistor.

Any help would be greatly appreciated before I make a purchase of sensors.

Best regards,

Elddis

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

Re: 20x DS18B20 Temperature Sensors with 20M cabling each

Sat Jan 11, 2020 7:03 pm

Hi.

I would suggest spreading your sensors over 4 or may be more gpio pins to try and keep your cable runs as short as possible, even then you might have to resort to powering the sensors from 5V but still using a 3.3V pull up on the data pin to maintain compatibility with the pi gpio.

I would not recommend using a breadboard long term as you will probably suffer with connectivity problems , so once you layout is tested and working you should move to a soldered PCB option , you can buy ready made PCBs that are the same layout as a breadboard to make it easier to transfer should you need it.

Another option for the green houses would be to use a pi zero w in each and send the results back to the main pi via WiFi.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ghp
Posts: 1466
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: 20x DS18B20 Temperature Sensors with 20M cabling each

Sat Jan 11, 2020 9:45 pm

Wireless communication is one solution.
- ESP8266 are interesting for wifi, but use quite a lot of power.
- RFM69HCW Packet Radio at 433MHz use less power and there are controller/radio boards around, even with lipoly support. With small solar panels there could be autonomous stations.
- raspberry in the field could suffer from power loss and sd card corruption.

When wired communication is an option, then a field bus like RS485 could be used. Designed for long wires, optoisolated tranceivers are available. Then use local microcontroller with a small RS485 board to connect. Modbus could be used to run the network on the raspberry.

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

Re: 20x DS18B20 Temperature Sensors with 20M cabling each

Sun Jan 12, 2020 4:17 am

What you do not want to do is connect all of this directly to GPIO pins. I have seen too many times the struggles folks go through when attempting the data line and pull up resistor scheme. Really short runs and proof of concept is fine, but I would discourage it.

What should be used is a Maxim 1-wire driver chip if you want to communicate over any distance at all.

Please take a look at this other post:
https://www.raspberrypi.org/forums/view ... hp?t=36163
This is also recommended reading - it discusses star and linear topologies and explains why one should be used over the other.
https://www.maximintegrated.com/en/desi ... 1/148.html

From the layout that you had diagrammed, the sensors can be grouped together. What you DO NOT want to do is to run one wire from each sensor back to the Pi and connect all of the data lines together at one point.. This would create a "star" topology, and the 1-wire protocol does not play nicely when wired that way.
I would recommend using a DS2482-800 driver. This will allow you to run up to eight lines back to the Pi (this is an eight channel 1-wire driver). It talks to the Pi via I2C. Because it is I2C and is addressable, you can add up to eight of these chips, allowing you to run each sensor (up to 64) back to its own channel if your setup lends itself best to running a single wire per sensor.

I currently have five sensors strung out on 369 feet of CAT6 cable connected to a DS2482-100 (single channel) working perfectly.
If a transient comes down the wire, it will damage the driver chip before the Pi. You do not get this built in protection when running directly to a GPIO pin.

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

Re: 20x DS18B20 Temperature Sensors with 20M cabling each

Sun Jan 12, 2020 5:00 am

i didnt look into exactly why, but when i last tried ds18b20 on an rpi, it seemed unreliable even over short distances

but an AVR running at 5v, driving a dozen of them spread all over the house, is perfectly stable

i suspected it was either the gpio drive current, the voltage of the system, or the pullup resistor choice

my AVR is then configured to just spit the values out the uart, to another machine

https://github.com/cleverca22/thermostat_firmware/ is the AVR side of the code

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