I2C/The two wires/Why pull-up resistors

Why pull-up resistors

A chip on I2C can only pull a line down. A pull-up resistor to the supply is the only thing that brings it back up, so a bus with no pull-ups has lines that float, and nothing on it answers.

Most GPIO outputs drive both ways: a transistor to the supply for a 1, and one to ground for a 0. An I2C output has only the second. The specification requires every chip on the bus to be open drain: it can connect the line to ground, or let go of it, and nothing more.

Letting go does not make a 1 by itself. Something has to bring the line up, and that is the pull-up: a resistor from each line to the supply, a few kilohms. With it, a line nobody is pulling sits at the supply, a 1; any chip pulling makes it a 0.

Why it is built that way

Two chips can pull at the same time and nothing happens but a 0. Had one been driving the line high while another pulled it low, the two outputs would short the supply to ground through each other. With open drain the worst case is a 0, which is why the 0 won when two chips shared an address in lesson 6. It is also what lets the clock stay shared, and a controller notice when it has lost to another.

A missing pull-up

With no pull-up, a released line floats. It drifts somewhere between the rails and a chip reading it might see either. The specification counts anything under 30 % of the supply as a 0 and anything over 70 % as a 1. On 3.3 V that is under about 1 V and over about 2.3 V; in between is undefined. A scan finds nothing, and everything times out.

The ESP32's own GPIO pull-ups are about 45 kΩ, Espressif's datasheet says: far weaker than the few kilohms a bus wants, as the next lesson shows. Don't count on them. Most modules carry proper pull-ups of their own.

Edit this page — content/fundamentals/i2c/pull-up-resistors.mdx

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Fundamentals on the forum →