MPR121 capacitive touch sensor (12 keys) with ESP32
Supply 3.3 V
Bus I2C
I2C address
0x5A / 0x5B / 0x5C / 0x5D
Pins and ESP32 wiring
| Pin | Role | ESP32 pin | Notes |
|---|---|---|---|
| VCC | Power | 3V3 | 3.3 V (the chip must not get 5 V unless the board has a regulator) |
| GND | Ground | GND | |
| SCL | I2C clock (SCL) | D22 | |
| SDA | I2C data (SDA) | D21 | |
| IRQ | Interrupt | D35 | LOW when a touch changes |
| ADD | Not wired to the ESP32 | — | Address: GND 0x5A, VCC 0x5B, SDA 0x5C, SCL 0x5D |
| E0 | Not wired to the ESP32 | — | Electrode 0: to a touch pad, foil or fruit |
| E1 | Not wired to the ESP32 | — | |
| E2 | Not wired to the ESP32 | — | |
| E3 | Not wired to the ESP32 | — | |
| E4 | Not wired to the ESP32 | — | |
| E5 | Not wired to the ESP32 | — | |
| E6 | Not wired to the ESP32 | — | |
| E7 | Not wired to the ESP32 | — | |
| E8 | Not wired to the ESP32 | — | |
| E9 | Not wired to the ESP32 | — | |
| E10 | Not wired to the ESP32 | — | |
| E11 | Not wired to the ESP32 | — |
Suggested wiring for the 30-pin ESP32 DevKit, avoiding flash, input-only and strapping pins. BoardPilot checks it for you as you wire.
Starter code (Arduino)
#include <Wire.h>
void setup() {
Serial.begin(115200);
Wire.begin(21, 22); // SDA = GPIO 21, SCL = GPIO 22
Wire.beginTransmission(0x5A);
bool found = Wire.endTransmission() == 0;
Serial.println(found ? "MPR121 capacitive touch sensor (12 keys) found at 0x5A" : "Not found: check power, GND and SDA/SCL");
}
void loop() {}
Sources
- NXP MPR121 datasheet, ADDR pin selects 0x5A to 0x5D; supply 1.71 to 3.6 V
- Common MPR121 breakouts, Header order differs (Adafruit, CJMCU, SparkFun): check the silkscreen
Try it in 3D in BoardPilot
Related parts
Part data: CC BY 4.0, free to reuse with credit to BoardPilot.