The clock
SDA carries the bits and SCL says when to read each one. Without the clock, a long run of zeros has no length a receiver can count, and the clock always comes from the controller.
Send four bits on one wire with nothing else, say 0, 0, 0 and 1, and the receiver sees the line sit low for a while and then go high. Was that three zeros, or one, or ten? Two chips could agree a speed in advance, as a serial port does, but then both need an accurate clock of their own.
I2C adds a second wire instead. SCL is the clock: every pulse on it says read now. SDA is the data. The rule, in the specification's words, is that the data on SDA must be stable while SCL is high, and may change only while SCL is low. One pulse, one bit.
The controller owns the clock
The ESP32 sends every clock pulse, including the ones during which a module is sending data back. That is why a module needs no clock of its own, and why the ESP32 can run the bus at whatever speed it likes, up to what the slowest chip on it allows. It can even stop between bytes; nothing is lost.
How fast
- 100 kHz, standard mode: the original 1982 bus, and what every module
supports.
Wire.setClock(100000). - 400 kHz, fast mode, added in version 1.0 of the specification in 1992. Many modules can do it, the LM75 temperature chip included.
- 1 MHz (Fast-mode Plus, 2007) and 3.4 MHz (high-speed mode, 1998) exist, and few sensor modules use them.
At 100 kHz a bit lasts 10 µs, far too fast to see. The bench runs 100,000 times slower: one bit a second.
Edit this page — content/fundamentals/i2c/the-clock.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.