Your I2C bus works perfectly on the breadboard. You move it to the actual wiring — maybe 30cm of cable to a sensor — and suddenly you're getting NACK errors, corrupted data, or complete communication failure.
You double-check the wiring. It's correct. You swap the sensor. Same problem. You lower the bus speed. It starts working again. What happened?
Bus capacitance happened.
The I2C protocol was designed for chip-to-chip communication on the same PCB, where traces are short and capacitance is measured in single-digit picofarads. When you start running I2C over cables or long PCB traces, the capacitance adds up fast, and the bus's ability to meet its timing requirements degrades until it just stops working.
Here's what's going on and what you can do about it.
How I2C Signaling Works (And Why Capacitance Kills It)
I2C uses open-drain signaling. Devices pull the bus low to transmit a 0, and the pull-up resistor pulls it back high for a 1. There are no active pull-ups — the bus relies entirely on the resistor to charge the line back to VCC.
When the bus transitions from low to high, the pull-up resistor charges the total bus capacitance through an RC circuit. The rise time is:
trise ≈ 0.8473 × Rpullup × Cbus
(Using the 30% to 70% threshold definition from the I2C spec, and the constant for an RC charging curve between those levels.)
If the capacitance is too high or the pull-up resistance is too large, the rise time exceeds the I2C specification's maximum, and the bus fails.
Maximum Rise Time by Mode
| I2C Mode | Max Frequency | Max Rise Time |
|---|---|---|
| Standard Mode | 100 kHz | 1000 ns |
| Fast Mode | 400 kHz | 300 ns |
| Fast Mode Plus | 1 MHz | 120 ns |
| High Speed Mode | 3.4 MHz | 40 ns |
The higher the frequency, the tighter the rise time requirement. A bus that works at 100kHz might completely fail at 400kHz — not because the clock is too fast, but because the signal can't rise fast enough between bits.
Where Does the Capacitance Come From?
Every conductor on the bus contributes capacitance:
| Source | Typical Capacitance |
|---|---|
| I2C device pin | 5-10 pF per pin |
| PCB trace (1mm) | ~0.1-0.5 pF |
| Wire (per meter) | ~50-100 pF |
| Connector (per pin) | 1-5 pF |
| Cable (Cat5e, per meter, one pair) | ~50 pF |
The I2C specification limits total bus capacitance to 400 pF for Standard and Fast modes. That's not a lot.
Let's Count
Say you have a bus with 4 devices, each contributing 10pF of pin capacitance, connected by 20cm of PCB trace at 0.3 pF/cm:
Cbus = (4 × 10pF) + (2 × 20cm × 0.3pF/cm) + parasitic
= 40 + 12 + ~10
= ~62 pF
That's well under 400pF. No problem on a PCB.
Now run that same bus over 3 meters of ribbon cable at 50pF/m each way:
Cbus = (4 × 10pF) + (2 × 3m × 50pF) + parasitic
= 40 + 300 + ~15
= ~355 pF
You're at 355pF — technically under 400pF, but with almost no margin. And at 400kHz Fast Mode, let's check the rise time:
trise = 0.8473 × Rpullup × Cbus
With 4.7kΩ pull-ups (a common default):
trise = 0.8473 × 4700 × 355×10⁻¹² = 1414 ns
That's 1414 ns — almost 5× the 300ns maximum for Fast Mode. The bus will fail at 400kHz.
At 100kHz (Standard Mode, 1000ns max):
Still 1414ns. Also fails.
The Pull-Up Resistor Calculation
The pull-up resistor value must satisfy two constraints:
Constraint 1: Rise Time
Rp(max) = trise(max) / (0.8473 × Cbus)
Constraint 2: Current Limit
The I2C spec limits the current through the pull-up when a device pulls the bus low. The minimum pull-up resistance ensures this current doesn't exceed spec:
Rp(min) = (VCC - VOL(max)) / IOL
Where VOL(max) is 0.4V and IOL is 3mA for Standard/Fast mode.
Example: 400kHz with 200pF Bus
Rp(max) = 300ns / (0.8473 × 200pF) = 300×10⁻⁹ / (169.46×10⁻¹²) = 1,770Ω
Rp(min) = (3.3V - 0.4V) / 3mA = 967Ω
Valid range: 967Ω to 1,770Ω. A standard 1.5kΩ resistor works.
Example: 400kHz with 400pF Bus (Maximum Spec)
Rp(max) = 300ns / (0.8473 × 400pF) = 885Ω
Rp(min) = 967Ω
The minimum resistance (967Ω) is higher than the maximum allowed (885Ω). No standard pull-up value satisfies both constraints. The bus cannot run at 400kHz with 400pF of capacitance. Period.
This is the fundamental problem with long I2C buses — at some point, no pull-up resistor value can make it work.
Solutions for Long-Distance I2C
If you need I2C to work over more than a meter or two of cable, you have options beyond just changing pull-up values.
1. Lower the Bus Speed
The simplest fix. Standard Mode (100kHz) allows 1000ns rise time, which is 3.3× more forgiving than Fast Mode (300ns). Many sensors support 100kHz even if they also support 400kHz.
At 100kHz with 355pF and 1kΩ pull-ups:
trise = 0.8473 × 1000 × 355×10⁻¹² = 301ns
Under the 1000ns limit. Works.
2. Use Stronger (Lower Value) Pull-Ups
Lower resistance = faster rise time. But you're limited by:
- The 3mA sink current spec
- The total power consumption
- The VOL requirement (pull-ups that are too strong can make it hard for devices to pull the bus low enough)
For 3.3V systems, the practical minimum is around 968Ω (for 3mA). For 5V systems, it's about 1.53kΩ.
3. Active Pull-Up Circuits
The PCA9617 and similar bus buffers use active pull-ups that source more current during transitions while still presenting high impedance for the static state. This gives you fast rise times without violating the DC spec.
4. I2C Bus Buffers/Repeaters
A bus buffer like the PCA9515 or P82B96 splits the bus into two segments, each with its own capacitance. The buffer regenerates the signal, so each segment only sees its local capacitance.
Master ---[Segment A: 50pF]--- Buffer ---[Segment B: 300pF]--- Slave
Each segment independently satisfies its rise time requirement. The buffer handles the signal regeneration between segments.
The P82B96 is particularly useful because it can also convert between different voltage levels and drive cables up to 20 meters.
5. Switch to a Different Protocol
If you're regularly running I2C over cables longer than 2-3 meters, you should seriously consider whether I2C is the right protocol.
| Protocol | Max Distance (practical) | Complexity |
|---|---|---|
| I2C (on PCB) | ~30cm | Low |
| I2C (with buffer) | ~10-20m | Medium |
| SPI | ~30cm (no built-in flow control) | Low |
| UART/Serial | ~15m at 9600 baud | Low |
| RS-485 (Modbus) | ~1200m | Medium |
| CAN bus | ~500m at 1Mbps | Medium |
| 1-Wire | ~100m (with active pull-up) | Low |
For anything over a few meters, RS-485 or CAN bus is a much better engineering choice. They're differential, noise-resistant, and designed for long cables.
I2C is fantastic for on-board communication between ICs. Using it as a long-distance bus protocol is fighting its design intent.
Practical Design Rules
| Scenario | Recommendation |
|---|---|
| <30cm, on PCB, <5 devices | Standard pull-ups (4.7kΩ), any speed |
| 30cm–1m, on PCB or short cable | Calculate pull-ups carefully, 100kHz safe, 400kHz may need stronger pull-ups |
| 1–3m cable | Use bus buffer, calculate pull-ups, stick to 100kHz |
| 3–10m cable | Use P82B96 or PCA9615 buffer, 100kHz only |
| >10m cable | Switch to RS-485 or CAN bus |
Diagnosing Capacitance Issues
If you suspect bus capacitance is causing problems:
-
Scope the bus. Look at the SDA and SCL waveforms. If the rising edges look like ramps instead of sharp transitions, capacitance is your issue.
-
Lower the speed. If the bus works at 100kHz but not 400kHz, capacitance is almost certainly the cause.
-
Reduce pull-up values. Try 2.2kΩ or 1.5kΩ. If communication improves, rise time was marginal.
-
Measure bus capacitance. With the bus idle, apply a known resistor and measure the RC time constant. Or check individual cable specs for pF/m ratings.
-
Count your devices. Each device adds pin capacitance. More devices = higher total capacitance.
Quick Calculation Reference
To determine if your I2C bus will work:
- Estimate total bus capacitance (all pins + traces + cable)
- Determine max rise time for your I2C mode
- Calculate max pull-up value: Rp(max) = trise / (0.8473 × Cbus)
- Calculate min pull-up value: Rp(min) = (VCC - 0.4V) / 3mA
- If Rp(min) > Rp(max), the bus cannot work at that speed with that capacitance
| Cbus | Rp(max) at 100kHz | Rp(max) at 400kHz |
|---|---|---|
| 50 pF | 23.6 kΩ | 7.1 kΩ |
| 100 pF | 11.8 kΩ | 3.5 kΩ |
| 200 pF | 5.9 kΩ | 1.8 kΩ |
| 300 pF | 3.9 kΩ | 1.2 kΩ |
| 400 pF | 2.9 kΩ | 885 Ω |
(Remember, Rp(min) for 3.3V is 967Ω — so the 400pF at 400kHz case is impossible.)
Want to size your I2C pull-up resistors without the spreadsheet gymnastics? Try the I2C Pull-Up Resistor Calculator — enter your bus capacitance, voltage, and target speed, and it gives you the valid pull-up range with full rise time verification. Runs in your browser, no signup needed.
I2C is a great protocol — for the right application. Know its limits, respect the capacitance budget, and your bus will be reliable. Push it past what it was designed for, and you'll spend more time debugging than designing.