← all lessons
Single-Ended Buses · SPI & I²C · #34 of 48

I²C Open-Drain & Pull-Up Sizing

The Rise-Time vs Sink-Current Tug of War

You wire a fresh temperature sensor onto the robot hand’s I²C bus, run the scan, and nothing answers. The scope tells the real story: every clock edge sags upward like a tired sigh instead of snapping high, and by the time the line finally reaches a logic one the controller has already given up and sampled a zero. The parts are fine. The wiring is fine. What is wrong is a single resistor you probably picked without thinking, sitting in a fight it is quietly losing.

On an I²C bus, the pull-up resistor is the only thing that ever drives the line high, and how you size it decides whether the bus works at all.

Every other bus you have met so far had a transmitter that could shove the line both ways. I²C cannot. Its devices can only pull down, so the journey back up is left entirely to a resistor charging the bus capacitance. That single design choice is what makes pull-up sizing the whole game: too big a resistor and the line rises too slowly, too small and you ask the chip to sink more current than it can. The right value lives in the narrow gap between those two failures, and the order to reason about it is fixed: rise time first, sink current second, scope last.

By the end, you can

  1. Explain why an open-drain bus needs an external pull-up and what each device can and cannot drive
  2. Calculate the bus rise time from R and C and compare it against the per-speed spec limit
  3. Choose an upper bound on R from the rise-time budget and a lower bound from the 3 mA sink limit
  4. Size pull-ups for a 400 kHz bus end to end: estimate C, pick R, verify both bounds, confirm on the scope

Intuition first

Picture the data line as a bucket and the logic threshold as a fill mark partway up its side. Every device on the bus has a drain plug at the bottom: open the plug and the bucket empties almost instantly to the floor (a clean, fast logic zero). No device has a tap. The only way water ever rises back to the fill mark is a thin pipe at the top, dribbling in from a reservoir. That pipe is the pull-up resistor, and the bucket’s width is the bus capacitance.

Now the tension is obvious. A wide pipe (small resistor) refills the bucket fast, so the line snaps high in time for the next clock edge. But a wide pipe also means that when a device opens its plug, it has to drain not just the bucket but the water still pouring in through the pipe, and a real plug can only swallow so much. A narrow pipe (large resistor) is gentle on the plug but refills the bucket so slowly that the fill mark arrives late, after the receiver has already looked away.

The art of pull-up sizing is choosing a pipe wide enough to refill in time but narrow enough that any single plug can still hold the line on the floor. Everything below is just putting numbers on “in time” and “on the floor.”

Open drain: pull low, never high

Look at how an I²C output is actually built. Each device hangs a single N-channel MOSFET on the shared wire, with its source at ground and its drain on the line. Drive the gate high and the transistor turns on, yanking the line down to nearly zero volts: a logic zero. Drive the gate low and the transistor turns off, going high-impedance, electrically disconnected from the wire. That is the entire output stage. There is no second transistor reaching up toward the supply. This is the open-drain configuration (its bipolar cousin, with a BJT instead of a FET, is called open-collector, and behaves identically for our purposes).

Because no device can push the line high, an external pull-up resistor to the supply rail does that job for the whole bus. When every device on the line is high-impedance, the resistor quietly pulls the wire up to the supply, and the bus reads a logic one. The instant any one device turns its FET on, that device wins: it sinks current straight to ground and the line goes low regardless of what anyone else wants. This is exactly why I²C can share two wires among many chips without short circuits. Two push-pull drivers fighting (one high, one low) would be a dead short and a puff of smoke. Two open-drain drivers can never fight, because neither can drive high. The worst they can do is both pull low, which is just a stronger zero.

I2C open-drain bus: pull-up resistors Rp tie SDA and SCL up to Vdd, and each device drives the lines only by pulling LOW through an N-FET. The bus capacitance Cb of all devices and traces sets the rise time after release. Vdd (3.3 V) Rp Rp pull-ups Rp provide the HIGH (idle = 1) SDA SCL ESP32 Sensor EEPROM open-drain: pulls LOW only, never drives HIGH Cb = bus capacitance (all devices + traces) after release, Rp + Cb set the rise: t_r ≈ 0.85 · Rp · Cb
On I2C, no device can drive the line HIGH. Each output is open-drain: an N-FET that only pulls LOW. The pull-up resistors Rp supply the HIGH and, working against the bus capacitance Cb, set how fast a released line rises back to Vdd (t_r ≈ 0.85 · Rp · Cb). Smaller Rp means faster edges but more current when a device holds the line low.

That single picture explains three things at once. It is why the bus has a deterministic loser in arbitration (the device trying to send a one sees the line held low by someone sending a zero, and backs off). It is why a slow device can stretch the clock by simply holding SCL low until it is ready. And it is why the rising edge is the slow, fragile one: falling edges are a transistor slamming the line down, but rising edges are only a resistor trickling charge up.

