Characteristic Locus
Inheritance System.Object > DhtBase > Dht10 > Dht12
Implements IAtmosphericSensor ITemperatureSensor IHumiditySensor
Namespace Meadow.Foundation.Sensors.Atmospheric
Assembly Dhtxx.dll

Syntax

public abstract class DhtBase : FilterableChangeObservableBase<AtmosphericConditionChangeResult, AtmosphericConditions>, IAtmosphericSensor, ITemperatureSensor, IHumiditySensor

Constructors

DhtBase(II2cBus, Byte)

Create a DHT sensor through I2C (Only DHT12)

Declaration
public DhtBase(II2cBus i2cBus, byte address = 92)

Parameters

Type Name Description
II2cBus i2cBus
System.Byte address

Fields

_readBuffer

Read buffer

Declaration
protected byte[] _readBuffer

Field Value

Type Description
System.Byte[]

_sensor

DHT12 sensor object.

Declaration
protected readonly II2cPeripheral _sensor

Field Value

Type Description
II2cPeripheral

Properties

Conditions

The AtmosphericConditions from the last reading.

Declaration
public AtmosphericConditions Conditions { get; protected set; }

Property Value

Type Description
AtmosphericConditions

Humidity

The humidity, in percent relative humidity, from the last reading..

Declaration
public float Humidity { get; }

Property Value

Type Description
System.Single

IsSampling

Gets a value indicating whether the analog input port is currently sampling the sensor. Call StartSampling() to spin up the sampling process.

Declaration
public bool IsSampling { get; protected set; }

Property Value

Type Description
System.Boolean

true if sampling, otherwise, false.

Temperature

The temperature, in degrees celsius (°C), from the last reading.

Declaration
public float Temperature { get; }

Property Value

Type Description
System.Single

WasLastReadSuccessful

How last read went, true for success, false for failure

Declaration
public bool WasLastReadSuccessful { get; }

Property Value

Type Description
System.Boolean

Methods

RaiseChangedAndNotify(AtmosphericConditionChangeResult)

Declaration
protected void RaiseChangedAndNotify(AtmosphericConditionChangeResult changeResult)

Parameters

Type Name Description
AtmosphericConditionChangeResult changeResult

Read()

Convenience method to get the current sensor readings. For frequent reads, use StartSampling() and StopSampling() in conjunction with the SampleBuffer.

Declaration
public Task<AtmosphericConditions> Read()

Returns

Type Description
System.Threading.Tasks.Task<AtmosphericConditions>

StartUpdating(Int32)

Declaration
public void StartUpdating(int standbyDuration = 1000)

Parameters

Type Name Description
System.Int32 standbyDuration

StopUpdating()

Stops sampling the temperature.

Declaration
public void StopUpdating()

Update()

Force the sensor to make a reading and update the relevant properties.

Declaration
public Task Update()

Returns

Type Description
System.Threading.Tasks.Task

Events

Updated

Declaration
public event EventHandler<AtmosphericConditionChangeResult> Updated

Event Type

Type Description
System.EventHandler<AtmosphericConditionChangeResult>