Remarks

Bh1750
Status
Source code GitHub
NuGet package

The BH1750 is a light intensity sensor that communicates over I2C.

Code Example

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

    public MeadowApp()
    {
        sensor = new Bh1750(Device.CreateI2cBus(), Bh1750.I2cAddressLow);

        Task.Run(async () =>
        {
            while(true)
            {
                Console.WriteLine($"Illuminance: {sensor.GetIlluminance()}lux");
                await Task.Delay(1000);
            }
        });
    }
}

Sample projects available on GitHub

Wiring Example

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

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

It should look like the following diagram:

Characteristic Locus
Inheritance System.Object > Bh1750
Inherited Members System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Foundation.Sensors.Light
Assembly Bh1750.dll

Syntax

public class Bh1750

Constructors

Bh1750(II2cBus, Byte, Bh1750.MeasuringModes, Double)

Create a new BH1750 light sensor object using a static reference voltage.

Declaration
public Bh1750(II2cBus i2cBus, byte address, Bh1750.MeasuringModes measuringMode = default(Bh1750.MeasuringModes), double lightTransmittance = 1)

Parameters

Type Name Description
II2cBus i2cBus
System.Byte address
Bh1750.MeasuringModes measuringMode
System.Double lightTransmittance

Properties

I2cAddressHigh

I2C address when address pin is high

Declaration
public static byte I2cAddressHigh { get; }

Property Value

Type Description
System.Byte

I2cAddressLow

I2C address when address pin is low

Declaration
public static byte I2cAddressLow { get; }

Property Value

Type Description
System.Byte

LightTransmittance

BH1750 Light Transmittance (27.20-222.50%)

Declaration
public double LightTransmittance { get; set; }

Property Value

Type Description
System.Double

MeasuringMode

BH1750 Measuring Mode

Declaration
public Bh1750.MeasuringModes MeasuringMode { get; set; }

Property Value

Type Description
Bh1750.MeasuringModes

Methods

GetIlluminance()

Get BH1750 Illuminance

Declaration
public double GetIlluminance()

Returns

Type Description
System.Double

Illuminance (Lux)