ESP32 won't find I2C device

Hello all -- Yet another I2C issue I'm hoping someone could provide some me some guidance on.

I'm using an esp32-wroom-32D devboard & I have a 2.8" TFT SPI Display (MFG Model is MSP2834) that uses I2C for the capacitive touch (driver IC: FT6336G) and SPI for the display (driver IC: ILI9341). I cannot get the esp to find the I2C seemingly no matter what I do.

It WILL find other devices such as the OLED SSD1306. I tried a few 2.8" displays thinking it could be a hardware issue, still no dice.

I have tried:

  • 4.7k & 10k pull up resistors
  • defining different SDA & SCL pins
  • Looking through the Wire.h library to make sure there was not anything overriding my definitions in my sketch
  • I used the FPC connector on the display with an FPC breakout board just incase there was something wrong with the header pins

Here are photos of my set up, a diagram of the wiring (im sorry in advanced if the wiring diagram is crap but I tried). & also an except from the data sheet of the display regarding the I2C.

Any suggestions from the community would be greatly appreciated & look forward to a discussion.

& Here is the code I am using to find the I2C address / confirm the communication:

#include <Wire.h>

// Define the SDA and SCL pins for your ESP32
#define SDA_PIN 21  // Change to your board's SDA pin
#define SCL_PIN 22  // Change to your board's SCL pin

void setup() {
  Serial.begin(115200);                // Start serial communication
  Wire.begin(SDA_PIN, SCL_PIN);        // Initialize I2C with custom SDA and SCL pins
  Serial.println("\nI2C Address Finder");
  Serial.println("=====================");
}

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

  Serial.println("Scanning for I2C devices...");

  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.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("Scan complete.\n");
  }

  delay(5000); // Wait 5 seconds before the next scan
}

If that schematic is how you have it wired, its not going to work.

You have the SDA and SCL GPIO pins connected direct to 3V3.

I may have screwed up the schematic, can you see from my photo with the breadboard how I have it connected & if that is correct?

Is this a case of mirror image? Do whatever you need to do to make sure the sensor pins are connected to the right MCU pins. It took me a few hours to get my head wrapped around that. I eventually desoldered the pins and reversed them so I could see the labels.

If it's SPI, why you try to find I2C?
Did I miss something?
You could post a link to your device you are troubleshooting here.

Yes.

1 Like

So the display driver is SPI but the touch screen driver is I2C. I dont have any issues with the display via SPI, just cannot get the touch working / communicating.

Here is where the display was purchased I've seen a bunch of inaccuracies on product descriptions and photos though so here are screenshots of the MFGs data sheet


I thought so...

It's been a couple of years since, but I was trying to accomplish this very thing and never got it going. The display would work till I incorporated the touchscreen and then - it cratered.

:cold_sweat: I'm unsure if this makes me feel better or worse now. haha I wonder if it is a hardware issue or something then. It should be simple to poll the i2c address and its been driving me nuts the last few days trying to get it to work. I just remembered I even used an i2c multiplexer just to see if somehow that would work -- I would get the address of the multiplexer board but still nothing for the display.

From the pic, that much, the pull-upping, looks right.

1 Like

Thanks, I would have thrown sand in my eyes if it was a resistor this whole time.
The struggle continues..

#include <Wire.h>

// Define the SDA and SCL pins for your ESP32
#define SDA_PIN 21  // Change to your board's SDA pin
#define SCL_PIN 22  // Change to your board's SCL pin
#define RST_PIN 19

void setup() {
  Serial.begin(115200);  // Start serial communication
  // RESET I2C
  pinMode(RST_PIN, OUTPUT);
  digitalWrite(RST_PIN, LOW);
  delay(100);
  digitalWrite(RST_PIN, HIGH);

  Wire.begin(SDA_PIN, SCL_PIN);  // Initialize I2C with custom SDA and SCL pins
  Serial.println("\nI2C Address Finder");
  Serial.println("=====================");
}

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

  Serial.println("Scanning for I2C devices...");

  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.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("Scan complete.\n");
  }

  delay(5000);  // Wait 5 seconds before the next scan
}

Sorry, did I miss something? Is there something wrong with the sketch?

ADD RESET I2C )))

Okay so a combination of two things got this to work.

  • I first updated the sketch and I still wasnt able to communicate.
  • I removed & reseated the small FPC cable

    and now I am able to communicate! (address 0x38 fwiw)
  • I reverted back to my original code without the reset that @ua6em shared with me and it did not work.

So a combination of the updated code along with re seating the touch fpc connector got it to work.

y'all are great. thank you

1 Like

The INT signal must also be used!
Note that the problem has been solved!!!

I did note that you solved it. thank you much for your help.

Question with the INT signal, I'm not using it right now but it seems to be communicating since I'm getting the address in the serial monitor? Could you explain a bit more if you wouldnt mind?

When the sensor sees a touch, it generates a signal, sets it to the INT pin, you should periodically read this pin and as soon as you receive this signal, you need to process it, it is easier to find a library. All this is already implemented there.

2 Likes

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