Sub topic 13
Bus Capacitance and Cable Length
This chapter assumes that you understand Arduino sketches, breadboard wiring, voltage, current, resistors, and the basic I2C transaction. The key idea is that an I2C bus is limited by how quickly its shared signals can rise from low to high.
Why the wires have capacitance
Every wire has a small amount of electrical capacitance. Capacitance is the ability to store electrical charge. The SDA and SCL wires also gain capacitance from:
- The copper traces on each circuit board
- Jumper wires and cable
- The input pins of connected devices
- Connector and breadboard contacts
All of these capacitances add together. A longer cable usually has more capacitance, and several devices add more pin capacitance.
I2C devices pull the lines low with transistor switches. They do not normally drive the lines high. Pull-up resistors bring SDA and SCL back to the high voltage. The resistor and total bus capacitance form an RC circuit. Its approximate time constant is:
τ = R × C
A larger resistance or larger capacitance makes the rising edge slower.
What a slow rising edge does
During a rising edge, the signal may remain between low and high for too long. A device might then sample an uncertain voltage. At higher clock rates, the next clock edge arrives before the signal has reached a valid high level.
Typical symptoms include:
- Devices work with short jumper wires but fail with a longer cable.
- A scanner finds some devices inconsistently.
- Communication works at 100 kHz but fails at 400 kHz.
- The logic analyzer shows rounded rising edges.
- The bus stays low after a device releases it.
The exact limit depends on the I2C speed mode and the electrical specifications of every device. Treat the standard bus capacitance limits as design targets, not guarantees that any wiring arrangement will work.
Choosing pull-up values
A smaller pull-up resistance charges the capacitance faster. However, it also causes more current when a device holds the line low:
I = V / R
For a 5 V bus with a 1 kΩ pull-up, a low line requires about 5 mA. A 10 kΩ pull-up requires about 0.5 mA, but produces a slower rising edge.
| Pull-up resistance | Rising edge | Low-level current at 5 V |
|---|---|---|
| 10 kΩ | Slow, lower load | 0.5 mA |
| 4.7 kΩ | Common starting point | 1.1 mA |
| 2.2 kΩ | Faster, higher load | 2.3 mA |
Use the largest resistance that still gives reliable rising edges, while checking that every device can safely sink the resulting low-level current. Many breakout boards already include pull-ups. Several boards in parallel can create a resistance that is too small.
Practical cable guidance
Keep I2C wiring short and place the pull-up resistors near the controller or near the center of the bus. Use a ground wire alongside SDA and SCL. Avoid running the bus beside noisy motors, relay wiring, or rapidly switching power lines.
When a cable must be longer, try these changes in order:
- Lower the clock with
Wire.setClock(100000). - Reduce the total bus capacitance by shortening the cable or removing unnecessary devices.
- Use stronger pull-ups, such as 4.7 kΩ instead of 10 kΩ, if the devices allow the added current.
- Use a suitable I2C buffer or a bus extender for demanding installations.
Exercise
A bus works at 100 kHz with 10 kΩ pull-ups but fails at 400 kHz. What should you test first?
Show answer
Inspect the rising edges, try a shorter cable, and verify that the existing pull-ups are suitable. Keep the lower speed if it restores reliable communication.