# Pull Up Resistor Value for temperature sensor

I read that there needs to be a pull-up resistance for dht22 when connected to arduino. When dht22 is close, arduino's internal resistor value is enough, we have to add external resistor. I want to know the exact relation that for X-meters, you should add an external resistor. Can anyone give some info about this?

• you should make your points clearer, to me, a generic value for pull up resistor is 10k – muyustan Jun 10 at 5:30
• @muyustan my arduino will be kept 20-30 m away from dht22. I do not care of strong pull-up wasting electricity. I need accurate readings. Suppose I add 10k resistor. Can I, for testing purpose, use it with 1 cm wire, or it will cause a lot of current? – Bhavya Gupta Jun 10 at 5:38
• Pull ups only use power when you use the I2C bus to read the sensor... So if it is not frequently, like once per minute, there is almost no power used. – MadHatter Jun 10 at 6:10
• The most-most-most generic pull up that you always try first unless you have reasons not to, is 10k. Since you're going to greater line lenghts, "downgrade" to 4.7k safely. There is no way it can damage anything (5V/4.7k = 1ma peak consumption). Even 2.2k will be safe to use, but usually the higher the frequency or longer the line (to counter line's capacitance and toggle up and down quick enough), the lower resistor you need. Keep it simple for now. 4.7k will work 100%. – Ilya Jun 10 at 11:26

Depending on the cable you are planning to use (for relatively long distances), the pull-up resistor and the cable capacitance form a nice, one-stage low-pass filter which directly affects tr and tf.

tr (Rise Time): The duration that the signal rises from its 10% to its 90% level.

tf (Fall Time): The duration that the signal falls from its 90% to its 10% level.

tp (Pulse duration): The duration between 67% and 33%.

As a result,

$$t_r = t_f = 2.2 \ R_P \ C_L$$

where RP is the pull-up resistor and CL is the total cable capacitance.

I will not fill in the answer with a proof. But it's easy - use the capacitor's charge and discharge equations.

For example, let's assume you are using a 20-meter-long cable with a capacitance of 30pF/m (running two cables: data and ground), so CL=600pF, and a pull-up resistor of RP = 10kOhm.

From the formula above, tr = tf = 13.2μs. We can fairly assume that the width of a pulse will be decreased by ~10μs. It's also easy to say that this RC network will chop-off the incoming frequencies beyond fC= 1/(2 π RP CL) = ~26kHz.

From the datasheet of your sensor, the minimum pulse width is 26-28μs which allows us to make tr = tf = ~1μs. With the same cable in the example above, the maximum pull-up resistor can be calculated as RP = ~1Ω which is completely unacceptable and impractical. So, you should either decrease the length or use buffers-repeaters at both ends.

• Sir!!! This is my first ever electronic project. And such a complicated answer! Anyway i got your point. I was planning to use just a normal electric wire used for home wiring... Do they worsen this problem? – Bhavya Gupta Jun 10 at 6:54
• @BhavyaGupta probably yes. Using long wires with pull-up resistors is not a good idea for your project. As I said in my answer, you can use buffers which allow you to use longer cables with higher speeds. – Rohat Kılıç Jun 10 at 6:56
• Thanks for replying. What is speed related to? Sorry for my lack of knowledge but I don't get where the parameter of speed came from? I just need to get temperature readings once every 30 minutes. – Bhavya Gupta Jun 10 at 7:00
• I meant the maximum communication speed without distortion/deformation of the signal. In your case the speed is determined by the sensor itself, so nothing to worry about. My answer about buffers/repeaters for long distances still applies. – Rohat Kılıç Jun 10 at 7:19
• @BhavyaGupta most likely there'll be no communication between the Arduino and the sensor at all - The sensor will not understand what Arduino says and vice versa - so you can't get any reading from the sensor. If you are lucky, you can get wrong readings such as -127°C in a room environment. – Rohat Kılıç Jun 10 at 7:47