Sizing I2C Pull-Up Resistors
"Use 4.7 kΩ" is the usual advice for I2C pull-ups, and it is right often enough to be dangerous. The correct value sits between two limits that depend on the supply voltage, the bus speed and the capacitance of the wiring. On a short 100 kHz bus the window is wide and almost anything works. At 400 kHz with a few devices and some cable, the window narrows quickly and 4.7 kΩ can fall outside it.
Why the resistor matters
I2C devices only pull the lines low. Nothing drives them high; the pull-up resistor does that by charging the capacitance of the bus. So a falling edge is fast, set by the device's output transistor, while a rising edge is an RC charging curve set by the resistor and the bus capacitance. Too large a resistor and the line rises too slowly to reach a valid high level in time. Too small and a device cannot pull the line low enough.
The lower limit: sink current
When a device holds the line low, the resistor's full current flows into its output. The I2C specification guarantees a low level of 0.4 V at a sink current of 3 mA for standard and fast mode, and at 20 mA for fast-mode plus. The smallest allowed resistor is therefore:
Rmin = (Vdd − 0.4 V) / Isink
| Supply | Rmin, standard and fast mode (3 mA) | Rmin, fast-mode plus (20 mA) |
|---|---|---|
| 1.8 V | 467 Ω | 70 Ω |
| 3.3 V | 967 Ω | 145 Ω |
| 5.0 V | 1.53 kΩ | 230 Ω |
The fast-mode plus column only applies if every device on the bus is a fast-mode plus part. One ordinary 3 mA device brings the limit back to the left column.
The upper limit: rise time
The specification measures rise time between 30% and 70% of the supply voltage. For an RC charging curve, the time between those two points is:
t_rise = R × C × ln(0.7 / 0.3) = 0.8473 × R × C
The maximum rise time is 1000 ns in standard mode (100 kHz), 300 ns in fast mode (400 kHz) and 120 ns in fast-mode plus (1 MHz). Solving for the resistor:
Rmax = t_rise_max / (0.8473 × Cbus)
| Bus capacitance | Rmax, standard mode | Rmax, fast mode | Rmax, fast-mode plus |
|---|---|---|---|
| 50 pF | 23.6 kΩ | 7.08 kΩ | 2.83 kΩ |
| 100 pF | 11.8 kΩ | 3.54 kΩ | 1.42 kΩ |
| 200 pF | 5.90 kΩ | 1.77 kΩ | 708 Ω |
| 400 pF | 2.95 kΩ | 885 Ω | 354 Ω |
Read this table against the common 4.7 kΩ. In standard mode it is fine up to 200 pF. In fast mode it is already too large at 100 pF, where the limit is 3.54 kΩ: the rise time comes out at 398 ns against the 300 ns allowed. And at 400 pF in fast mode the upper limit of 885 Ω is below the 967 Ω lower limit for a 3.3 V bus, so no resistor value satisfies both. That bus must be slowed down, shortened, or split with a buffer.
Estimating bus capacitance
Bus capacitance is the sum of everything connected to the line:
- Each device pin, typically up to about 10 pF. The exact figure is in the device's datasheet.
- PCB traces, on the order of 1 pF per centimetre for a typical trace over a ground plane.
- Cables, which are usually the largest part. Ribbon and multi-core cable is commonly in the range of 50 to 100 pF per metre between adjacent conductors.
These are rough figures for a first estimate. A board with four devices and 15 cm of trace lands around 50 pF. Add half a metre of cable to an external sensor and the total is closer to 100 pF, which is where a 400 kHz bus stops working with 4.7 kΩ.
Choosing inside the window
Any value between Rmin and Rmax meets the specification. Within the window there is a trade:
- Lower values give faster edges and better noise immunity, at the cost of current. Every time a line is low, Vdd / R flows through the resistor: 1.5 mA for 2.2 kΩ at 3.3 V, 0.70 mA for 4.7 kΩ, 0.33 mA for 10 kΩ. On a battery-powered device with a busy bus this is measurable.
- Higher values save power and are easier on weak outputs, but leave less margin when a cable or another device is added later.
A reasonable default is a value about half way between the limits, leaning lower if the bus leaves the board.
The hidden parallel resistors
Pull-ups on the same line are in parallel. Sensor breakout boards usually carry their own, often 4.7 kΩ or 10 kΩ. Plug three such boards into one bus and three 10 kΩ resistors become 3.33 kΩ; two 4.7 kΩ become 2.35 kΩ. This is usually harmless and sometimes helpful, but with enough modules the combined value drops below Rmin, and devices can no longer pull the line to a valid low. If a bus stops working when one more module is added, measure the resistance from SDA to Vdd with the power off before suspecting the software.
The microcontroller's internal pull-ups, typically tens of kilohms, are too weak to serve as I2C pull-ups for anything but a very short, slow bus. They are also in parallel with the external ones, where their effect is negligible.
Measuring instead of estimating
The capacitance estimate is the weakest part of the calculation, and it is easy to replace with a measurement. Put an oscilloscope probe on SCL, trigger on a rising edge, and measure the time from 30% to 70% of the supply voltage. For a 3.3 V bus those levels are 0.99 V and 2.31 V. Use a ×10 probe; a ×1 probe adds around 100 pF of its own and changes what you are measuring.
The measured rise time also gives the real bus capacitance, by turning the formula around:
Cbus = t_rise / (0.8473 × R)
A rise time of 400 ns with 4.7 kΩ pull-ups means about 100 pF. From there the tables above give the largest resistor that meets the target speed.
Symptoms of a wrong value
- Too large: rounded, shark-fin edges on the scope. The bus works at 100 kHz and fails at 400 kHz, or works on the bench and fails with the production cable. Clock stretching by the controller's own rise-time detection can make the actual bit rate lower than configured.
- Too small: the low level sits well above ground, several hundred millivolts or more. Some devices acknowledge and others do not.
Run the numbers: I2C Timing & Pull-Up Resistor Calculator does this calculation for your own values.
More guides
- ADC Resolution Is Not Accuracy: LSB Size, Reference Error, Settling and Oversampling
- C Struct Padding on Cortex-M: Where the Bytes Go and How to Control Them
- CAN Bit Timing Step by Step: Choosing BRP, Segments and Sample Point
- Why Your CRC Does Not Match: Polynomial, Init, Reflection and XOR-Out Explained
- Fixed-Point Arithmetic in Q Format: Scaling, Multiplying and Not Overflowing
- Floating-Point Pitfalls on Microcontrollers: Precision, Timestamps and Accidental Doubles
- How Much UART Baud Rate Error Is Too Much? The Sampling Math