i2c pullup hardware stm32 nrf52

I2C Pull-up Resistor Selection: The Complete Guide

· Bob Peters

Every I2C design eventually runs into the same question: what value pull-up resistors do I use? The answer is “it depends” — but it depends on exactly three things you can calculate.

The physics in 30 seconds

I2C lines are open-drain. Every device on the bus can only pull the line low. The pull-up resistor pulls it back to VCC when nobody is asserting it. The two constraints:

  1. Low-level output: The resistor must not source more current than the device can sink while holding the line at a valid low voltage (≤ 0.4 V for standard I2C devices).
  2. Rise time: The RC circuit formed by the pull-up resistor and bus capacitance must charge the line to a valid high voltage (≥ 0.7 × VCC) within the maximum allowed rise time for your speed mode.

These give you a minimum and maximum resistor value. Anything in between works. The I2C pull-up calculator computes this range for your parameters.

The minimum: how low can you go?

The I2C spec (NXP UM10204) says the output driver must sink at least 3 mA with the line at V_OL ≤ 0.4 V for Standard and Fast mode. This gives:

R_min = (VCC - 0.4V) / 3 mA

At 3.3 V: R_min = 967 Ω → round up to 1 kΩ At 5.0 V: R_min = 1533 Ω → round up to 1.5 kΩ

Fast+ mode (1 MHz) specifies up to 20 mA sink capability, dropping the minimum to ~145 Ω at 3.3 V.

Note: most sensors and MCU I2C peripherals exceed the 3 mA minimum significantly (STM32 I2C can sink ~20 mA depending on GPIO drive configuration). But the spec minimum is the safe design point — you can’t always know what’s on the bus.

The maximum: RC rise time

Every device pin and PCB trace adds capacitance. The I2C spec limits total bus capacitance to 400 pF. The rise time constant for an RC circuit:

t_rise ≈ 0.8473 × R × C_bus

(The 0.8473 factor comes from charging from 0 to 70% of VCC, matching the I2C V_IH threshold.)

Speed mode rise time limits:

ModeMax t_riseMax R at 100 pFMax R at 200 pF
Standard (100 kHz)1000 ns11.8 kΩ5.9 kΩ
Fast (400 kHz)300 ns3.5 kΩ1.8 kΩ
Fast+ (1 MHz)120 ns1.4 kΩ0.7 kΩ

4.7 kΩ works fine for 100 kHz. It fails at 400 kHz with more than ~75 pF. This is why “use 4.7 kΩ” is incomplete advice.

Estimating bus capacitance

You need to estimate the total capacitance on the SDA and SCL lines:

  • PCB trace: ~1 pF per centimetre for typical FR4 with a ground plane
  • Microcontroller I2C pin: 5–10 pF (check the datasheet — STM32G0 pins are ~7 pF, nRF52 pins ~2 pF)
  • Sensor pin: 5–15 pF (check the sensor datasheet; many don’t spec this, assume 10 pF)
  • Connector (0.1” header): ~3–5 pF per pin
  • Cable: twisted pair adds ~50–70 pF/m, ribbon cable adds ~100 pF/m

A typical design with an STM32, two sensors, and 10 cm of trace per line: 7 + 10 + 10 + 10 = ~37 pF. Use 100 pF as a conservative estimate if you haven’t measured.

If you have a scope, you can measure rise time directly and back-calculate the effective capacitance: C = t_rise / (0.8473 × R_pullup).

The internal pull-up trap

STM32, nRF52, and ESP32 all have configurable pull-up resistors on GPIO pins. At first glance, enabling the internal pull-up looks like it saves two external resistors. It doesn’t work.

Internal pull-ups on these MCUs are typically 40–50 kΩ. At 100 kHz Standard mode with 50 pF bus capacitance: t_rise = 0.8473 × 47 kΩ × 50 pF = 1993 ns. That’s 2× the spec limit. You’ll get clock stretching, NACK responses, and data corruption — intermittently.

Disable the internal pull-ups (GPIO_NOPULL in STM32 HAL) and use external resistors.

Multiple pull-up sources

This catches designers who use modules. If your baseboard has 4.7 kΩ pull-ups and you plug in an Adafruit or SparkFun module that also has 4.7 kΩ pull-ups, the effective pull-up is:

R_effective = 4700 ∥ 4700 = 2.35 kΩ

At Fast mode with 200 pF bus capacitance: t_rise = 0.8473 × 2350 × 200 pF = 398 ns. Over the 300 ns Fast mode limit. The bus might work in the lab but fail at high temperatures when capacitance increases.

Check your modules for pull-up resistors before assuming the bus has only one pull-up per line. Remove the module’s pull-ups (DNP the resistors on the module if possible) and control the bus from one place.

What value to actually use

For most designs at 3.3 V and 400 kHz Fast mode:

  • Bus capacitance < 100 pF: 2.2 kΩ (E24 standard value, comfortably in range)
  • Bus capacitance 100–200 pF: 1 kΩ (near R_min, check your actual capacitance)
  • Bus capacitance > 200 pF: reduce speed mode or add an I2C buffer (PCA9517, LTC4311)

Use the I2C pull-up calculator to check your specific setup.