Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Adxl335

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

Code Example

Adxl335 sensor;

public MeadowApp()

    // create the sensor driver
    sensor = new Adxl335(Device, Device.Pins.A00, Device.Pins.A01, Device.Pins.A02, null);

    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => {
        Console.WriteLine($"Accel: [X:{result.New.X.MetersPerSecondSquared:N2}," +
            $"Y:{result.New.Y.MetersPerSecondSquared:N2}," +
            $"Z:{result.New.Z.MetersPerSecondSquared:N2} (m/s^2)]");

    // Example that uses an IObservable subscription to only be notified when the filter is satisfied
    var consumer = Adxl335.CreateObserver(
        handler: result => Console.WriteLine($"Observer: [x] changed by threshold; new [x]: X:{result.New.X:N2}, old: X:{result.Old?.X:N2}"),
        // only notify if there's a greater than 1G change in the Z direction
        filter: result => {
            if (result.Old is { } old) { //c# 8 pattern match syntax. checks for !null and assigns var.
                return ((result.New - old).Z > new Acceleration(1, AU.Gravity));
            return false;

    //==== one-off read

    // start updating

protected async Task ReadConditions()
    var result = await sensor.Read();
    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"Accel: [X:{result.X.MetersPerSecondSquared:N2}," +
        $"Y:{result.Y.MetersPerSecondSquared:N2}," +
        $"Z:{result.Z.MetersPerSecondSquared:N2} (m/s^2)]");

Sample project(s) available on GitHub

Code Sample

public class MeadowApp : App<F7Micro, MeadowApp>
    Adxl335 sensor;

    public MeadowApp()
        sensor = new Adxl335(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


The ADXL335 sensor can be purchased on a breakout board from the following suppliers:

Wiring Example

Characteristic Locus
Inheritance System.Object ObservableBase<Acceleration3D> SensorBase<Acceleration3D> SamplingSensorBase<Acceleration3D> Adxl3xxBase > Adxl335
Implements IAccelerometer
Inherited Members Adxl3xxBase.Acceleration3DUpdated Adxl3xxBase.XAnalogIn Adxl3xxBase.YAnalogIn Adxl3xxBase.ZAnalogIn Adxl3xxBase.SupplyVoltage Adxl3xxBase.GravityRange Adxl3xxBase.Acceleration3D Adxl3xxBase.RaiseEventsAndNotify(IChangeResult<Acceleration3D>) Adxl3xxBase.ReadSensor() Adxl3xxBase.VoltageToGravity(Voltage) SamplingSensorBase<Acceleration3D>.StartUpdating(Nullable<TimeSpan>) SamplingSensorBase<Acceleration3D>.StopUpdating() SensorBase<Acceleration3D>.Updated SensorBase<Acceleration3D>.samplingLock SensorBase<Acceleration3D>.SamplingTokenSource SensorBase<Acceleration3D>.Conditions SensorBase<Acceleration3D>.IsSampling SensorBase<Acceleration3D>.UpdateInterval SensorBase<Acceleration3D>.RaiseEventsAndNotify(IChangeResult<Acceleration3D>) SensorBase<Acceleration3D>.Read() ObservableBase<Acceleration3D>.observers ObservableBase<Acceleration3D>.NotifyObservers(IChangeResult<Acceleration3D>) Meadow.Foundation.ObservableBase<Acceleration3D>.Subscribe(IObserver<>) Meadow.Foundation.ObservableBase<Acceleration3D>.CreateObserver(Action<>, System.Nullable<Predicate<Meadow.IChangeResult<UNIT>>>)
Namespace Meadow.Foundation.Sensors.Motion
Assembly Adxl3xx.dll


public class Adxl335 : Adxl3xxBase, IAccelerometer


Adxl335(IAnalogInputController, IPin, IPin, IPin, Nullable<Voltage>)

Create a new ADXL335 sensor object.

public Adxl335(IAnalogInputController device, IPin xPin, IPin yPin, IPin zPin, Voltage? supplyVoltage)


Type Name Description
IAnalogInputController device

Device that has the analog pins.

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.

System.Nullable<Voltage> supplyVoltage

The voltage supplied to the sensor. Defaults to 3.3V if null.