I was using a temperature sensor DS18B20 with Arduino.

I've read that you should connect the digital input line and the 5V line with a 4.7kOhm resistor - like in the picture.

Can someone explain why do we need to do this? And why this resistance? What happens if we don't put a resistor at all or use a different resistance?

Dallas DS18B20 with the 4.7kOhm resistor


2 Answers 2


The product page FAQ [https://www.maximintegrated.com/en/support/faqs/ds18b20-faq.html] has an entry:

Q: Is the 4.7kΩ resistor needed for 5V and 3.3V operation?
A: Yes, the 4.7kΩ pullup resistor is required for both 5V and 3.3V applications.

The 1-wire bus requires that the control signal be pulled high so the master device can pull it low to ask for data, and the slave device can pull it low to give the data. This allows you to have multiple 1-wire devices on the same "one wire".

The data sheet notes another purpose:

Another feature of the DS18B20 is the ability to operate
without an external power supply. Power is instead
supplied through the 1-Wire pullup resistor through the
DQ pin when the bus is high. The high bus signal also
charges an internal capacitor (CPP), which then supplies
power to the device when the bus is low. This method of
deriving power from the 1-Wire bus is referred to as “parasite
power.” As an alternative, the DS18B20 may also be
powered by an external supply on VDD.
  • 1
    Note that while a resistor is required, it need not be 4.7kohm. The internal resistors on the arduino are enough to drive 4 sensors at 2-3 feet of wire, not in parasitic mode. The 4.7k resistor lets you drive systems with much higher capacitance (dozens of sensors at multiple meters). For playing around or a single sensor, there really is no need.
    – Perkins
    Oct 28, 2019 at 20:47
  • Here you can find a more in-depth look at this question and why the internal pull-up can very well work. wp.josh.com/2014/06/23/…
    – Frank
    Jun 13, 2021 at 7:33

Adding to jose's answer above to answer your other two questions

And why this resistance? When the device doesnt have its own power supply it uses the power going through the pull up resistor-thus with this resistance it is powered properly. Also the other reason- as Jose wrote is because it the value which differentiates high or low bits.

What happens if we don't put a resistor at all or use a different resistance? If you are going to you an out of spec value-dont expect the device to work properly because its using the wrong resistance-e.g. it may not work because if the resistance is too high-then according to ohms law it may not receive enough parasitic power. Though it should be able to tolerate the error tolerance of the resistor-so changing it by a few ohms either way from 4700 ohms will not make a difference. You may damage the device without a resistor.

  • Thanks! What I still don't understand, is that we do supply the power to the temperature sensor by the 5V line directly (one of the legs of the sensor is conntected to the Arduino's 5V). So, does that mean that the power supply goes from 5V, through the resistor to the digital input line (the middle leg)? Nov 3, 2016 at 22:49
  • How do you think the sensor works when its powered from the arduino? Nov 3, 2016 at 22:55
  • 1
    Im trying to understand what you are thinking thats why I asked that. Nov 3, 2016 at 22:55
  • 2
    In your particular use-case, you aren't using the parasitic-power feature. The 4.7k ohm resistor is a "pull-up" resistor for the bus's data line. Why 4.7k? At 5V, the most current that can flow through the resistor is about 1mA. That's weak enough that all any other device on the bus needs to do to bring the line down to (near) 0V is sink more than 1mA of current. But when that device let's go (stops sinking current) the line always rises back to 5V. Nov 4, 2016 at 2:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.