ESP32S3 I2C not working

I have an ESP32S3 that I want to use INA226 but with the code below ,but it's not detecting anything on the I2C, Now if I upload the exact same code to an ESP32 it shows that the INA226 is connected with the address of 0x51.
I have pull up resistors connect the SDA,SCL lines and I have also tried another 2 ESP32S3 and they do the same by not detecting anything

#include "Wire.h"
//#include <Wire.h>
#define I2C_SDA 4
#define I2C_SCL 5
void setup() {
  Serial.begin(115200);
  Wire.setPins(I2C_SDA,I2C_SCL);
  Wire.begin(I2C_SDA, I2C_SCL);
}

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 device2 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");
   }
}

I've tried a few way but no joy
Thanks

Have you checked your ESP32S3 data sheet or schematic to verify that your SCL and SDA pins are specified correctly?

Don

running the following program in an ESP32-S3-DevKitC-1

#include <Wire.h>
#include <i2cdetect.h>

#define I2C_SDA 4
#define I2C_SCL 5

void setup() {
  Wire.begin(I2C_SDA, I2C_SCL);
  //Wire.begin();
  Serial.begin(115200);
  Serial.println("i2cdetect example\n");
  Serial.print("Scanning address range 0x03-0x77\n\n");
  
}

void loop() {
  i2cdetect();
  delay(2000);
}

it displays

14:56:18.243 ->      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
14:56:18.243 -> 00:          -- -- -- -- -- -- -- -- -- -- -- -- --
14:56:18.275 -> 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
14:56:18.275 -> 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
14:56:18.275 -> 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
14:56:18.275 -> 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
14:56:18.275 -> 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
14:56:18.275 -> 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
14:56:18.275 -> 70: -- -- -- -- -- -- 76 --

detecting a Pololu TOF sensor on address 0x76

if I run your program of post 1 I get

14:58:47.080 -> Scanning for I2C devices ...
14:58:47.080 -> I2C device2 found at address 0x76
1 Like

Why make it hard if you can make it easy.
Start with simple basic code that everyone uses.

// Forum: https://forum.arduino.cc/t/esp32s3-i2c-not-working/1244885
// This Wokwi project: https://wokwi.com/projects/394517050165987329

#include <Wire.h>

void setup() 
{
  Serial.begin(115200);
  Wire.begin();  // default SDA = 8, SCL = 9
}

void loop() 
{
  Serial.print("Scan: ");
 
  for(int address = 1; address < 128; address++)
  {
    Wire.beginTransmission(address);
    int error = Wire.endTransmission();
    if (error == 0)
    {
      Serial.printf("0x%02X ", address);
    }
  }
  Serial.println();

  delay(2000);
}

Try it in Wokwi simulation:

Thanks guy's from your comments I have now got it working, I stupidly connected the SCL to a wrong pin on the eps32s3, I connected it to D6 the last port instead of D5(GPI06) but I thought I'd double checked that and had each SP32S3 on separate bread boards guess the more you look the more confused I got and got myself lost in thinking it was working when I used it my ready made PCB (which I left at work)

Thanks Koepel I've not seen or heard of that

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.