NEARFIELD·TOOLS

I2C pull-up resistor calculator

The range of pull-up the I2C specification allows on your bus, checked at every corner of supply and tolerance, the value to buy, what the pull-ups already on your breakout boards do to it, and the SCL rate you will really get once the edges have taken their share of each clock period.

Bus capacitance

Pull-ups

Defaults: the minimums every Fast-mode part must meet in NXP's I2C specification (UM10204 rev. 7): 3 mA at 0.4 V, 10 pF and ±10 µA per pin. Your datasheets are usually better than that; enter their figures. The 1 pF/cm for wiring is a rule of thumb for a PCB trace over a ground plane.

—
pull-up to fit
—
allowed range
—
rise time
—
SCL rate you get
—
bus capacitance
—
current while low
allowed at every corner your bus capacitance limit
Pull-upOn the lineRise timeSCL rateCurrent lowResult

Why there is a range

I2C lines are open-drain: devices only ever pull SDA and SCL low, and a resistor to VDD on each line brings it back up. That resistor is squeezed from both sides. Too small, and the weakest driver on the bus cannot pull the line down far enough, because it has to sink the current the resistor supplies. Too large, and the bus capacitance charges too slowly for the next clock edge. NXP's I2C specification, UM10204, gives both limits:

Rp(min) = (VDD − VOL(max)) / IOL     Rp(max) = tr / (0.8473 · Cb)

The rise time tr is measured between 30 % and 70 % of VDD, the input thresholds, and an RC charge takes ln(0.7/0.3) = 0.8473 time constants to cross that band. The limits depend on the bus speed:

ModeClockRise timeBus capacitanceSink current
Standard-mode100 kHz1000 ns400 pF3 mA at 0.4 V
Fast-mode400 kHz300 ns400 pF3 mA at 0.4 V
Fast-mode Plus1 MHz120 ns550 pF20 mA at 0.4 V

Most calculators stop at those two formulas with nominal values. This one evaluates them at the corners: the lower limit at the highest supply and the resistor at the bottom of its tolerance, the upper one at the top of its tolerance. With the defaults (Fast-mode, 3.3 V ±5 %, 60 pF, ±5 % resistors) the range is 1.075 kΩ to 5.62 kΩ, and the page picks 2.7 kΩ.

Two more limits come from the noise margins in the same specification. The low level must stay 0.1·VDD below the 0.3·VDD input threshold, which matters below about 2 V, where 0.4 V is too high (the specification asks for 2 mA at 0.2·VDD there instead). The high level must stay 0.2·VDD above the 0.7·VDD threshold, and every pin on the bus may leak up to ±10 µA, which the pull-up turns into a voltage drop:

n · Ileak · Rp ≤ 0.1 · VDD

With four pins at the specification's 10 µA that caps a 3.3 V bus at 8.25 kΩ (7.464 kΩ nominal once ±5 % on the supply and on the resistor are allowed for), so a 10 kΩ pull-up on a slow bus with four parts does not meet the specification at its worst corner. Real parts usually leak far less: many datasheets guarantee 1 µA. Enter the worst figure from your parts' datasheets.

Bus capacitance

The capacitance is that of every pin on the line, the wiring and anything else attached. The specification allows up to 10 pF per pin; datasheets often say less. A PCB trace over a ground plane adds about 1 pF per centimetre: a 50 Ω trace on FR-4 has 1.2 pF/cm, and a thinner, higher-impedance trace less (the PCB impedance calculator gives the exact figure for your stack-up). Ribbon cable and jumper wires are typically 0.3 to 0.5 pF/cm per conductor, more when SDA and SCL run beside a ground. Long cables are where most buses run out.

The best figure is a measurement. Put a scope on SCL, read the time from 30 % to 70 % of VDD, and enter it with the pull-up that was fitted under from a rise time I measured. The page works the capacitance back out as Cb = tr/(0.8473·Rp). If your scope measures 10 % to 90 %, multiply by 0.386 first (0.8473 / ln 9).

Pull-ups already on the bus