Rise time: the bus is an RC charging up

When every device releases the line, the pull-up resistor RR has to charge the total bus capacitance CbusC_{bus} from zero up to the supply. That is exactly the RC charge you met back in the capacitor lesson: an exponential approach toward the rail with time constant τ=RCbus\tau = R \, C_{bus}. The voltage climbs as

V(t)=Vdd(1et/(RCbus))V(t) = V_{dd}\left(1 - e^{-t/(R\,C_{bus})}\right)

and the bus does not care about the whole curve. It cares about one thing: how long the edge takes to cross from a solid low to a solid high, the rise time triset_{rise}, measured between the 30 percent and 70 percent points the I²C spec uses for this purpose. Working that band out of the exponential gives the rule you will use every time:

trise0.85RCbust_{rise} \approx 0.85 \, R \, C_{bus}

Read it as: the rise time is just under one RC time constant. Double the resistor, double the rise time. Double the capacitance (more devices, longer traces), double the rise time. The factor 0.850.85 comes straight from the logarithms of those two threshold crossings, and it is close enough to one that you can sanity-check any design in your head: triset_{rise} is roughly RR times CC.

The spec then sets a ceiling. The edge must finish well inside one bit period, so faster buses demand faster edges:

Bus speedMaximum triset_{rise}
100 kHz (standard)1 μs\approx 1\ \mu s
400 kHz (fast)300 ns\approx 300\ \text{ns}
1 MHz (fast-plus)120 ns\approx 120\ \text{ns}

Your job is to keep the computed triset_{rise} comfortably under the row that matches your bus speed. Because triset_{rise} grows with RR, that ceiling becomes an upper bound on the pull-up: any resistor bigger than

Rmaxtrise,spec0.85CbusR_{max} \approx \frac{t_{rise,\text{spec}}}{0.85 \, C_{bus}}

makes the edge too slow. More devices and longer wires raise CbusC_{bus}, which pushes RmaxR_{max} down, so a crowded bus forces a smaller pull-up. That is the single most common cause of a bus that worked on the bench with one sensor and died when you added three more: the capacitance crept up and the old resistor stopped being fast enough.

Sink current: the floor under the resistor

So make the resistor small and the edges get fast. Why not use 100 Ω and be done? Because of the other end of the line. Remember that a logic zero is one device’s FET pulling the wire to ground against the pull-up, which is still trying to lift it. The smaller the resistor, the more current it forces back through that FET, and the FET can only sink so much while still holding the line genuinely low.

The spec pins this down with the low-level output voltage, VOLV_{OL}. A compliant I²C device must be able to hold the line at or below 0.4 V0.4\ \text{V} while sinking up to about 3 mA3\ \text{mA}. At the worst case, the entire supply sits across the pull-up while the device clamps the bottom, so the current the FET must swallow is

IsinkVddRI_{sink} \approx \frac{V_{dd}}{R}

Set that equal to the 3 mA3\ \text{mA} limit and you get a lower bound on the resistor:

RminVdd3 mAR_{min} \approx \frac{V_{dd}}{3\ \text{mA}}

For a 3.3 V bus that is about 1.1 kΩ1.1\ \text{k}\Omega; for 5 V, about 1.7 kΩ1.7\ \text{k}\Omega. Go below RminR_{min} and the device can no longer drag the line under 0.4 V0.4\ \text{V}, so your “zero” reads as a marginal half-volt that the next chip may or may not believe. You have not gained speed; you have manufactured an intermittent fault.

Now the whole problem has shape. The pull-up must live in a window:

Vdd3 mA    R    trise,spec0.85Cbus\frac{V_{dd}}{3\ \text{mA}} \;\le\; R \;\le\; \frac{t_{rise,\text{spec}}}{0.85 \, C_{bus}}

The floor comes from sink current, the ceiling from rise time, and a healthy bus has a comfortable gap between them. When the gap closes, the message is not “try another resistor,” it is “you have too much capacitance for this speed.” For most hobby and robot-hand buses the classic 4.7 kΩ4.7\ \text{k}\Omega sits safely inside the window at 100 kHz, but as you will see in a moment, it can fall right off the ceiling at 400 kHz.

See it: drive the tug of war

The simulator below is the window made live. You set the pull-up RR, the estimated bus capacitance CbusC_{bus}, and the bus speed; it computes the rise time from 0.85RCbus0.85\,R\,C_{bus}, compares it to the spec limit for that speed, and reports the worst-case sink current Vdd/RV_{dd}/R at the same time. Watch the two readouts move in opposite directions as you drag RR: that opposition is the trade-off.

Rise time tr
398 ns
Spec limit
300 ns
Rise verdict
FAIL
Sink current Isink
0.70 mA

