Sub topic 6
Standard, Fast and Other I2C Bus Speeds
This chapter assumes you understand Arduino setup() and loop(), basic resistors, and how to connect SDA and SCL. You should also know how to use the Serial Monitor.
What the bus speed means
I2C speed is the frequency of the SCL clock generated by the controller. A speed of 100 kHz means the controller produces about 100,000 clock cycles per second. Each byte also needs an acknowledgment bit, so the useful data rate is lower than the clock rate.
Common I2C speed modes are:
| Mode | Maximum SCL frequency | Typical use |
|---|---|---|
| Standard mode | 100 kHz | General sensors and displays |
| Fast mode | 400 kHz | Faster sensor sampling |
| Fast-mode Plus | 1 MHz | Short, carefully designed buses |
| High-speed mode | 3.4 MHz | Specialized hardware |
The slowest device on the bus determines the safe choice. A controller may request 400 kHz, but every target must support that speed. A target is the device that responds to the controller.
Why wiring affects speed
SDA and SCL are open-drain lines. Devices pull a line low, but pull-up resistors bring it back high. The wires, circuit-board traces, device pins, and input capacitance all store electrical charge. Together, they form bus capacitance.
A larger capacitance makes the rising edge slower. At a higher clock rate, there is less time for the line to rise before the next bit is sampled. A bus can therefore work at 100 kHz but fail at 400 kHz.
Lower-value pull-ups create faster rising edges, but they draw more current whenever a device pulls a line low. Higher-value pull-ups save current but may produce edges that are too slow. Use the values recommended by your board and device datasheets. Common breakout boards often include pull-ups already, so connecting several boards can make the total resistance too low.
Selecting a speed with Wire
On many Arduino boards, Wire starts at a board-specific default, commonly 100 kHz. Set the requested speed after starting the I2C interface:
#include <Wire.h>
void setup() {
Serial.begin(9600);
Wire.begin();
Wire.setClock(400000); // Request Fast mode: 400 kHz
Serial.println("I2C started at 400 kHz");
}
void loop() {
}Wire.setClock() requests a rate. It does not guarantee that the physical bus can meet it. Check the target datasheets, use short wiring, and test communication at the selected rate. If errors appear, reduce the speed first. A slower bus often fixes marginal rise times and gives clock-stretching targets more time.
Practical choices
Start with 100 kHz when wiring a new circuit. Move to 400 kHz when you need faster updates and all devices support it. Speeds above 400 kHz require closer attention to pull-ups, capacitance, voltage levels, and board layout.
Exercise
A bus works at 100 kHz but produces incorrect readings at 400 kHz. What should you try first?
Show answer
Confirm that every target supports 400 kHz, then inspect pull-ups and wiring. Try shorter wires, correct the pull-up network, or return to 100 kHz.