MicroPython driver for MPR121 capacitive touch keypads and breakout boards.
Compatible with:
- SparkFun Capacitive Touch Keypad - MPR121 (discontinued)
- MPR121 Capacitive Touch Keypad
- MPR121 Capacitive Touch Breakout Board
These boards use 3.3V logic, so you would want to use a logic level converter with this for 5V systems.
Examples
Copy the file to your device, using ampy, webrepl or compiling and deploying. eg.
Basic usage
from machine import Pin, I2C import mpr121 import time i2c = I2C(scl=Pin(5), sda=Pin(4)) mpr = mpr121.MPR121(i2c, 0x5A) while True: print(mpr.touched()) time.sleep_ms(100)
For more detailed examples, see /examples
Parts
- MPR121 Capacitive Touch Keypad $2.88 AUD
- Female-Female Dupont wires $0.64 AUD
- VCC-GND STM32F407VET6 mini $15.47 AUD
- TinyPICO $20.00 USD
- Wemos D1 Mini $5.20 AUD
Connections
VCC GND STM32F407VET6 Mini
from machine import I2C import mpr121 i2c = I2C(3) mpr = mpr121.MPR121(i2c, 0x5A)
| MPR121 | STM32F407VET6 |
|---|---|
| VCC | 3V3 (or 5V) |
| IRQ | D3 (optional) |
| SCL | A8 (SCL) |
| SDA | C9 (SDA) |
| GND | GND |
- I2C(1) SCL=B6, SDA=B7
- I2C(2) SCL=B10, SDA=B11
- I2C(3) SCL=A8, SDA=C9
TinyPICO (ESP32)
from machine import Pin, I2C import mpr121 i2c = I2C(scl=Pin(22), sda=Pin(21)) mpr = mpr121.MPR121(i2c, 0x5A)
| MPR121 | TinyPICO ESP32 |
|---|---|
| VCC | 3V3 |
| IRQ | GPIO32 (optional) |
| SCL | GPIO22 (SCL) |
| SDA | GPIO21 (SDA) |
| GND | GND |
Wemos D1 Mini (ESP8266)
from machine import Pin, I2C import mpr121 i2c = I2C(scl=Pin(5), sda=Pin(4)) mpr = mpr121.MPR121(i2c, 0x5A)
| MPR121 | D1 Mini ESP8266 |
|---|---|
| VCC | 3V3 |
| IRQ | D3 (optional) |
| SCL | D1 GPIO5 (SCL) |
| SDA | D3 GPIO4 (SDA) |
| GND | GND |
Links
License
Licensed under the MIT License.
Copyright (c) 2018 Mike Causer

