18B20 and cable length


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2009
    Posts
    583

    Default 18B20 and cable length

    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 ?

  2. #2
    Join Date
    Feb 2013
    Location
    Quebec, Canada
    Posts
    67


    Did you find this post helpful? Yes | No

    Default Re: 18B20 and cable length

    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.

  3. #3
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 18B20 and cable length

    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

  4. #4
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: 18B20 and cable length

    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.

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: 18B20 and cable length

    FWIW the data sheet says 4k7

    George

  6. #6
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 18B20 and cable length

    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

  7. #7
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 18B20 and cable length

    Quote Originally Posted by towlerg View Post
    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


  8. #8
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: 18B20 and cable length

    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.

  9. #9
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 18B20 and cable length

    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



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

Similar Threads

  1. LCD cable length?
    By Art in forum General
    Replies: 27
    Last Post: - 14th February 2012, 15:35
  2. Max cable length?
    By Fredrick in forum Serial
    Replies: 8
    Last Post: - 2nd July 2010, 20:37
  3. DS1820 Max Cable length ?
    By dccch in forum General
    Replies: 2
    Last Post: - 24th January 2008, 07:44
  4. Measure cable length with a PIC?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th July 2007, 18:45
  5. Cable Length Between Micros
    By markcadcam in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st June 2006, 14:29

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts