# MPR121, problems with I2C

**URL:** <https://forum.arduino.cc/t/mpr121-problems-with-i2c/992770>\
**Category:** 3rd Party Boards\
**Created:** [May 17, 2022, 4:33pm UTC](https://forum.arduino.cc/t/mpr121-problems-with-i2c/992770 "2022-05-17T16:33:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![klenges](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@klenges](https://forum.arduino.cc/u/klenges)\
**Post date:** [May 17, 2022, 4:33pm UTC](https://forum.arduino.cc/t/mpr121-problems-with-i2c/992770/1 "2022-05-17T16:33:36Z")

</div>

Hello,

I am using the MPR121 to measure some capacitances. Everything worked fine, but today the MPR121 wont connect anymore. When running the code below it outputs that the MPR121 isnt connected (error inside MPR1.begin()).

I already scanned the device with a I2C Scanner an there it is found. Any suggestions whats the problem?

[table][tr][td][size=14pt][sub]Code:[/sub][/size][hr][/td][/tr][tr][td][size=9pt][tt]#include \<Wire.h\>  
#include "Adafruit\_MPR121.h"

Adafruit\_MPR121 MPR1 = Adafruit\_MPR121color=#000000[/color];

int a,b,c,d,e,f; // gemessene Kapazität  
int Ix; // Variable für den Messstrom  
int Tx; // Variable für die Messzeit  
bool cap = false; // cap auf true für Kapazitätswert, cap auf false für ADC-Wert

void setupcolor=#000000[/color] {  
// Verbindung zum PC  
Serial.begincolor=#000000[/color];  
while color=#000000[/color]{  
delaycolor=#000000[/color];  
}  
Wire.begincolor=#000000[/color];  
// Test ob Verbindung zum MPR hergestellt werden konnte.  
// Falls nicht Kabel SCL und SDA nochmal raus und rein stecken.

[//Serial.println](https://Serial.println)("Adafruit MPR121 Capacitive Touch sensor test");   
// Default address is 0x5A, if tied to 3.3V its 0x5B  
// If tied to SDA its 0x5C and if SCL then 0x5D  
if color=#000000[/color] {  
Serial.println("MPR1 not found, check wiring?");  
while color=#000000[/color];  
}  
}

void loopcolor=#000000[/color] {

if color=#000000[/color]{  
Ix = MPR1.readRegister8color=#000000[/color];  
Tx = MPR1.readRegister8color=#000000[/color]\>\>4;  
a = (Ix\*pow(2, Tx-2)\*1024) / (MPR1.filteredDatacolor=#000000[/color]\* 3.3);  
}  
else {  
a = MPR1.filteredDatacolor=#000000[/color];  
b = MPR1.filteredDatacolor=#000000[/color];  
c = MPR1.filteredDatacolor=#000000[/color];  
d = MPR1.filteredDatacolor=#000000[/color];  
e = MPR1.filteredDatacolor=#000000[/color];  
f = MPR1.filteredDatacolor=#000000[/color];  
}  
Serial.printlncolor=#000000[/color];  
Serial.printlncolor=#000000[/color];  
Serial.printlncolor=#000000[/color];  
Serial.printlncolor=#000000[/color];  
Serial.printlncolor=#000000[/color];  
Serial.printlncolor=#000000[/color];  
Serial.printlncolor=#000000[/color];  
}[/tt][/size][/td][/tr][/table]

---

<div class="post-metadata">

**Author:** ![pylon](https://avatars.discourse-cdn.com/v4/letter/p/59ef9b/32.png) [@pylon](https://forum.arduino.cc/u/pylon)\
**Post date:** [May 18, 2022, 7:22am UTC](https://forum.arduino.cc/t/mpr121-problems-with-i2c/992770/2 "2022-05-18T07:22:01Z")

</div>

There might be many reasons for this. The Adafruit code resets the device and then read the CONFIG2 register which should hold the default values. There might be a way to change the content of that register constantly or your wiring is not good enough to transfer values reliably.  
Unfortunately your code is mangled somehow by the forum system or you did a copy/paste mistake but it's unreadable.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [November 14, 2022, 7:22am UTC](https://forum.arduino.cc/t/mpr121-problems-with-i2c/992770/3 "2022-11-14T07:22:38Z")

</div>

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