ESP32s2 I2C Scanner not working

Hello Everyone,
I am using esp32s2 wroom board. I have I2C salves EEPROM and RTC. I run the I2C scanner but no device is coming. Hardware is fine and I also have 4.7k pull up resistor. I found some issue in GitHub but it is not working. ([2.0.0] Fix issue with init I2C for esp32 S2 by chegewara · Pull Request #4776 · espressif/arduino-esp32 · GitHub)

Thanks for help in the advance.

how did you wire the pull-up resistors?
where did you plug your EEPROM and RTC?

Please post the code that you are using following the advice in How to get the best out of this forum regarding code tags

The BUS is common for EEPROM and RTC and it is PULL up from 4.7k resistors.

#include <Wire.h>
#define I2C_SDA 40
#define I2C_SCL 41
#define frequency 100000
void setup()
{

Wire.begin(I2C_SDA, I2C_SCL,frequency);
Wire.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}

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

Serial.println("Scanning...");

nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the 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.print(address,HEX);
  Serial.println("  !");

  nDevices++;
}
else if (error==4)
{
  Serial.print("Unknown 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); // wait 5 seconds for next scan
}

How about editing your post with the code and using those code tag thingies?

#include <Wire.h>
#define I2C_SDA 40
#define I2C_SCL 41
#define frequency 100000
void setup()
{

Wire.begin(I2C_SDA, I2C_SCL,frequency);
Wire.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}

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

Serial.println("Scanning...");

nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the 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.print(address,HEX);
  Serial.println("  !");

  nDevices++;
}
else if (error==4)
{
  Serial.print("Unknown 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); // wait 5 seconds for next scan
}

Like that, Give it a try.

Hi @Idahowalker , I didn't understand your reply.

What core version are you using? If you are not using 2.0.0 see this thread about how to install it with the Board Manager.
https://forum.arduino.cc/t/esp32-s2-i2c-problems/863106/9

I am using 2.0.0 only but it is not working though @cattledog

#include <Wire.h>
#define I2C_SDA 40
#define I2C_SCL 41
#define frequency 100000
void setup()
{

Wire.begin(I2C_SDA, I2C_SCL,frequency);
Wire.begin();

The second call to Wire.begin() may over ride the first, and the default settings may be used.

Try with out the second call, and if possible, use only Wire.begin() with the default sda/scl pins for your board.

Make sure you pullup resistors in the sda/scl pins.

@cattledog if u see my code I have already commented wire.begin()...
My board is custom so I can't use default pin.

@cattledog @Idahowalker @UKHeliBob @J-M-L there is still a problem. If you guys can help.

Share all the design info of this custom board

@J-M-L I tink there is no issue with board,I have taken I2C wires from this board and connected to my arduino UNO and I2C scanner is working there. Problem is with wsp32s2. it seems some problem in i2c driver library

This does not determine anything if there is an error on the board.

Can you take the i2c wires from the board and connect them to a separate ESP32S2