Remarks

ADXL337
Status
Source code GitHub
NuGet package

The ADXL337 is a low power accelerometer capable of measuring +/- 3g of acceleration along three axes. The ADXL337 is controlled via I2C.

Code Example

public class MeadowApp : App<F7Micro, MeadowApp>
{
    Adxl337 sensor;

    public MeadowApp()
    {
        sensor = new Adxl337(Device, Device.Pins.A01, Device.Pins.A02, Device.Pins.A03, 500);

        sensor.AccelerationChanged += Sensor_AccelerationChanged;
    }

    private void Sensor_AccelerationChanged(object sender, Meadow.Foundation.Sensors.SensorVectorEventArgs e)
    {
        Console.WriteLine($"X: {e.CurrentValue.X}, Y: {e.CurrentValue.Y}, Z: {e.CurrentValue.Z}");
    }
}

Sample projects available on GitHub

Wiring Example

Characteristic Locus
Inheritance System.Object > Adxl337
Inherited Members System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Foundation.Sensors.Motion
Assembly Adxl337.dll

Syntax

public class Adxl337

Constructors

Adxl337(IIODevice, IPin, IPin, IPin, UInt16, Double)

Declaration
public Adxl337(IIODevice device, IPin x, IPin y, IPin z, ushort updateInterval = 100, double accelerationChangeNotificationThreshold = 0.10000000149011612)

Parameters

Type Name Description
IIODevice device
IPin x
IPin y
IPin z
System.UInt16 updateInterval
System.Double accelerationChangeNotificationThreshold

Fields

MinimumPollingPeriod

Minimum value that can be used for the update interval when the sensor is being configured to generate interrupts.

Declaration
public const ushort MinimumPollingPeriod = 100

Field Value

Type Description
System.UInt16

Properties

AccelerationChangeNotificationThreshold

Any changes in the acceleration that are greater than the acceleration threshold will cause an event to be raised when the instance is set to update automatically.

Declaration
public double AccelerationChangeNotificationThreshold { get; set; }

Property Value

Type Description
System.Double

SupplyVoltage

Declaration
public double SupplyVoltage { get; set; }

Property Value

Type Description
System.Double

X

Acceleration along the X-axis.

Declaration
public double X { get; }

Property Value

Type Description
System.Double

Remarks

This property will only contain valid data after a call to Read or after an interrupt has been generated.

XVoltsPerG

Volts per G for the X axis.

Declaration
public double XVoltsPerG { get; set; }

Property Value

Type Description
System.Double

Y

Acceleration along the Y-axis.

Declaration
public double Y { get; }

Property Value

Type Description
System.Double

Remarks

This property will only contain valid data after a call to Read or after an interrupt has been generated.

YVoltsPerG

Volts per G for the X axis.

Declaration
public double YVoltsPerG { get; set; }

Property Value

Type Description
System.Double

Z

Acceleration along the Z-axis.

Declaration
public double Z { get; }

Property Value

Type Description
System.Double

Remarks

This property will only contain valid data after a call to Read or after an interrupt has been generated.

ZVoltsPerG

Volts per G for the X axis.

Declaration
public double ZVoltsPerG { get; set; }

Property Value

Type Description
System.Double

Methods

GetRawSensorData()

Get the raw analog input values from the sensor.

Declaration
public Task<Vector> GetRawSensorData()

Returns

Type Description
System.Threading.Tasks.Task<Vector>

Vector object containing the raw sensor data from the analog pins.

Update()

Read the sensor output and convert the sensor readings into acceleration values.

Declaration
public Task Update()

Returns

Type Description
System.Threading.Tasks.Task

Events

AccelerationChanged

Event to be raised when the acceleration is greater than +/- AccelerationChangeNotificationThreshold.

Declaration
public event SensorVectorEventHandler AccelerationChanged

Event Type

Type Description
SensorVectorEventHandler