Sub topic 3
Why the Bus Needs Pull-Up Resistors
Prerequisites and the electrical model
This chapter assumes you understand basic Arduino sketches, breadboard wiring, voltage, current, and resistance. You should also know that a resistor limits current.
I2C uses two shared signal lines:
- SDA carries data.
- SCL carries the clock.
Both lines use open-drain signaling. An I2C device can connect a line to ground, making it LOW. It does not actively drive the line HIGH. A pull-up resistor connects each line to the bus supply voltage, allowing the line to return to HIGH when no device is pulling it LOW.
This arrangement lets several devices share the same wires safely. If one device sends LOW while another device leaves the line released, the line remains LOW. No device needs to fight another device by driving opposite voltage levels.
Why a resistor is necessary
Without a pull-up resistor, a released line would be electrically floating. Its voltage could be unpredictable, so the Arduino might read random HIGH and LOW values.
The resistor also limits current when a device pulls the line LOW. For example, with a 5 V supply and a 4.7 kΩ resistor, the approximate current is:
5 V / 4,700 Ω = 1.06 mA
The device must sink this current while holding the line LOW. A smaller resistor produces a faster rising edge, but it also increases the current that the device must sink.
The resistor and the bus capacitance form an RC circuit. Capacitance comes from the Arduino pins, device inputs, circuit-board traces, and cables. A larger resistance or larger capacitance makes the signal rise more slowly.
Choosing a pull-up value
| Pull-up value | Rise time | LOW-level current at 5 V | Typical use |
|---|---|---|---|
| 10 kΩ | Slower | 0.5 mA | Short, low-capacitance bus |
| 4.7 kΩ | Moderate | 1.1 mA | Common starting value |
| 2.2 kΩ | Faster | 2.3 mA | Higher capacitance, if devices allow it |
Start with 4.7 kΩ on both SDA and SCL for a short 5 V bus. Use an oscilloscope or logic analyzer when the bus is long, fast, or unreliable. The I2C speed and the device datasheets determine the allowed rise time.
Common pull-up mistakes
Many sensor breakout boards already contain pull-ups. Connecting several such boards can place their resistors in parallel. Two 4.7 kΩ resistors become an effective 2.35 kΩ resistor. Several boards can reduce the resistance too far, increasing sink current.
Some boards use pull-ups to 5 V while a 3.3 V device is connected. This can exceed the device's input limits. Check the voltage of every pull-up before connecting the bus. Remove duplicate resistors or use a suitable level shifter when necessary.
Exercise
Why can an I2C device safely pull SDA LOW even when another device is connected to the same line?
Show answer
Devices only pull the line LOW or release it. They do not actively drive it HIGH, so there is no direct HIGH-versus-LOW output conflict.