Concept explainer · Intermediate · 4 min read
I2C Explained
Wiring, Pull-ups, Addresses and Troubleshooting
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
I2C is a two-wire bus that lets one microcontroller talk to many sensors and displays using a data line (SDA) and a clock line (SCL). Every device has a 7-bit address, both lines need pull-up resistors (typically 4.7 kΩ at 100 kHz), and all devices must share a ground. An I2C scanner sketch finds the address of anything connected.
Key specs at a glance
- Wires
- SDA (data), SCL (clock), plus GND and power
- Addressing
- 7-bit, up to 112 usable addresses
- Speeds
- 100 kHz standard, 400 kHz fast, 1 MHz fast-mode plus
- Pull-ups
- 4.7 kΩ typical at 100 kHz; 2.2 kΩ for 400 kHz or longer wires
- Line type
- Open-drain: devices only pull low
- Practical length
- Under about 1 m on hobby boards without bus extenders
A shorted, over-charged or damaged lithium cell can get very hot and catch fire. Use a protection board or BMS, never short the terminals, charge on a non-flammable surface and do not leave a charging pack alone. Throw away cells that are swollen or dented.
How I2C works
The controller (your Arduino, ESP32 or Pico) drives the clock and starts every conversation by sending a device address. Only the device with that address answers. Because devices can only pull the lines low, pull-up resistors return them to high between bits. That is why I2C works with many devices on the same two wires, and also why missing pull-ups are the most common I2C fault.
Most breakout modules already include 4.7 kΩ or 10 kΩ pull-ups. With several modules connected, their pull-ups combine in parallel; if the total drops below about 1 kΩ, some devices cannot pull the line low enough.
Default I2C pins on popular boards
| Board | SDA | SCL | Notes |
|---|---|---|---|
| Arduino Uno / Nano | A4 | A5 | Also on the two pins beside AREF (Uno R3) |
| Arduino Mega | 20 | 21 | |
| ESP32 DevKit | GPIO 21 | GPIO 22 | Remappable with Wire.begin(sda, scl) |
| ESP8266 NodeMCU | D2 (GPIO 4) | D1 (GPIO 5) | |
| Raspberry Pi Pico | GP4 | GP5 | I2C0 default; many other pin pairs work |
| Raspberry Pi 4/5 | GPIO 2 (pin 3) | GPIO 3 (pin 5) | 1.8 kΩ pull-ups on board |
- Arduino Uno / Nano
- SDA:
- A4
- SCL:
- A5
- Notes:
- Also on the two pins beside AREF (Uno R3)
- Arduino Mega
- SDA:
- 20
- SCL:
- 21
- ESP32 DevKit
- SDA:
- GPIO 21
- SCL:
- GPIO 22
- Notes:
- Remappable with Wire.begin(sda, scl)
- ESP8266 NodeMCU
- SDA:
- D2 (GPIO 4)
- SCL:
- D1 (GPIO 5)
- Raspberry Pi Pico
- SDA:
- GP4
- SCL:
- GP5
- Notes:
- I2C0 default; many other pin pairs work
- Raspberry Pi 4/5
- SDA:
- GPIO 2 (pin 3)
- SCL:
- GPIO 3 (pin 5)
- Notes:
- 1.8 kΩ pull-ups on board
Common I2C addresses (and conflicts)
Two devices with the same address cannot share a bus. Many modules let you change the address with a solder jumper or pin; otherwise use a TCA9548A multiplexer or a second I2C bus.
| Module | Address(es) | Watch out for |
|---|---|---|
| SSD1306 OLED | 0x3C (sometimes 0x3D) | |
| PCF8574 LCD backpack | 0x27 (PCF8574) or 0x3F (PCF8574A) | Try both if the screen stays blank |
| MPU6050 IMU | 0x68, or 0x69 with AD0 high | Clashes with DS3231 RTC |
| DS3231 RTC | 0x68 (+ 0x57 EEPROM) | Clashes with MPU6050 |
| BMP280 / BME280 | 0x76 or 0x77 | |
| PCA9685 servo driver | 0x40 to 0x7F | Clashes with INA219 at 0x40 |
| INA219 current sensor | 0x40 to 0x4F | |
| ADS1115 ADC | 0x48 to 0x4B |
- SSD1306 OLED
- Address(es):
- 0x3C (sometimes 0x3D)
- PCF8574 LCD backpack
- Address(es):
- 0x27 (PCF8574) or 0x3F (PCF8574A)
- Watch out for:
- Try both if the screen stays blank
- MPU6050 IMU
- Address(es):
- 0x68, or 0x69 with AD0 high
- Watch out for:
- Clashes with DS3231 RTC
- DS3231 RTC
- Address(es):
- 0x68 (+ 0x57 EEPROM)
- Watch out for:
- Clashes with MPU6050
- BMP280 / BME280
- Address(es):
- 0x76 or 0x77
- PCA9685 servo driver
- Address(es):
- 0x40 to 0x7F
- Watch out for:
- Clashes with INA219 at 0x40
- INA219 current sensor
- Address(es):
- 0x40 to 0x4F
- ADS1115 ADC
- Address(es):
- 0x48 to 0x4B
Find your device with an I2C scanner
Upload this sketch, open the Serial Monitor at 115200 baud, and it lists every address that responds. If nothing is found, check wiring, power and pull-ups before suspecting the library.
#include <Wire.h>
void setup() {
Serial.begin(115200);
Wire.begin(); // ESP32: Wire.begin(21, 22);
Serial.println("Scanning...");
for (byte addr = 1; addr < 127; addr++) {
Wire.beginTransmission(addr);
if (Wire.endTransmission() == 0) {
Serial.print("Found device at 0x");
Serial.println(addr, HEX);
}
}
}
void loop() {}Mixing 3.3 V and 5 V devices on I2C
If a 5 V module has pull-ups to 5 V and you connect it to a 3.3 V ESP32 or Pico, the bus idles at 5 V and stresses the 3.3 V pins. Either remove or re-route the module's pull-ups to 3.3 V, or use a bidirectional BSS138 level shifter designed for I2C.
I2C vs SPI vs UART
| I2C | SPI | UART | |
|---|---|---|---|
| Wires | 2 (shared) | 4 + one CS per device | 2 per device (TX/RX) |
| Typical speed | 100 to 400 kHz | 1 to 80 MHz | 9600 to 115200 baud |
| Devices per bus | Many, by address | Many, by chip-select pin | One |
| Best for | Sensors, small OLEDs, RTCs | Fast displays, SD cards | GPS, Bluetooth, debug output |
- Wires
- I2C:
- 2 (shared)
- SPI:
- 4 + one CS per device
- UART:
- 2 per device (TX/RX)
- Typical speed
- I2C:
- 100 to 400 kHz
- SPI:
- 1 to 80 MHz
- UART:
- 9600 to 115200 baud
- Devices per bus
- I2C:
- Many, by address
- SPI:
- Many, by chip-select pin
- UART:
- One
- Best for
- I2C:
- Sensors, small OLEDs, RTCs
- SPI:
- Fast displays, SD cards
- UART:
- GPS, Bluetooth, debug output
Try it: I2C pull-up calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Swapping SDA and SCL. Nothing is damaged, but nothing responds.
- Running without pull-ups, or with too many modules' pull-ups in parallel.
- Using long jumper wires or flat cable at 400 kHz; drop to 100 kHz or shorten the bus.
- Two modules with the same address, such as an MPU6050 and a DS3231 at 0x68.
- Forgetting a shared ground between boards powered from different supplies.
Frequently asked questions
What pull-up resistor value should I use for I2C?
4.7 kΩ to 3.3 V or 5 V suits most hobby buses at 100 kHz. Use 2.2 kΩ for 400 kHz or longer wires. Check whether your modules already include pull-ups before adding more.
How many devices can I connect to I2C?
Up to 112 addresses in theory. In practice the limit is bus capacitance (400 pF) and address clashes, so a few to a dozen modules on short wires is typical.
Is I2C the same as IIC or TWI?
Yes. IIC is another way of writing I2C, and TWI (Two-Wire Interface) is the name Microchip/Atmel uses for compatible hardware.
Why does my I2C scanner find no devices?
Check power to the module, the shared ground, SDA/SCL orientation and the pins your board uses. Then confirm pull-ups exist; a missing pull-up is the most common cause.
How long can I2C wires be?
I2C was designed for on-board use. Up to about 1 m works with good pull-ups at 100 kHz. For longer runs use a differential extender such as the P82B715 or switch to RS485 or CAN.
Parts for this guide
Calculators
Terms in this guide
Keep learning
Sources
- UM10204 I2C-bus specification and user manual (NXP Semiconductors)
- Arduino Wire library reference (Arduino)
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.




