Remarks

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

The Max44009 is an analog ambient light sensor.

Code Example

Max44009 sensor;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    sensor = new Max44009(Device.CreateI2cBus());

    // Example that uses an IObservable subscription to only be notified when the filter is satisfied
    var consumer = Max44009.CreateObserver(
        handler: result => Resolver.Log.Info($"Observer: filter satisifed: {result.New.Lux:N2}Lux, old: {result.Old?.Lux:N2}Lux"),

        // only notify if the visible light changes by 100 lux (put your hand over the sensor to trigger)
        filter: result => {
            if (result.Old is { } old) { //c# 8 pattern match syntax. checks for !null and assigns var.
                // returns true if > 100lux change
                return (result.New - old).Abs().Lux > 100;
            }
            return false;
        });

    sensor.Subscribe(consumer);

    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => Resolver.Log.Info($"Light: {result.New.Lux:N2}Lux");

    return Task.CompletedTask;
}

public override async Task Run()
{
    var result = await sensor.Read();
    Resolver.Log.Info("Initial Readings:");
    Resolver.Log.Info($" Light: {result.Lux:N2}Lux");

    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

Wiring Example

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

Max44009 Meadow Pin
SCL D08
SDA D07
GND GND
VCC 3V3

It should look like the following diagram:

Characteristic Locus
Inheritance object ObservableBase<Illuminance> SamplingSensorBase<Illuminance> PollingSensorBase<Illuminance> ByteCommsSensorBase<Illuminance> > Max44009
Implements IObservable<IChangeResult<Illuminance>> ISamplingSensor<Illuminance> ISensor<Illuminance> IDisposable II2cPeripheral
Inherited Members ByteCommsSensorBase<Illuminance>.Init(int, int) ByteCommsSensorBase<Illuminance>.Dispose(bool) ByteCommsSensorBase<Illuminance>.Dispose() ByteCommsSensorBase<Illuminance>.BusComms ByteCommsSensorBase<Illuminance>.ReadBuffer ByteCommsSensorBase<Illuminance>.WriteBuffer PollingSensorBase<Illuminance>.StartUpdating(TimeSpan?) PollingSensorBase<Illuminance>.StopUpdating() SamplingSensorBase<Illuminance>.samplingLock SamplingSensorBase<Illuminance>.RaiseEventsAndNotify(IChangeResult<Illuminance>) SamplingSensorBase<Illuminance>.Read() SamplingSensorBase<Illuminance>.SamplingTokenSource SamplingSensorBase<Illuminance>.Conditions SamplingSensorBase<Illuminance>.IsSampling SamplingSensorBase<Illuminance>.UpdateInterval SamplingSensorBase<Illuminance>.Updated ObservableBase<Illuminance>.NotifyObservers(IChangeResult<Illuminance>) ObservableBase<Illuminance>.Subscribe(IObserver<IChangeResult<Illuminance>>) ObservableBase<Illuminance>.CreateObserver(Action<IChangeResult<Illuminance>>, Predicate<IChangeResult<Illuminance>>) ObservableBase<Illuminance>.observers object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Sensors.Light
Assembly Max44009.dll

Syntax

public class Max44009 : ByteCommsSensorBase<Illuminance>, IObservable<IChangeResult<Illuminance>>, ISamplingSensor<Illuminance>, ISensor<Illuminance>, IDisposable, II2cPeripheral

Constructors

Max44009(II2cBus, byte)

Create a new Max44009 object

Declaration
public Max44009(II2cBus i2cBus, byte address = 74)

Parameters

Type Name Description
II2cBus i2cBus

The I2C bus

byte address

The I2C address

Remarks

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

The Max44009 is an analog ambient light sensor.

Code Example

Max44009 sensor;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    sensor = new Max44009(Device.CreateI2cBus());

    // Example that uses an IObservable subscription to only be notified when the filter is satisfied
    var consumer = Max44009.CreateObserver(
        handler: result => Resolver.Log.Info($"Observer: filter satisifed: {result.New.Lux:N2}Lux, old: {result.Old?.Lux:N2}Lux"),

        // only notify if the visible light changes by 100 lux (put your hand over the sensor to trigger)
        filter: result => {
            if (result.Old is { } old) { //c# 8 pattern match syntax. checks for !null and assigns var.
                // returns true if > 100lux change
                return (result.New - old).Abs().Lux > 100;
            }
            return false;
        });

    sensor.Subscribe(consumer);

    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => Resolver.Log.Info($"Light: {result.New.Lux:N2}Lux");

    return Task.CompletedTask;
}

