Skip to main content

Meadow.Foundation.Sensors.Hid.Mpr121

Mpr121
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Hid.Mpr121

Code Example

public override Task Initialize()
{
Resolver.Log.Info("Initialize...");

var sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged;

return Task.CompletedTask;
}

private void Sensor_ChannelStatusesChanged(object sender, ChannelStatusChangedEventArgs e)
{
string pads = string.Empty;

for (int i = 0; i < e.ChannelStatus.Count; i++)
{
if (e.ChannelStatus[(Mpr121.Channels)i] == true)
{
pads += i + ", ";
}
}

var msg = string.IsNullOrEmpty(pads) ? "none" : (pads + "touched");
Resolver.Log.Info(msg);
}

Sample project(s) available on GitHub

Wiring Example

To wire a Mpr121 to your Meadow board, connect the following:

Mpr121Meadow Pin
GNDGND
SCLD08 (SCL)
SDAD07 (SDA)
VCC3V3

It should look like the following diagram: