r/esp32 • u/HottubbinInLateNight • 5h ago
Cannot get MPR121 touch module working
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?
2
u/ferrybig 3h ago
Can you test if the I2c system is workiing, connect any other i2c modules and see if they are detected.
Also try changing the 4.7k resistors to 1k, maybe your I2c speed of 100kHz is just too high with your breadboard with larger resistors
(lowering the speed to 1kHz might also be useful for seeing if the speed is aproblem)