Remarks

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

The TEMT6000 is an I2C ambient light sensor.

Code Example

Veml7700 sensor;

public override Task Initialize()
{
    Console.WriteLine("Initialize...");

    sensor = new Veml7700(Device.CreateI2cBus());
    sensor.DataSource = Veml7700.SensorTypes.Ambient;

    sensor.RangeExceededHigh += (s, a) => Console.WriteLine("Too bright to measure");
    sensor.RangeExceededLow += (s, a) => Console.WriteLine("Too dim to measure");

    // classical .NET events can also be used:
    sensor.Updated += (sender, result) => Console.WriteLine($"Illuminance: {result.New.Lux:n3}Lux");

    return Task.CompletedTask;
}

public override async Task Run()
{
    var conditions = await sensor.Read();

    Console.WriteLine("Initial Readings:");
    Console.WriteLine($"  Illuminance: {conditions.Lux:n3}Lux");

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

Sample project(s) available on GitHub

Wiring Example

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

Veml7700 Meadow Pin
3V3 3V3
GND GND
SCK D08
SDA D07

It should look like the following diagram:

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

Syntax

public class Veml7700 : ByteCommsSensorBase<Illuminance>, ISamplingSensor<Illuminance>, IDisposable, ILightSensor, IDisposable

Constructors

Veml7700(II2cBus)

Create a new Veml7700 object with the default address

Declaration
public Veml7700(II2cBus i2cBus)

Parameters

Type Name Description
II2cBus i2cBus

The I2C bus

Properties

DataSource

Sensor types Data source

Declaration
public Veml7700.SensorTypes DataSource { get; set; }

Property Value

Type Description
Veml7700.SensorTypes

Illuminance

Luminosity reading from the TSL2561 sensor.

Declaration
public Illuminance? Illuminance { get; protected set; }

Property Value

Type Description
System.Nullable<Illuminance>

Methods

RaiseEventsAndNotify(IChangeResult<Illuminance>)

Raise events for subcribers and notify of value changes

Declaration
protected override void RaiseEventsAndNotify(IChangeResult<Illuminance> changeResult)

Parameters

Type Name Description
IChangeResult<Illuminance> changeResult

The updated sensor data

ReadSensor()

Reads data from the sensor

Declaration
protected override Task<Illuminance> ReadSensor()

Returns

Type Description
Task<Illuminance>

The latest sensor reading

Overrides

Meadow.Foundation.SensorBase<Illuminance>.ReadSensor()

Events

LuminosityUpdated

Raised when the luminosity value changes

Declaration
public event EventHandler<IChangeResult<Illuminance>> LuminosityUpdated

Event Type

Type Description
EventHandler<IChangeResult<Illuminance>>

RangeExceededHigh

Raised when the high range is exceeded

Declaration
public event EventHandler RangeExceededHigh

Event Type

Type Description
EventHandler

RangeExceededLow

Raised when the low range is exceeded

Declaration
public event EventHandler RangeExceededLow

Event Type

Type Description
EventHandler