Start where it opens: 4.7 kΩ4.7\ \text{k}\Omega, 100 pF100\ \text{pF}, 400 kHz. The rise time lands near 400 ns against a 300 ns ceiling, so the verdict is FAIL, even though the sink current is a lazy 0.7 mA. The classic resistor is too slow here, not too greedy. Now drag RR down toward 2 kΩ2\ \text{k}\Omega and watch the rise time drop under the limit and flip to PASS while the sink current climbs toward 1.7 mA, still well under the 3 mA floor. You have just found a legal value by hand. Then push CbusC_{bus} up to 300 pF (imagine adding two more sensors and a cable) and watch the rise time balloon again: the same resistor that passed now fails, and you have to drop RR further still. That is the crowded-bus failure mode playing out in real time, and it is the single most useful intuition this lesson can give you.

On an idle I²C bus with every device released, what is actually pulling the SDA line up to a logic one?

You move a working 100 kHz bus up to 400 kHz and the rise time now exceeds the 300 ns spec. Which change fixes it while staying legal?

Lab: a five-minute pull-up sizing pass

At the bench, size pull-ups in the same order every time so you never get trapped. First, estimate CbusC_{bus}: count roughly 10 pF per device pin plus the trace and any cable, and round up (it is always more than you think). Second, set the ceiling: take your bus speed’s triset_{rise} limit and compute Rmax=trise/(0.85Cbus)R_{max} = t_{rise}/(0.85\,C_{bus}). Third, set the floor: Rmin=Vdd/3 mAR_{min} = V_{dd}/3\ \text{mA}, about 1.1 kΩ1.1\ \text{k}\Omega at 3.3 V. Pick a standard resistor near the middle of the RminR_{min}-to-RmaxR_{max} window, leaning toward the smaller end if the bus is busy. Finally, confirm on the scope: probe SDA, look at a rising edge, and measure the real 30-to-70 percent time. If it is under the limit with margin and the low level sits under 0.4 V, you are done. If the edge is lazy, halve the resistor and re-measure. The scope is the judge; the math just gets you close.

Where 0.85 comes from, and why fast-plus mode swaps the resistor for a current source

The factor 0.850.85 is not magic; it falls out of the exponential charge. The I²C spec measures rise time between 0.3Vdd0.3\,V_{dd} and 0.7Vdd0.7\,V_{dd}. Solving V(t)=Vdd(1et/τ)V(t)=V_{dd}(1-e^{-t/\tau}) for those two crossings:

t30=τln(10.3),t70=τln(10.7)t_{30} = -\tau \ln(1 - 0.3), \qquad t_{70} = -\tau \ln(1 - 0.7)trise=t70t30=τ[ln(0.7)ln(0.3)]=τln ⁣(0.70.3)0.847τt_{rise} = t_{70} - t_{30} = \tau\left[\ln(0.7) - \ln(0.3)\right] = \tau \ln\!\left(\tfrac{0.7}{0.3}\right) \approx 0.847\,\tau

so trise0.85RCbust_{rise} \approx 0.85\,R\,C_{bus} exactly. (If you instead use the classic 10-to-90 percent band common elsewhere in electronics, the same algebra gives the familiar trise2.2τt_{rise}\approx 2.2\,\tau; I²C just samples a narrower, easier band, so its constant is smaller. Both describe the same RC edge.)

This also explains the spec’s escape hatch at high speed. As you push toward 1 MHz fast-plus and beyond, RmaxR_{max} from the rise-time budget shrinks until it collides with RminR_{min} from the sink limit, and no resistor satisfies both. The spec’s answer is to stop using a plain resistor. Fast-mode-plus drivers are specified to sink up to 20 mA (not 3 mA), which lowers RminR_{min} and reopens the window; and high-speed mode allows a current-source pull-up that delivers constant charging current instead of a resistor’s ever-weakening trickle, flattening the late part of the edge that an RC curve drags out. Both are the same realization this lesson started with: the rising edge is the enemy, so spend transistors to fix it rather than over-constraining the resistor. A small note on the numbers: this lesson uses the practical 3 mA3\ \text{mA} sink figure and the 0.850.85 rise-time constant as the working rules of thumb. Some grounding sources quote the wider 10-to-90 percent rise convention and mode-specific drive strengths (3 mA for standard and fast, 20 mA for fast-plus); those are consistent with the bounds here once you match the threshold band and the mode, and the authoritative numbers above are what to size with.

Grounded in Wikipedia: “I²C”, “Open collector”, “Rise time” (CC BY-SA).

Key takeaways

  • I²C is open-drain: every device can only pull the line LOW, and a single external pull-up provides the only path HIGH.
  • The rising edge is an RC charge: trise ≈ 0.85 · R · Cbus, and it must stay under ≈1 µs at 100 kHz, 300 ns at 400 kHz, 120 ns at 1 MHz.
  • Rise time puts an upper bound on R; smaller R means faster edges but more sink current.
  • Sink current puts a lower bound: Rmin ≈ Vdd / 3 mA, because a device must hold the line under 0.4 V while sinking ≤ 3 mA.
  • More devices and longer traces raise Cbus, forcing a smaller R, and past 400 pF the window slams shut.
