Skip to main content

Meadow.Foundation.Grove.Sensors.Motion.3-AxisDigitalAccelerometer16g

3-AxisDigitalAccelerometer16g
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Grove.Sensors.Motion.3-AxisDigitalAccelerometer_16g

Code Example

ThreeAxisDigitalAccelerometer16g sensor;

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

sensor = new ThreeAxisDigitalAccelerometer16g(Device.CreateI2cBus());
sensor.SetPowerState(false, false, true, false, ThreeAxisDigitalAccelerometer16g.Frequencies.TwoHz);

sensor.Updated += (sender, result) =>
{
Resolver.Log.Info($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
$"Y:{result.New.Y.MetersPerSecondSquared:N2}," +
$"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]");
};

return Task.CompletedTask;
}

public override Task Run()
{
sensor.StartUpdating(TimeSpan.FromMilliseconds(500));

return Task.CompletedTask;
}

Sample project(s) available on GitHub