PDA

View Full Version : 18B20 and cable length



Scampy
- 18th September 2015, 19:24
Guys, need some suggestions.

I'm using two sensors in a project, and AM2302 and DS18B20. I made up sets of sensors approx 3m when testing and everything worked well. However I have a need to place one set of sensors on the othre side of the room, with a cable length of around 11m. When wired up the AM2302 sensor works fine, but the DS18B20 isn't read.

Thinking it might of been a bad crip connection on the plug I took one of the working 3m cables and tested that which worked fine, so I knew that both ends (the RJ11 and DS18b20) were fine, so I cut the cable in half and connected the RJ11 to one end of the long cable run and the 18b20 to the other, having used a multi-meter to prove the continuity of the long cable first.

is there any limit on the cable run when using a DS18B20? the pull up resistor on the signal line is 10K, would this need changing, if so higher or lower ?

MichelJasmin
- 18th September 2015, 19:57
I did something like this and it worked. I had a 10µF tantalum capacitor close to the DS18B20. I don't remember exactly but the 10k pull up was close to the sensor.

Scampy
- 18th September 2015, 21:51
Thanks for the advice. I've done some reading and it seems that lowering the resistor value to something like 2K, and placing that near the DS18b20 rather than the PIC should work. I'll try this later as the device is currenty controlling the heater in an incubator, amd don't want to risk the eggs getting too cold whilst I try and mod the PCB etc

Charlie
- 19th September 2015, 12:38
10K is too high. I have successfully run 50' with a 2.2 K driving directly from the pin of the PIC (resistor at the PIC end of the wire). There are also circuits that use transistors to more aggressively pull up for long range or multiple devices on the bus.

towlerg
- 19th September 2015, 13:29
FWIW the data sheet says 4k7

George

Scampy
- 20th September 2015, 10:51
Charlie , George, thanks for the inputs. Once the eggs have hatched (approx 4 weeks time) I'll be able to change the resistor values without any impact. I'll stick 2K2 in to all of the 4 inputs so it won't matter which input I use for the long run sensor

Scampy
- 25th October 2015, 16:40
FWIW the data sheet says 4k7

George

George, thanks for the advice. I made the mistake and installe dthe wrong value resistors. 4K7 is indeed the correct value, but I had to wait until today to try it out as I was using the habistat controller to run the reptile incubator and had to wait for the eggs to hatch. Now that's over I have changed the resistor for a 4K7 and the sensor is working fine over the cable length and the controller has been running fine all day

http://micro-heli.co.uk/controller2.jpg

Charlie
- 27th October 2015, 14:13
It's great that you've got it going, Malcolm. The datasheet talks about 5K as sort of a maximum value, optimal for a single device but there are all sorts of conditions where you'd want it smaller. If you are running in parasitic mode with a long lead, if you have multiple 1-wire devices on the same bus, if you are running at lower voltages (say 3.3 V), you will find you need to lower that value. The datasheet has an example circuit for effectively lowering the value to near zero while the device takes it's reading. Bottom line is that there isn't a single best value.
So if you have 1 device on the bus, running at 5V, not in parasitic mode, 4.7K is perfect. If you have a different configuration, and you have troubles, try lowering the resistor to 2.2 K. Larger values like 10 K are unlikely to ever work, as you discovered.
There's a lot of discussion online about these devices including a couple application notes that talk about these exceptions.

Scampy
- 28th October 2015, 00:34
Thanks for the additional info Charlie. Yes I'm running at 5v and each sensor is on it's own pin on the PIC.

The controller was installed at the weekend. It sits on a stack of three vivariums, with the fouth being a large 160cm x 50cm x 50xm the other side of the room. The cabling for heater, light and two sensors are routed in trunking over the door and along the skirting board to the unit

http://micro-heli.co.uk/vivstack.jpg

I've updated the schematic and PCB drawings to use 4K7 resistors... Where I got 10K value from I don't know !