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?
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.