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
Implements IAccelerometer
Namespace Meadow.Foundation.Sensors.Motion
Assembly Adxl337.dll

Syntax

public class Adxl337 : FilterableChangeObservableBase<AccelerationConditionChangeResult, AccelerationConditions>, IAccelerometer

Constructors

Adxl337(IIODevice, IPin, IPin, IPin)

Create a new ADXL337 sensor object.

Declaration
public Adxl337(IIODevice device, IPin xPin, IPin yPin, IPin zPin)

Parameters

Type Name Description
IIODevice device
IPin xPin

Analog pin connected to the X axis output from the ADXL337 sensor.

IPin yPin

Analog pin connected to the Y axis output from the ADXL337 sensor.

IPin zPin

Analog pin connected to the Z axis output from the ADXL337 sensor.

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

Conditions

Declaration
public AccelerationConditions Conditions { get; protected set; }

Property Value

Type Description
AccelerationConditions

IsSampling

Gets a value indicating whether the analog input port is currently sampling the ADC. Call StartSampling() to spin up the sampling process.

Declaration
public bool IsSampling { get; protected set; }

Property Value

Type Description
System.Boolean

true if sampling; otherwise, false.

SupplyVoltage

Power supply voltage applied to the sensor. This will be set (in the constructor) to 3.3V by default.

Declaration
public float SupplyVoltage { get; set; }

Property Value

Type Description
System.Single

XAcceleration

Acceleration along the X-axis.

Declaration
public float XAcceleration { get; }

Property Value

Type Description
System.Single

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 float XVoltsPerG { get; set; }

Property Value

Type Description
System.Single

YAcceleration

Acceleration along the Y-axis.

Declaration
public float YAcceleration { get; }

Property Value

Type Description
System.Single

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 float YVoltsPerG { get; set; }

Property Value

Type Description
System.Single

ZAcceleration

Acceleration along the Z-axis.

Declaration
public float ZAcceleration { get; }

Property Value

Type Description
System.Single

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 float ZVoltsPerG { get; set; }

Property Value

Type Description
System.Single

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.

RaiseChangedAndNotify(AccelerationConditionChangeResult)

Declaration
protected void RaiseChangedAndNotify(AccelerationConditionChangeResult changeResult)

Parameters

Type Name Description
AccelerationConditionChangeResult changeResult

Read()

Declaration
public Task<AccelerationConditions> Read()

Returns

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

StartUpdating(Int32)

Declaration
public void StartUpdating(int standbyDuration = 1000)

Parameters

Type Name Description
System.Int32 standbyDuration

StopUpdating()

Declaration
public void StopUpdating()

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

Updated

Declaration
public event EventHandler<AccelerationConditionChangeResult> Updated

Event Type

Type Description
System.EventHandler<AccelerationConditionChangeResult>