Sensor breakout boards usually carry their own pull-ups, often 10 kΩ or 4.7 kΩ, and every board you add puts another pair in parallel. List them under already on the bus (10k, 10k or 3x10k) and the page works out what they add up to, whether anything still needs adding, and what. Too many can make the bus fail the other way: four boards with 4.7 kΩ each make 1.175 kΩ, and on a 5 V ±5 % bus a 3 mA driver needs at least 1.702 kΩ, so a part at the specification's minimum can no longer pull the line down to 0.4 V. Remove the extra pull-ups (many boards have a solder jumper for them), keeping one pair. The parallel resistor calculator does the arithmetic for any other combination.

A microcontroller's internal pull-ups count too: enter the datasheet figure. They are usually tens of kilohms, too weak for Fast-mode on their own: 30 kΩ meets 300 ns only below 12 pF, less than two pins.

The clock you really get

A controller that synchronises its clock, as section 3.1.7 of UM10204 describes, does not start counting its high phase when it releases SCL. It starts when it sees the line high, above 0.7·VDD, and it starts its low phase when it sees the line fall below 0.3·VDD. Hardware I2C controllers generally work this way. The time the line takes to get there is added to every period. Set a controller to 400 kHz on the defaults and the edges add 218 ns: the clock runs at 368 kHz. Some I2C peripherals' configuration tools ask for the rise and fall times so they can compensate; if yours does, give it the worst rise time this page reports.

The page measures the rise from the low level the driver actually reaches to 0.7·VDD, at the slow corner of the resistor. The fall is modelled with the weakest driver as a resistance, VOL/IOL, and is never taken as faster than the specification's minimum fall time for Fast-mode parts, 20 ns · VDD/5.5 V. The table shows the rate for every value in and around the range, so you can see what a stiffer pull-up buys.

When nothing fits

If the capacitance is too large for the weakest driver, the two limits cross and no resistor works. The page says how far over you are and gives the fastest clock the bus can still run at with the stiffest pull-up the driver allows, from equation 3 of the specification:

fmax = 1 / (tLOW + tHIGH + tr + tf)

with the minimum low and high periods of the mode (4.7 and 4.0 µs in Standard-mode, 1.3 and 0.6 µs in Fast-mode, 0.5 and 0.26 µs in Fast-mode Plus). The specification's other remedies are stronger drivers (Fast-mode Plus parts sink 20 mA), a bus buffer that splits the bus into segments each with its own capacitance budget, and a switched pull-up or rise-time accelerator that only stiffens the line while it rises.

Related

The RC time constant calculator works out any other threshold crossing of the same RC charge, and the LED resistor calculator models a microcontroller pin as a resistance the same way this page models the driver. For a level-shifted bus, each side has its own supply and its own pull-ups: size them separately.

FAQ

What pull-up resistor should I use for I2C at 400 kHz?

For a small 3.3 V board with a few parts, 2.2 kΩ to 4.7 kΩ. But 4.7 kΩ at ±5 % allows only 71.7 pF of bus capacitance at 400 kHz, which four pins and 30 cm of wiring nearly use up; with more parts or a cable, go lower, down to 1.2 kΩ for ±5 % resistors on a 3.3 V ±5 % supply. At 5 V the floor rises to about 1.7 kΩ.

Is 10k too weak for I2C?

At 100 kHz a ±5 % 10 kΩ allows up to 112 pF of bus capacitance, which covers most small boards, though with three or more pins at the specification's worst-case leakage it no longer holds the high level (see above). At 400 kHz it allows only 33.7 pF, three pins and almost no wiring.

Do SDA and SCL both need a pull-up?

Yes, one each, normally the same value. Both lines are open-drain and nothing else pulls them high. One pair per bus is enough, wherever it sits.

Why does my I2C bus work on the bench but fail with a longer cable?

The cable adds capacitance, which slows the rising edges until a device reads a bit before the line has reached 0.7·VDD. Measure the rise time, enter it here and see how far over you are; a stiffer pull-up, a slower clock or a bus buffer will fix it.