Home

Awesome

MicroPython MPR121

MicroPython driver for MPR121 capacitive touch keypads and breakout boards.

demo

demo

Compatible with:

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.

$ ampy put mpr121.py

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

Connections

VCC GND STM32F407VET6 Mini

from machine import I2C
import mpr121
i2c = I2C(3)
mpr = mpr121.MPR121(i2c, 0x5A)
MPR121STM32F407VET6
VCC3V3 (or 5V)
IRQD3 (optional)
SCLA8 (SCL)
SDAC9 (SDA)
GNDGND

TinyPICO (ESP32)

from machine import Pin, I2C
import mpr121
i2c = I2C(scl=Pin(22), sda=Pin(21))
mpr = mpr121.MPR121(i2c, 0x5A)
MPR121TinyPICO ESP32
VCC3V3
IRQGPIO32 (optional)
SCLGPIO22 (SCL)
SDAGPIO21 (SDA)
GNDGND

Wemos D1 Mini (ESP8266)

from machine import Pin, I2C
import mpr121
i2c = I2C(scl=Pin(5), sda=Pin(4))
mpr = mpr121.MPR121(i2c, 0x5A)
MPR121D1 Mini ESP8266
VCC3V3
IRQD3 (optional)
SCLD1 GPIO5 (SCL)
SDAD3 GPIO4 (SDA)
GNDGND

Links

License

Licensed under the MIT License.

Copyright (c) 2018 Mike Causer