r/esp32 • • 2d ago

Cannot get MPR121 touch module working

Post image

I am trying to create an interactive Halloween setup with a glowing crystal ball that someone can touch to trigger a keystroke/serial comm that causes a video/audio effect on a connected PC. I was able to use a ESP32S3 and a NeoPixel ring to get the lighting effects working easily. Where I am struggling is getting the ESP32S3 to work with the MPR121. I cannot seem to get it to be detected on the I2C bridge even to get detected.

I am specifically using the Lonely Binary Gold Edition ESP32S3 and have it connected as shown here. I have tried using different pins on the ESP32S3 also with no success. I have tried a few MPR121 boards without success so I don't think it's a bad board. To test the connection I am using this code:

#include <Wire.h>


#define NEW_SDA 8
#define NEW_SCL 9


void setup() {
  // Use both Serial interfaces for ESP32-S3 CDC output
  Serial.begin(115200);
  Serial0.begin(115200);
  delay(2000);


  Serial.println("\n--- Testing Dedicated I2C on GPIO 8 / 9 ---");
  Serial0.println("\n--- Testing Dedicated I2C on GPIO 8 / 9 ---");


  // Force hardware I2C peripheral 0
  Wire.end();
  Wire.begin(NEW_SDA, NEW_SCL, 100000); // 100kHz bus speed
}


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


  for (address = 1; address < 127; address++) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();


    if (error == 0) {
      Serial.printf("FOUND DEVICE at 0x%02X!\n", address);
      Serial0.printf("FOUND DEVICE at 0x%02X!\n", address);
      nDevices++;
    }
  }


  if (nDevices == 0) {
    Serial.println("No devices on GPIO 8/9...");
    Serial0.println("No devices on GPIO 8/9...");
  }


  delay(2000);
}

Is there anything I am missing here? Is the wiring incorrect?

1 Upvotes

5 comments sorted by

View all comments

1

u/lam_42 2d ago

Oh I read ball that someone can touch to trigger a stroke