ESP32 Using Wire.end but cannot use pins

I am using a Touchscreen and use I2C with an esp32 to read the point that I am touching.
Additionally, I am controlling four, four wire motors. I need Pin 26,27 for a Motor and I need it also for I2C to communicate with the touchscreen as it is hard wired in. Each works separately perfectly, but when I try and end the Wire and move the motor nothing happens and no error is thrown.

Motor is custom class that uses ledc and works when the motor code is above the Wire setup code.

Is there a Register I can reset ? Like how AVR boards have TWCR?

  Motor m1 = Motor(26, 27, 1);

  Wire.begin(26, 27);
  Serial.println("Wire Begin");

  int XL = 0;
  int XH = 0;
  int YL = 0;
  int YH = 0;

  int data = 0;
  Wire.beginTransmission(TOUCH_I2C_ADD);
  Wire.write(TOUCH_REG_XH);
  Wire.endTransmission();
  Wire.requestFrom(TOUCH_I2C_ADD, 1);

  if (Wire.available())
  {
    data = Wire.read();
  }
  XH = data;
  Wire.end();
  Serial.println("Wire End");

  m1.Move(100, HIGH);
  delay(1000);
  m1.Move(0, HIGH);
  delay(1000);

How that? Then the motor will react on I2C transmissions as well, and the display will react on and interfere with the motor signals. Not a sane idea :frowning:

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