Practice 1 warm-up

A 100 kHz bus has a pull-up of 4.7 kΩ4.7\ \text{k}\Omega and an estimated bus capacitance of 120 pF120\ \text{pF}. Estimate the rise time and say whether it passes the standard-mode limit.

Show worked solution

Use trise0.85RCbust_{rise} \approx 0.85\,R\,C_{bus}:

trise0.85×4700 Ω×120×1012 F0.85×5.64×107 s480 nst_{rise} \approx 0.85 \times 4700\ \Omega \times 120\times10^{-12}\ \text{F} \approx 0.85 \times 5.64\times10^{-7}\ \text{s} \approx 480\ \text{ns}

The standard-mode limit is about 1 μs1\ \mu s, and 480 ns480\ \text{ns} is comfortably under it. The bus passes at 100 kHz. (Note that the same resistor and capacitance would fail at 400 kHz, where the ceiling is only 300 ns, which is why moving an existing bus to fast mode so often breaks it.)

Practice 2 core

Size the pull-ups for a 400 kHz bus running off 3.3 V with an estimated Cbus=200 pFC_{bus} = 200\ \text{pF}. Find the rise-time upper bound on RR, the sink-current lower bound, and pick a sensible standard resistor.

Show worked solution

Upper bound (rise time). The 400 kHz ceiling is trise=300 nst_{rise} = 300\ \text{ns}:

Rmaxtrise0.85Cbus=300×1090.85×200×10123.0×1071.7×10101.76 kΩR_{max} \approx \frac{t_{rise}}{0.85\,C_{bus}} = \frac{300\times10^{-9}}{0.85 \times 200\times10^{-12}} \approx \frac{3.0\times10^{-7}}{1.7\times10^{-10}} \approx 1.76\ \text{k}\Omega

Lower bound (sink current). With Vdd=3.3 VV_{dd} = 3.3\ \text{V} and the 3 mA limit:

RminVdd3 mA=3.30.0031.1 kΩR_{min} \approx \frac{V_{dd}}{3\ \text{mA}} = \frac{3.3}{0.003} \approx 1.1\ \text{k}\Omega

Pick. The legal window is roughly 1.1 kΩR1.76 kΩ1.1\ \text{k}\Omega \le R \le 1.76\ \text{k}\Omega. A standard 1.5 kΩ1.5\ \text{k}\Omega resistor sits neatly in the middle. Check it back: trise0.85×1500×200p255 nst_{rise} \approx 0.85 \times 1500 \times 200\text{p} \approx 255\ \text{ns} (under 300 ns, pass) and Isink3.3/15002.2 mAI_{sink} \approx 3.3/1500 \approx 2.2\ \text{mA} (under 3 mA, pass). Then confirm the real edge on the scope.

Practice 3 stretch

On a 3.3 V, 400 kHz bus you keep adding sensors and the capacitance has climbed to Cbus=600 pFC_{bus} = 600\ \text{pF}. Show that no single resistor can satisfy both bounds, and say what you would actually do.

Show worked solution

Rise-time ceiling at 300 ns:

Rmax300×1090.85×600×10123.0×1075.1×1010588 ΩR_{max} \approx \frac{300\times10^{-9}}{0.85 \times 600\times10^{-12}} \approx \frac{3.0\times10^{-7}}{5.1\times10^{-10}} \approx 588\ \Omega

Sink-current floor:

Rmin3.30.0031.1 kΩR_{min} \approx \frac{3.3}{0.003} \approx 1.1\ \text{k}\Omega

Now Rmax588 ΩR_{max} \approx 588\ \Omega is below Rmin1.1 kΩR_{min} \approx 1.1\ \text{k}\Omega: the window has inverted, so there is no resistor that is both fast enough and gentle enough. The numbers are telling you the problem is not the resistor, it is the 600 pF (already well past the 400 pF spec wall). The real fixes: cut the capacitance (shorter traces, drop a sensor or two off this segment, lose the long cable), split the bus into segments behind an active bus buffer / repeater so each side sees less capacitance, or move to fast-mode-plus parts whose 20 mA drive lowers RminR_{min} and reopens the window. Chasing a magic resistor here is wasted time.

The resistor you almost did not think about turns out to hold the whole bus together. It is the only hand reaching up while every chip reaches down, and good I²C is nothing more than choosing that hand carefully: strong enough to lift the line in time, gentle enough that any single chip can still pull it back to the floor. Get the tug of war balanced and two quiet wires will carry a dozen conversations without a single raised voice.

full glossary →