Remarks

Ags01Db
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Environmental.Ags01Db

The AGS01DB is a MEMS VOC gas sensor that commuincates over I2C.

Supply voltage(V) 3.3~5.5 Supply current(mA) <30 Measuring range(ppm) 0~100 Operating range (°C) 0~50 Operating range (% RH) 0~95 Interface I²C Size:LWH (mm) 23.312.55.8

Code Example

Ags01Db ags10Db;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize ...");
    ags10Db = new Ags01Db(Device.CreateI2cBus());

    Resolver.Log.Info($"Version: v{ags10Db.GetVersion()}");

    var consumer = Ags01Db.CreateObserver(
        handler: result =>
        {
            Resolver.Log.Info($"Concentration New Value {result.New.PartsPerMillion}ppm");
            Resolver.Log.Info($"Concentration Old Value {result.Old?.PartsPerMillion}ppm");
        },
        filter: null
    );
    ags10Db.Subscribe(consumer);

    ags10Db.ConcentrationUpdated += (object sender, IChangeResult<Meadow.Units.Concentration> e) =>
    {
        Resolver.Log.Info($"Concentration Updated: {e.New.PartsPerMillion:N2}ppm");
    };

    return Task.CompletedTask;
}

public override Task Run()
{
    ags10Db.StartUpdating(TimeSpan.FromSeconds(1));

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a Ags01Db to your Meadow board, connect the following:

Ags01Db Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3

It should look like the following diagram:

Characteristic Locus
Inheritance System.Object ObservableBase<Concentration> SamplingSensorBase<Concentration> PollingSensorBase<Concentration> ByteCommsSensorBase<Concentration> > Ags01Db
Implements ISamplingSensor<Concentration> ISamplingSensor<Concentration> IDisposable
Inherited Members ByteCommsSensorBase<Concentration>.Peripheral ByteCommsSensorBase<Concentration>.ReadBuffer ByteCommsSensorBase<Concentration>.WriteBuffer ByteCommsSensorBase<Concentration>.Init(Int32, Int32) ByteCommsSensorBase<Concentration>.Dispose(Boolean) ByteCommsSensorBase<Concentration>.Dispose() PollingSensorBase<Concentration>.StartUpdating(Nullable<TimeSpan>) PollingSensorBase<Concentration>.StopUpdating() SamplingSensorBase<Concentration>.samplingLock SamplingSensorBase<Concentration>.Updated SamplingSensorBase<Concentration>.SamplingTokenSource SamplingSensorBase<Concentration>.Conditions SamplingSensorBase<Concentration>.IsSampling SamplingSensorBase<Concentration>.UpdateInterval SamplingSensorBase<Concentration>.RaiseEventsAndNotify(IChangeResult<>) SamplingSensorBase<Concentration>.Read() ObservableBase<Concentration>.observers ObservableBase<Concentration>.NotifyObservers(IChangeResult<>) Meadow.Foundation.ObservableBase<Concentration>.Subscribe(IObserver<>) Meadow.Foundation.ObservableBase<Concentration>.CreateObserver(Action<>, System.Nullable<Predicate<IChangeResult<UNIT>>>)
Namespace Meadow.Foundation.Sensors.Environmental
Assembly Ags01Db.dll

Syntax

public class Ags01Db : ByteCommsSensorBase<Concentration>, ISamplingSensor<Concentration>, ISamplingSensor<Concentration>, IDisposable

Constructors

Ags01Db(II2cBus, Byte)

Create a new Ags01Db object

Declaration
public Ags01Db(II2cBus i2cBus, byte address = null)

Parameters

Type Name Description
II2cBus i2cBus

The I2C bus

System.Byte address

The I2C address

Properties

Concentration

The current concentration value

Declaration
public Concentration? Concentration { get; }

Property Value

Type Description
System.Nullable<Concentration>

Methods

GetVersion()

Get ASG01DB Version

Declaration
public byte GetVersion()

Returns

Type Description
System.Byte

Version

RaiseChangedAndNotify(IChangeResult<Concentration>)

Raise change events for subscribers

Declaration
protected void RaiseChangedAndNotify(IChangeResult<Concentration> changeResult)

Parameters

Type Name Description
IChangeResult<Concentration> changeResult

The change result with the current sensor data

ReadSensor()

Get ASG01DB VOC Gas Concentration and Update the Concentration property.

Declaration
protected override Task<Units.Concentration> ReadSensor()

Returns

Type Description
Task<Units.Concentration>

Overrides

Meadow.Foundation.SamplingSensorBase<Concentration>.ReadSensor()

Events

ConcentrationUpdated

Raised when the concentration changes

Declaration
public event EventHandler<IChangeResult<Concentration>> ConcentrationUpdated

Event Type

Type Description
EventHandler<IChangeResult<Concentration>>