DS18B20 reliability considerations

Tags: #<Tag:0x00007f10a7e4a9a8>
(Frogmore42) #21

Using a pull-up to 5V on a 3V3 MCU can be just fine if the MCU is designed for that. Some are rated for it and some have a design the will work okay. Since it is a pull-up, when the MCU input protection circuit goes active it will be able to lower the voltage without needing to disapate too much current.

I used to use 5V for the power pin and didn’t have problems. I now use 3V3, since the esp8266 is not rated for 5V on the input pins (there is some debate on this, but it isn’t clear that it is 5V tolerant). I have not had any more problems since I switched, so I don’t believe 5V is necessary if runs are short. The datasheet does recommend using 5V for both pull-up and power when you need maximum range, ie 100m or so.


(dBC) #22

I think what you’re witnessing there is a battle between your 4K7 pull-up and the internal protection diodes. If you disconnected it from the input, I’d expect it to be at 5V. When the bus is idle (most of the time) there is no load on the data pin so it should be sitting at 5V (I’m excluding parasite mode here).

I’m pretty sure neither the ATmega328p nor the RPi have 5V tolerant input pins. You’re probably only putting about 0.3mA through the protection diode which is below the 1mA max Atmel specify (don’t know what the RPi specs are). But those diodes are primarily intended for ESD protection, not as voltage clamps.

I’ve been doing some extreme OneWire tests lately, and was all set to post in here … “don’t be shy about making your pull-up much stronger”. You’ll see plenty of Maxim stuff using 1K pull-ups for good bus reliability. The only limiting factor there is the amount of current the ds18b20 can sink when it’s trying to hold a ‘0’; to stay within that spec you can go to about 910R with 3.3V and 1K3 with 5V. Had I offered that advice in this thread and someone followed it, I reckon they would have blown their inputs. The only thing protecting those 3.3V inputs from the 5V you’re feeding them is the current limiting provided by that 4K7 pull-up.


(Bill Thomson) #23

RPi, 3V3 maximum.

From the post at the link above:
ALL the Pi GPIO are 3V3. NONE of them are tolerant of voltages outside the range 0 to 3.3V.

With the ATMega328, it depends on Vcc


1 Like

(dBC) #24

In my experience, particularly true if it was built in Solihull. @Robert.Wall you’re from that nick of the woods aren’t you? Duck around there and sort ‘em out would ya’ please.


(Robert Wall) #25

I don’t have any contacts there now. There was a time when I could look up the IEE list of members, but I’m not the local Hon.Sec any more.


emonTx screw terminal block
(Dave Howorth) #26

FWIW, I’m not a hardware person but a link I posted in another thread - emonTx screw terminal block - might be relevant to the discussion of pullups here. See the post by albundy in

Also, I remember seeing somewhere the suggestion that the best way to wire using Cat-5 is to use one pair for earth and data and another pair for earth and power. So earth is on two lines. Not sure how that compares against the strict 3-wire approach suggested above.


(Frogmore42) #27

I looked at the datasheet. It appears that the DS18*20 has absolute voltage levels for low and high. This means it should be no problem to use 5V on VDD and 3V3 for the pull-up. Using 5V for the pull-up with an MCU that is NOT 5V tolerant would be a not very good idea, but would probably work.

I have a DS18B20 that is on a reasonably long line, about 15m. It works great as long as the VDD line is properly connected to either 3V3 or 5V. If the VDD line is disconnected, the sensor still works, but reads 85C.


(Robert Wall) #28

85°C means it hasn’t worked. That is the value that is loaded into the register at power-up, and when you read that value, it means that the measurement and conversion of the temperature hasn’t taken place, or hasn’t completed - that is, if you try to read the temperature too soon after commanding it to convert the temperature.


(dBC) #29

I suspect what’s happened in that case is the device has fallen back to parasite mode (getting its power off the data line), and that probably fell away during the conversion when it draws it’s max current, and the device resets as a result. By then it’s a brand new day from the device’s point of view… what conversion? So when the “result” is read, you get the power-up value because the device has indeed just powered up.