Remarks

TemperatureHumiditySensor_HighAccuracyMini
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Grove.Sensors.Atmospheric.TemperatureHumiditySensor_HighAccuracyMini

Code Example

TemperatureHumiditySensor_HighAccuracyMini sensor;

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

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

    var consumer = TemperatureHumiditySensor_HighAccuracyMini.CreateObserver(
        handler: result =>
        {
            Resolver.Log.Info($"Observer: Temp changed by threshold; new temp: {result.New.Temperature?.Celsius:N2}C, old: {result.Old?.Temperature?.Celsius:N2}C");
        },
        filter: result =>
        {
            //c# 8 pattern match syntax. checks for !null and assigns var.
            if (result.Old is { } old)
            {
                return (
                (result.New.Temperature.Value - old.Temperature.Value).Abs().Celsius > 0.5);
            }
            return false;
        }
    );
    sensor.Subscribe(consumer);

    sensor.Updated += (sender, result) =>
    {
        Resolver.Log.Info($"  Temperature: {result.New.Temperature?.Celsius:N2}C");
        Resolver.Log.Info($"  Relative Humidity: {result.New.Humidity?.Percent:N2}%");
    };

    return Task.CompletedTask;
}

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

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

TemperatureHumiditySensor_HighAccuracyMini Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00
Characteristic Locus
Inheritance object ObservableBase<(Temperature? Temperature, RelativeHumidity? Humidity)> SamplingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)> PollingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)> ByteCommsSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)> Th02 > TemperatureHumiditySensor_HighAccuracyMini
Implements IObservable<IChangeResult<(Temperature? Temperature, RelativeHumidity? Humidity)>> ISamplingSensor<(Temperature? Temperature, RelativeHumidity? Humidity)> ISensor<(Temperature? Temperature, RelativeHumidity? Humidity)> IDisposable ITemperatureSensor ISamplingSensor<Temperature> ISensor<Temperature> IHumiditySensor ISamplingSensor<RelativeHumidity> ISensor<RelativeHumidity> II2cPeripheral
Inherited Members Th02.TemperatureUpdated Th02.HumidityUpdated Th02.Temperature Th02.Humidity Th02.DefaultI2cAddress Th02.RaiseEventsAndNotify(IChangeResult<(Temperature? Temperature, RelativeHumidity? Humidity)>) Th02.ReadSensor() ByteCommsSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.BusComms ByteCommsSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.ReadBuffer ByteCommsSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.WriteBuffer ByteCommsSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.Init(int, int) ByteCommsSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.Dispose(bool) ByteCommsSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.Dispose() PollingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.StartUpdating(TimeSpan?) PollingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.StopUpdating() SamplingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.samplingLock SamplingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.Updated SamplingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.SamplingTokenSource SamplingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.Conditions SamplingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.IsSampling SamplingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.UpdateInterval SamplingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.ReadSensor() SamplingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.RaiseEventsAndNotify(IChangeResult<(Temperature? Temperature, RelativeHumidity? Humidity)>) SamplingSensorBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.Read() ObservableBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.observers ObservableBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.NotifyObservers(IChangeResult<(Temperature? Temperature, RelativeHumidity? Humidity)>) ObservableBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.Subscribe(IObserver<IChangeResult<(Temperature? Temperature, RelativeHumidity? Humidity)>>) ObservableBase<(Temperature? Temperature, RelativeHumidity? Humidity)>.CreateObserver(Action<IChangeResult<(Temperature? Temperature, RelativeHumidity? Humidity)>>, Predicate<IChangeResult<(Temperature? Temperature, RelativeHumidity? Humidity)>>) object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Grove.Sensors.Atmospheric
Assembly TemperatureHumiditySensor_HighAccuracyMini.dll

Syntax

public class TemperatureHumiditySensor_HighAccuracyMini : Th02, IObservable<IChangeResult<(Temperature? Temperature, RelativeHumidity? Humidity)>>, ISamplingSensor<(Temperature? Temperature, RelativeHumidity? Humidity)>, ISensor<(Temperature? Temperature, RelativeHumidity? Humidity)>, IDisposable, ITemperatureSensor, ISamplingSensor<Temperature>, ISensor<Temperature>, IHumiditySensor, ISamplingSensor<RelativeHumidity>, ISensor<RelativeHumidity>, II2cPeripheral

Constructors

TemperatureHumiditySensor_HighAccuracyMini(II2cBus)

Creates a TemperatureHumiditySensor_HighAccuracyMini driver

Declaration
public TemperatureHumiditySensor_HighAccuracyMini(II2cBus i2cBus)

Parameters

Type Name Description
II2cBus i2cBus

Remarks

TemperatureHumiditySensor_HighAccuracyMini
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Grove.Sensors.Atmospheric.TemperatureHumiditySensor_HighAccuracyMini

Code Example

TemperatureHumiditySensor_HighAccuracyMini sensor;

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

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

    var consumer = TemperatureHumiditySensor_HighAccuracyMini.CreateObserver(
        handler: result =>
        {
            Resolver.Log.Info($"Observer: Temp changed by threshold; new temp: {result.New.Temperature?.Celsius:N2}C, old: {result.Old?.Temperature?.Celsius:N2}C");
        },
        filter: result =>
        {
            //c# 8 pattern match syntax. checks for !null and assigns var.
            if (result.Old is { } old)
            {
                return (
                (result.New.Temperature.Value - old.Temperature.Value).Abs().Celsius > 0.5);
            }
            return false;
        }
    );
    sensor.Subscribe(consumer);

    sensor.Updated += (sender, result) =>
    {
        Resolver.Log.Info($"  Temperature: {result.New.Temperature?.Celsius:N2}C");
        Resolver.Log.Info($"  Relative Humidity: {result.New.Humidity?.Percent:N2}%");
    };

    return Task.CompletedTask;
}

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

    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

TemperatureHumiditySensor_HighAccuracyMini Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00