public override async Task Run()
{
    var result = await sensor.Read();
    Resolver.Log.Info("Initial Readings:");
    Resolver.Log.Info($" Light: {result.Lux:N2}Lux");

    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

Wiring Example

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

Max44009 Meadow Pin
SCL D08
SDA D07
GND GND
VCC 3V3

It should look like the following diagram:

Properties

DefaultI2cAddress

The default I2C address for the peripheral

Declaration
public byte DefaultI2cAddress { get; }

Property Value

Type Description
byte

Remarks

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

The Max44009 is an analog ambient light sensor.

Code Example

Max44009 sensor;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    sensor = new Max44009(Device.CreateI2cBus());

    // Example that uses an IObservable subscription to only be notified when the filter is satisfied
    var consumer = Max44009.CreateObserver(
        handler: result => Resolver.Log.Info($"Observer: filter satisifed: {result.New.Lux:N2}Lux, old: {result.Old?.Lux:N2}Lux"),

        // only notify if the visible light changes by 100 lux (put your hand over the sensor to trigger)
        filter: result => {
            if (result.Old is { } old) { //c# 8 pattern match syntax. checks for !null and assigns var.
                // returns true if > 100lux change
                return (result.New - old).Abs().Lux > 100;
            }
            return false;
        });

    sensor.Subscribe(consumer);

    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => Resolver.Log.Info($"Light: {result.New.Lux:N2}Lux");

    return Task.CompletedTask;
}

public override async Task Run()
{
    var result = await sensor.Read();
    Resolver.Log.Info("Initial Readings:");
    Resolver.Log.Info($" Light: {result.Lux:N2}Lux");

    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

Wiring Example

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

Max44009 Meadow Pin
SCL D08
SDA D07
GND GND
VCC 3V3

It should look like the following diagram:

Methods

Initialize()

Initalize the sensor

Declaration
protected void Initialize()

Remarks

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

The Max44009 is an analog ambient light sensor.

Code Example

Max44009 sensor;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    sensor = new Max44009(Device.CreateI2cBus());

    // Example that uses an IObservable subscription to only be notified when the filter is satisfied
    var consumer = Max44009.CreateObserver(
        handler: result => Resolver.Log.Info($"Observer: filter satisifed: {result.New.Lux:N2}Lux, old: {result.Old?.Lux:N2}Lux"),

        // only notify if the visible light changes by 100 lux (put your hand over the sensor to trigger)
        filter: result => {
            if (result.Old is { } old) { //c# 8 pattern match syntax. checks for !null and assigns var.
                // returns true if > 100lux change
                return (result.New - old).Abs().Lux > 100;
            }
            return false;
        });

    sensor.Subscribe(consumer);

    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => Resolver.Log.Info($"Light: {result.New.Lux:N2}Lux");

    return Task.CompletedTask;
}

public override async Task Run()
{
    var result = await sensor.Read();
    Resolver.Log.Info("Initial Readings:");
    Resolver.Log.Info($" Light: {result.Lux:N2}Lux");

    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

Wiring Example

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

Max44009 Meadow Pin
SCL D08
SDA D07
GND GND
VCC 3V3

It should look like the following diagram:

ReadSensor()

Reads data from the sensor

Declaration
protected override Task<Illuminance> ReadSensor()

Returns

Type Description
Task<Illuminance>

The latest sensor reading

Overrides

Remarks

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

The Max44009 is an analog ambient light sensor.

Code Example

Max44009 sensor;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    sensor = new Max44009(Device.CreateI2cBus());

    // Example that uses an IObservable subscription to only be notified when the filter is satisfied
    var consumer = Max44009.CreateObserver(
        handler: result => Resolver.Log.Info($"Observer: filter satisifed: {result.New.Lux:N2}Lux, old: {result.Old?.Lux:N2}Lux"),

        // only notify if the visible light changes by 100 lux (put your hand over the sensor to trigger)
        filter: result => {
            if (result.Old is { } old) { //c# 8 pattern match syntax. checks for !null and assigns var.
                // returns true if > 100lux change
                return (result.New - old).Abs().Lux > 100;
            }
            return false;
        });

    sensor.Subscribe(consumer);

    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => Resolver.Log.Info($"Light: {result.New.Lux:N2}Lux");

    return Task.CompletedTask;
}

public override async Task Run()
{
    var result = await sensor.Read();
    Resolver.Log.Info("Initial Readings:");
    Resolver.Log.Info($" Light: {result.Lux:N2}Lux");

    sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

Wiring Example

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

Max44009 Meadow Pin
SCL D08
SDA D07
GND GND
VCC 3V3

It should look like the following diagram: