Skip to content

I2C protocol not working #10114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
ankushiot opened this issue Aug 5, 2024 · 5 comments
Closed
1 task done

I2C protocol not working #10114

ankushiot opened this issue Aug 5, 2024 · 5 comments
Labels
Resolution: More info needed More info must be provided in this issue

Comments

@ankushiot
Copy link

Board

ESP32 C6 WROOM 1

Device Description

Unable to detect I2C sensor connected.

Hardware Configuration

No only BME 680 was connected. SDA Pin 6, SCL Pin 7

Version

other

IDE Name

Arduino IDE

Operating System

Windows 11

Flash frequency

40MHz

PSRAM enabled

yes

Upload speed

115200

Description

Unable to detect I2C sensor even I2C scanned doesn't shows anything.

Sketch

Ada Fruit bme680test.ino

Debug Message

Sensor working fine on Arduino Nano

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@ankushiot ankushiot added the Status: Awaiting triage Issue is waiting for triage label Aug 5, 2024
@P-R-O-C-H-Y
Copy link
Member

Hello @ankushiot,
Can you please provide more informations:

  • Sketch to reproduce the issue
  • Debug log from the sketch -> Set Debug level to "Verbose"
  • Arduino core version

Thank you.

@P-R-O-C-H-Y P-R-O-C-H-Y added Resolution: More info needed More info must be provided in this issue and removed Status: Awaiting triage Issue is waiting for triage labels Aug 5, 2024
@Thieuzor
Copy link

Thieuzor commented Jan 14, 2025

Hi! I've got the same issue with the following sketch:

#include <Wire.h>
 
void setup() {
  Wire.begin(21,22,100000);
  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
}
 
void loop() {
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
      nDevices++;
    }
    else if (error==4) {
      Serial.print("Unknow error at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  }
  else {
    Serial.println("done\n");
  }
  delay(5000);          
}

Only on 3.1.x it's not working anymore. I've tested it successfully on previous versions.

@me-no-dev
Copy link
Member

Can you try instead of Wire.begin(21,22,100000); to have

Wire.setPins(21, 22);
Wire.begin();

@me-no-dev
Copy link
Member

me-no-dev commented Jan 14, 2025

The following code works for me on 3.1.1

#include "Wire.h"

void setup() {
  Serial.begin(115200);
  Wire.setPins(6, 7);
  Wire.begin();
}

void loop() {
  byte error, address;
  int nDevices = 0;

  delay(5000);

  Serial.println("Scanning for I2C devices ...");
  for (address = 0x01; address < 0x7f; address++) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.printf("I2C device found at address 0x%02X\n", address);
      nDevices++;
    } else if (error != 2) {
      Serial.printf("Error %d at address 0x%02X\n", error, address);
    }
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found");
  }
}

@Parsaabasi
Copy link

Hi @ankushiot
Do you still need assistance with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: More info needed More info must be provided in this issue
Projects
None yet
Development

No branches or pull requests

6 participants