ChrisM
ChrisM

Reputation: 11

SCL Stuck Low and I2C Timeout Issue with ESP32 and ZTW523A

I’m working on interfacing a ZTW523A touch controller with an ESP32 via I2C, but I’m facing issues with I2C timeouts (Wire.h error 5: timeout) and I am unable to detect the device using an I2C scanner. Despite following the recommended setup and adding pull-up resistors, the bus doesn’t seem to communicate with the touch controller.

#include <Wire.h>
#include <Arduino.h>
#include <I2CScanner.h>

#define RESET_PIN D7
#define SCL_PIN D5 // ESP32 GPIO connected to Reset (pin 24)

I2CScanner scanner;

void resetTouchPanel()
{
  pinMode(RESET_PIN, OUTPUT);
  digitalWrite(RESET_PIN, LOW); // Pull Reset low
  delay(5);                      // Hold for 5ms
  digitalWrite(RESET_PIN, HIGH); // Release Reset

  delay(1000); // Wait for initialization
  Serial.println("Touch panel reset complete.");
}

void resetI2CBus()
{
  pinMode(SCL_PIN, OUTPUT);
  for (int i = 0; i < 9; i++)
  { // Generate clock pulses
    digitalWrite(SCL_PIN, HIGH);
    delayMicroseconds(10);
    digitalWrite(SCL_PIN, LOW);
    delayMicroseconds(10);
  }
  pinMode(SCL_PIN, INPUT); // Restore SCL to input
}
void setup()
{
  Serial.begin(115200);
  delay(100);

  resetTouchPanel();

  Wire.end();

  Wire.begin();
  Wire.setClock(100000);
  delay(100);
  resetI2CBus();
  scanner.Init();
}

void loop()
{
  delay(10);

  resetTouchPanel();
  scanner.Scan();
}

Could this be an issue with the ZTW523A initialization sequence or reset behavior? Is there a specific I2C address or configuration I might be missing? Are there additional debugging techniques (e.g. logic analyzer) I should try?

Can someone help me debug this issue? Thank you so much!

Upvotes: 1

Views: 77

Answers (0)

Related Questions