Remarks

ADXL337
Status
Source code GitHub
NuGet package

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

Code Example

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

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

        sensor.AccelerationChanged += Sensor_AccelerationChanged;
    }

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

Syntax

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

Constructors

Adxl377(IIODevice, IPin, IPin, IPin)

Create a new ADXL337 sensor object.

Declaration
public Adxl377(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 ADXL335 sensor.

IPin yPin

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

IPin zPin

Analog pin connected to the Z axis output from the ADXL335 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

AccelerationY

Acceleration along the Y-axis.

Declaration
public float AccelerationY { 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.

AccelerationZ

Acceleration along the Z-axis.

Declaration
public float AccelerationZ { 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.

AccellerationX

Acceleration along the X-axis.

Declaration
public float AccellerationX { 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.

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

XVoltsPerG

Volts per G for the X axis.

Declaration
public float XVoltsPerG { get; set; }

Property Value

Type Description
System.Single

YVoltsPerG

Volts per G for the X axis.

Declaration
public float YVoltsPerG { get; set; }

Property Value

Type Description
System.Single

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>