How do I calculate the required value for a pull-up resistor?

Quick Answer: Experience and experimentation is how you figure out the proper pullup/pulldown value.

Long Answer: The pullup/down resistor is the R in an RC timing circuit. The speed that your signal will transition will depend on R (your resistor) and C (the capacitance of that signal). Often times C is hard to know exactly because it depends on many factors, including how that trace is routed on the PCB. Since you don't know C, you cannot figure out what R should be. That's where experience and experimentation come in.

Here are some rules of thumb when guessing at a good pullup/down resistor value:

  • For most things, 3.3k to 10k ohms works just fine.
  • For power sensitive circuits, use a higher value. 50k or even 100k ohms can work for many applications (but not all).
  • For speed sensitive circuits, use a lower value. 1k ohms is quite common, while values as low as 200 ohms are not unheard of.
  • Sometimes, like with I2C, the "standard" specifies a specific value to use. Other times the chips application notes might recommend a value.

Use 10 kΩ, it's a good value.

For more detail, we have to look at what a pullup does. Let's say you have a pushbutton you want to read with a microcontroller. The pushbutton is a momentary SPST (Single Pole Single Throw) switch. It has two connection points which are either connected or not. When the button is pressed, the two points are connected (switch is closed). When released, they are not connected (switch is open). Microcontrollers don't inherently detect connection or disconnection. What they do sense is a voltage. Since this switch has only two states it makes sense to use a digital input, which is after all designed to be only in one of two states. The micro can sense which state a digital input is in directly.

A pullup helps convert the open/closed connection of the switch to a low or high voltage the microcontroller can sense. One side of the switch is connected to ground and the other to the digital input. When the switch is pressed, the line is forced low because the switch essentially shorts it to ground. However, when the switch is released, nothing is driving the line to any particular voltage. It could just stay low, pick up other nearby signals by capacitive coupling, or eventually float to a specific voltage due to the tiny bit of leakage current thru the digital input. The job of the pullup resistor is to provide a positive guaranteed high level when the switch is open, but still allow the switch to safely short the line to ground when closed.

There are two main competing requirements on the size of the pullup resistor. It has to be low enough to solidly pull the line high, but high enough to not cause too much current to flow when the switch is closed. Both those are obviosly subjective and their relative importance depends on the situation. In general, you make the pullup just low enough to make sure the line is high when the switch is open, given all the things that might make the line low otherwise.

Let's look at what it takes to pull up the line. Looking only at the DC requirement uncovers the leakage current of the digital input line. The ideal digital input has infinite impedance. Real ones don't, of course, and the extent they are not ideal is usually expressed as a maximum leakage current that can either come out of or go into the pin. Let's say your micro is specified for 1 µA maximum leakage on its digital input pins. Since the pullup has to keep the line high, the worst case is assuming the pin looks like a 1 µA current sink to ground. If you were to use a 1 MΩ pullup, for example, then that 1 µA would cause 1 Volt accross the 1 MΩ resistor. Let's say this is a 5V system, so that means the pin is only guaranteed to be up to 4V. Now you have to look at the digital input spec and see what the minimum voltage requirement is for a logic high level. That can be 80% of Vdd for some micros, which would be 4V in this case. Therefore a 1 MΩ pullup is right at the margin. You need at least a little less than that for guaranteed correct behaviour due to DC considerations.

However, there are other considerations, and these are harder to quantify. Every node has some capacitive coupling to all other nodes, although the magnitude of the coupling falls off with distance such that only nearby nodes are relevant. If these other nodes have signals on them, these signals could couple onto your digital input. A lower value pullup makes the line lower impedance, which reduces the amount of stray signal it will pick up. It also gives you a higher minimum guaranteed DC level against the leakage current, so there is more room between that DC level and where the digital input might interpret the result as a logic low instead of the intended logic high. So how much is enough? Clearly the 1 MΩ pullup in this example is not enough (too high a resistance). It's nearly impossible to guess coupling to nearby signals, but I'd want at least a order of magnitude margin over the minimum DC case. That means I want a 100 kΩ pullup or lower at least, although if there is much noise around I'd want it to be lower.

There is another consideration driving the pullup lower, and that is rise time. The line will have some stray capacitance to ground, so will exponentially decay towards the supply value instead of instantly going there. Let's say all the stray capacitance adds up to 20 pF. That times the 100 kΩ pullup is 2 µs. It takes 3 time constants to get to 95% of the settling value, or 6 µs in this case. That is of no consequence in human time so doesn't matter in this example, but if this were a digital bus line you wanted to run at 200 kHz data rate it wouldn't work.

Now lets look at the other competing consideration, which is the current wasted when the switch is pressed. If this unit is running off of line power or otherwise handling substantial power, a few mA won't matter. At 5V it takes 5 kΩ to draw 1 mA. That's actually "a lot" of current in some cases, and well more than required due to the other considerations. If this is a battery powered device and the switch could be on for a substantial fraction of the time, then every µA may matter and you have to think about this very carefully. In some cases you might sample the switch periodically and only turn on the pullup for a short time around the sample to minimize current draw.

Other than special considerations like battery operation, 100 kΩ is high enough impedance to make me nervous about picking up noise. 1 mA of current wasted when the switch is on seems unnecessarily large. So 500 µA, which means 10 kΩ impedance is about right.

Like I said, use 10 kΩ. It's a good value.


First, this kind of tutorials is useless, they won't teach you electronics. You have to learn how to draw a schematic, the wiring comes afterwards.
So, lacking the schematic I had to derive it myself from the wiring diagram. OK, that wasn't so hard, but when you draw the schematic you see something is missing: what does the tact switch connect to? You have to know that to answer your question. I presume it's a digital input of the microcontroller, but there's no way to know.

There are two situations: tact switch open, and switch closed.

In the closed state the microcontroller's input is connected to ground, so it will see a low level. There will also flow a current through the resistor. A good schematic would have told you that one end of the resistor is connected to +5V, the tact switch connects the other end to ground. Let's see if a 10k\$\Omega\$ resistor will do. Then the current through the resistor equals \$\dfrac{5V}{10k\Omega}\$ = 500\$\mu\$A. That seems reasonable. Let's see if that's OK too when the switch is open.

In the switch open state we can ignore it, and pretend that there's only the resistor between V+ and the microcontroller's input. We know from experience, or, better, because we looked it up in the datasheet that when you apply a voltage to a microcontrollers input there will only flow very little current, often less than 1\$\mu\$A. Let's say it's 1\$\mu\$A. Then the voltage drop across the resistor will be 1\$\mu\$A \$\times\$ 10k\$\Omega\$ = 10mV. The voltage on the input will then be 4.99V. That's probably OK, but let's do our job properly. If you had a schematic (I think you've got it by now, don't you?) you would know what type the microcontroller is. I know Arduino is AVR, so I'll pick a random AVR datasheet. The electrical characteristics say that a high input level should be at least 0.6 \$\times\$ \$V_{DD}\$ (page 320). That's 3V, so the 4.99V is safe.

What if we had chosen a different resistor value? A lower value would mean less voltage drop and the input voltage would be even higher than 4.99V. But then there would be more current through the resistor when the switch is closed, and that's something you don't want.
A higher resistor value would be OK when the switch is closed, since there would be less current, but the input voltage on the microcontroller will be lower than 4.99V. We have some headroom here, so a somewhat higher value might be OK.

conclusion

  1. The 10k\$\Omega\$ is OK for both switch open and closed situations.
  2. Learn to draw schematics, and read datasheets