Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.3 KB

README.md

File metadata and controls

54 lines (40 loc) · 1.3 KB

SensorHub - Environmental sensor

Summary

SensorHub for reading Temperature, Pressure, Illuminance and Humidity. I2C can be used to communicate with the device.

Documentation

Usage

You can read all the sensors in a very straight forward way:

    const int I2cBusId = 1;
    I2cConnectionSettings connectionSettings = new(I2cBusId, SensorHub.DefaultI2cAddress);
    SensorHub sh = new(I2cDevice.Create(connectionSettings));

    if (sh.TryReadOffBoardTemperature(out var t))
    {
        Console.WriteLine($"OffBoard temperature {t}");
    }

    if (sh.TryReadBarometerPressure(out var p))
    {
        Console.WriteLine($"Pressure {p}");
    }

    if (sh.TryReadBarometerTemperature(out var bt))
    {
        Console.WriteLine($"Barometer temperature {bt}");
    }

    if (sh.TryReadIlluminance(out var l))
    {
        Console.WriteLine($"Illuminance {l}");
    }

    if (sh.TryReadOnBoardTemperature(out var ot))
    {
        Console.WriteLine($"OnBoard temperature {ot}");
    }

    if (sh.TryReadRelativeHumidity(out var h))
    {
        Console.WriteLine($"Relative humidity {h}");
    }

    if (sh.IsMotionDetected)
    {
        Console.WriteLine("Motion detected");
    }