adafruit_mpr121

CircuitPython driver for the MPR121 capacitive touch breakout board.

See usage in the examples/simpletest.py file.

  • Author(s): Tony DiCola

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_mpr121.MPR121(i2c: I2C, address: int = 90)[source]

Driver for the MPR121 capacitive touch breakout board.

baseline_data(pin: int) int[source]

Get the baseline data register value.

Parameters:

pin (int) – The pin to read (0 - 11).

Raises:

ValueError – Argument pin is invalid.

Returns:

The baseline data value stored in the register.

Return type:

int

filtered_data(pin: int) int[source]

Get the filtered data register value.

Parameters:

pin (int) – The pin to read (0 - 11).

Raises:

ValueError – Argument pin is invalid.

Returns:

The filtered data value stored in the register.

Return type:

int

is_touched(pin: int) bool[source]

Get if pin is being touched.

Raises:

ValueError – Argument pin is invalid.

Returns:

True if pin is being touched; otherwise False.

Return type:

bool

reset() None[source]

Reset the MPR121 into a default state.

All configurations and states previously set are lost.

Raises:

RuntimeError – The sensor is in an invalid config state.

touched() int[source]

Get the touch state of all pins as a 12-bit value.

Returns:

A 12-bit value representing the touch state of each pin. Each state in the value is represented by either a 1 or 0; touched or not.

Return type:

int

property touched_pins: Tuple[bool]

Get a tuple of the touched state for all pins.

class adafruit_mpr121.MPR121_Channel(mpr121: MPR121, channel: int)[source]

Represents a single channel on the touch sensor.

Not meant to be used directly.

property raw_value: int

Get the raw touch measurement.

property release_threshold: int

Get or set the release threshold.

property threshold: int

Get or set the touch threshold.

property value: bool

Get whether the touch pad is being touched or not.