Ad Space — Top Banner

I2C Not Working

Espressif ESP32

Severity: Moderate

What Does This Error Mean?

ESP32 I2C not working is usually caused by incorrect SDA/SCL pin assignment, missing pull-up resistors, or wrong device I2C address in the code. Run an I2C scanner sketch first to confirm the device is detected before writing any application code.

Affected Models

  • ESP32 DevKit
  • ESP32-WROOM-32
  • ESP32-S2
  • ESP32-S3
  • ESP32-C3
  • ESP32 WROVER

Common Causes

  • SDA and SCL pins swapped or using wrong GPIO numbers for the Wire library
  • Missing or incorrect pull-up resistors — I2C requires 4.7kΩ pull-ups on SDA and SCL
  • Wrong I2C address in code — device address depends on hardware address pins
  • Multiple devices on the bus with conflicting addresses
  • I2C bus speed too high for the device or cable length

How to Fix It

  1. Flash an I2C scanner sketch.

    Upload a standard I2C scanner to the ESP32. Open Serial Monitor at 115200 baud. If the device appears at any address, I2C is working — your code may be using the wrong address. If nothing appears, the issue is wiring or power.

  2. Verify SDA and SCL pin numbers.

    ESP32 default I2C pins are GPIO 21 (SDA) and GPIO 22 (SCL), but Wire.begin() can use any GPIO. Check your call to Wire.begin(SDA, SCL) or Wire.begin() and confirm the pins match your physical connections. Double-check by tracing the wires from the sensor to the ESP32.

  3. Add 4.7kΩ pull-up resistors.

    I2C requires pull-up resistors on both SDA and SCL lines. Many breakout boards include them, but if you are wiring directly to a bare sensor, you must add 4.7kΩ resistors from SDA to 3.3V and SCL to 3.3V. Without pull-ups, I2C will not work reliably.

  4. Confirm the device I2C address.

    Most I2C sensors have configurable addresses via address pins (ADDR pin tied to GND or VCC). Check the sensor datasheet or the board silkscreen for the default address. Update Wire.beginTransmission(address) in your code to match.

  5. Reduce I2C clock speed.

    Some slow sensors or long cable runs require a reduced I2C clock. Add Wire.setClock(100000) in your setup() to set the clock to 100kHz (standard mode). The default ESP32 I2C clock is 100kHz, but some libraries override it to 400kHz, which can fail with slower devices.

When to Call a Professional

ESP32 I2C issues are almost always software or wiring. If the I2C scanner never detects the device with confirmed correct wiring and pull-ups, the I2C device itself may be faulty.