Pull up resister with DS18B20: why?

Hi everyone

I'm using a DS18B20 with the one-wire library on an Arudino Uno to measure temperature. Works great.

I used a pull-up resistor between data and +5v as advised, however, while I understand the need for a pull-up (or down) resistor when dealing with inputs that a chip is monitoring, I don't really know why, when the chip is providing a data 'output' in this case, I need the pull-up.

Can anyone advise? It's working fine but I'd like to know more about the need for it.

By the way, I'm using the DS18B20 to measure water temperature and after MUCH searching and reading-up on how to waterproof an LM35 device for temperature sensing, I found a waterproof ready-potted DS18B20 in a stainless steel casing for about £3.50 on eBay. I don't think I could buy the LM35 and assorted waterproofing parts for that amount, let alone pre-assembled - so for anyone considering waterproofing an LM35 - it's worth trying this route.

Thanks!

Input pins are high impedance and essentially open circuit as far as loading goes. Without some load at the end of the line all of your interconnecting wire will act as an antenna and that "hum" will be added to the dc voltage you want to read giving you very inaccurate readings. ?In the industiral setting we don't read many analog sensors as voltages but as closed loop currents using the 4-20 format where the monitoring point converts it to a voltage and corrects for the 4mA representing a 0 reading.

Wow, thank you for such a detailed answer!
Really helpful.

Some devices create an output signal simply pulling the output line down to ground, then "let go" and allow them to float. The pullup brings the output back up to Vcc.

In addition, some of the Dallas One-Wire devices (some 1820 variants among them) can operate on parasitic power - you don't have to run power to the device, it simply steals enough power from the output to operate.

-j

Thanks for the extra info.

I'd read about parasitic power but haven't tested it yet. Once complete, the sensor will be at the end of a good few metres of cable so whether I use that, or use 3 cores, depends on whether parasitic power is more or less useful over longer runs.

I have good luck with parasitic power, so try it first. I have runs of about 10-20 meters with no issues at all. Worst case, you might need to have a stronger pullup (2.2K ohms) before having to resort to adding the extra power source. When using parasitic power on the DS18x20 connect the Vcc pin to GND pin. (meaning: Connect pin 1 to pin 3 on the DS18x20)

Thanks!

Just to confirm then:

Vcc + GND connected together
Pullup between them and pin 2
Connect GND to GND on the Arduino
Connect my input pin on the Arduino to pin 2

... and connect +5v to pin 2 as well?

Sorry to ask the obvious!

cog1:
Thanks!

Just to confirm then:

Vcc + GND connected together

If by that you mean pins 1 and 3 of the DS18B20 connected together, yes.

cog1:
Pullup between them and pin 2

No, pullup between the Arduino i/o pin and Arduino +5v

cog1:
Connect GND to GND on the Arduino

yes, pins 1 and 3 of the DS18B20 connected to Arduino GND.

cog1:
Connect my input pin on the Arduino to pin 2

Yes.

cog1:
... and connect +5v to pin 2 as well?

No! Pin 2 receives power through the pullup resistor.

Thank you, everyone!

I appreciate the parasitic power diagrams are available on the datasheet but it's easier to learn through these discussions.

I just wanted to add my thanks to Dc42 for the information. I was wondering about the same stuff, but Cog1 asked it much better than I could.

The only problem with paristic power is that it takes a little longer to make the reading conversion and that no other transmission can happen at the same time on the one wire bus
So having multiple devices means it will take some time to collect all the reading, which normally is no big deal, just wanted to let you know about that