MPR121 capacitive touch sensor (12 keys) with ESP32

Supply 3.3 V Bus I2C I2C address 0x5A / 0x5B / 0x5C / 0x5D
VCCGNDSCLSDAIRQADDE0E1E2E3E4E5E6E7E8E9E10E11

Pins and ESP32 wiring

PinRoleESP32 pinNotes
VCCPower3V33.3 V (the chip must not get 5 V unless the board has a regulator)
GNDGroundGND
SCLI2C clock (SCL)D22
SDAI2C data (SDA)D21
IRQInterruptD35LOW when a touch changes
ADDNot wired to the ESP32—Address: GND 0x5A, VCC 0x5B, SDA 0x5C, SCL 0x5D
E0Not wired to the ESP32—Electrode 0: to a touch pad, foil or fruit
E1Not wired to the ESP32—
E2Not wired to the ESP32—
E3Not wired to the ESP32—
E4Not wired to the ESP32—
E5Not wired to the ESP32—
E6Not wired to the ESP32—
E7Not wired to the ESP32—
E8Not wired to the ESP32—
E9Not wired to the ESP32—
E10Not wired to the ESP32—
E11Not 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

Try it in 3D in BoardPilot

BoardPilot Part data (JSON)

Related parts

Part data: CC BY 4.0, free to reuse with credit to BoardPilot.