Skip to content

I2C scan takes extremely long (~126 seconds) with Wire.endTransmission() on empty bus #492

@shiv836

Description

@shiv836

Board/Environment

Board: Arduino Uno R4 WiFi

Core Version: 1.5.1

IDE: Arduino IDE 2.2.1

OS: Windows

Sketch to reproduce

#include <Wire.h>

void setup() {
  Wire.begin();
  Serial.begin(115200);
  delay(1000);
  Serial.println("\nI2C Scanner with Timing");
}

void loop() {
  byte error;
  unsigned long startTime = millis();

  Serial.println("Scanning...");
  for (byte address = 1; address < 127; address++) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
  }

  unsigned long elapsed = millis() - startTime;
  Serial.print("Time taken to scan I2C bus 0: ");
  Serial.print(elapsed);
  Serial.println(" ms");
  delay(5000);
}

Observed Behavior

With no I²C devices connected, a single full scan takes ~126,000 ms (≈126 seconds).

Expected scan duration is typically <200 ms on other Arduino cores.

Each Wire.endTransmission() seems to block for ~1 second when no device responds.

Expected Behavior

A complete scan of addresses 1–126 should complete in a few hundred milliseconds, even when no devices are present.

Metadata

Metadata

Assignees

Labels

topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions