🐤 Tutorial 24 - MPR121

The MPR121 is a capacitive touch sensor controller that can detect touch or proximity to up to 12 different electrodes. It can be used to build touch-sensitive buttons, sliders, and other interfaces that don’t require physical buttons or switches.

The MPR121 communicates with a microcontroller using an I2C interface, and provides information about which electrodes have been touched or are in proximity. It also includes a range of features, such as adjustable sensitivity, auto-calibration, and a noise filter, to help improve the accuracy and reliability of touch detection.

One of the key benefits of using the MPR121 capacitive touch sensor is that it can detect touch or proximity through non-conductive materials, such as plastic or glass. This means that touch-sensitive interfaces can be built into a wide range of devices and surfaces, without the need for physical buttons or switches.

The MPR121 is available in a range of package types, including QFN, TQFP, and DFN, making it easy to integrate into a wide range of electronic projects. It can be programmed using a variety of programming languages, including C, C++, and Python.

Overall, the MPR121 capacitive touch sensor is a versatile and widely-used electronic component that provides a simple and effective way to build touch-sensitive interfaces. Its ease of use and compatibility with a wide range of devices make it a popular choice for hobbyists and professionals alike.

Components Needed

ComponentQuantity
Raspberry Pi Pico W1
Micro USB Cable1
Breadboard1
WiresSeveral
MPR121 Module1

Fritzing Diagram

Code

from mpr121 import MPR121
from machine import Pin, I2C
import time

i2c = I2C(1, sda=Pin(6), scl=Pin(7))
mpr = MPR121(i2c)

# check all keys
while True:
    value = mpr.get_all_states()
    if len(value) != 0:
        print(value)
    time.sleep_ms(100)

Code Explanation