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

There are many tutorials that use a pull-up or pull-down resistor in conjunction with a switch to avoid a floating ground, e.g.

http://www.arduino.cc/en/Tutorial/button

Many of these projects use a 10K resistor, merely remarking that it is a good value.

Given a a particular circuit, how do I determine the appropriate value for a pull-down resistor? Can it be calculated, or is it best determined by experimentation?

• I found this tutorial from sparkfun a good introduction to pull-up and pull-down resistors sparkfun Pull-up Resistors and the answers provided to your most excellent posted question are great. – Richard Chambers Jan 10 '18 at 23:36

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.
• 200 ohms for a pullup? Wow, thats a lot of quiescent current. – 0x6d64 Dec 14 '11 at 8:13
• @0x6d64 - You're assuming the bus is low when quiescent. – Connor Wolf Jun 18 '13 at 3:31
• Texas Instruments has a very good reference that explains not only how to calculate the value for an I2C pull-up resistor, but how the formula is actually derived. See the I2C Bus Pullup Resistor Calculation Application Report at ti.com/lit/an/slva689/slva689.pdf. – JamieSee Jul 15 '17 at 22:45

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.

• And additional requirement is that some switches, for instance the common 'tact' type switches, are specified for only a very low current, for instance 1 mA. Note that 10k (at 5V or lower) satisfies this requirement, but it must be kept in mind wen lower resistor values are considered. – Wouter van Ooijen Jan 29 '12 at 22:22
• @Wouter - my favorite tact switches not only have a 50mA maximum (1mA seems low to me), but also a minimum. To keep the contacts clean I place a capacitor in parallel to the switch, the idea being that the short circuit current peak when switching keeps the contacts clean. Despite life of only 100 000 cycles is specified in testing we had no problems using them to 200 000 cycles. – stevenvh Apr 15 '12 at 12:35
• @stevenvh Could you explain more about the capacitor in parallel with the switch? How come, making the initial short circuit current high keeps the contacts clean? – abdullah kahraman Mar 15 '13 at 22:29
• This situation where you could see excessive capacitive coupling affecting a pull-up resistor value. Seems crazy, but it's not. I have an obnoxious tri-state output, that I am reading with an ADC. One one board, a 220k pull-up is sufficient so all of the tri-states can be read by the ADC. On another (more tightly placed board), I need like a 100k pull-up. Thought I was on crazy pills chasing this all morning. – Leroy105 Feb 8 '18 at 23:19

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
• I'd disagree that is useless, in fact wiring diagrams made with Fritzing are probably now common than schematics when it comes to Arduino. The audience must be taken into consideration. – Dave Newton Mar 17 '15 at 10:54