Remarks
HIH6130 | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
The HIH6130 sensor allows the reading of the relative humidity and temperature via I2C.
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
Hih6130 sensor;
public MeadowApp()
{
sensor = new Hih6130(Device.CreateI2cBus());
sensor.StartUpdating();
sensor.Updated += Sensor_Updated;
}
private void Sensor_Updated(object sender, Meadow.Peripherals.Sensors.Atmospheric.AtmosphericConditionChangeResult e)
{
Console.WriteLine($"Humidity: {e.New.Humidity}, Temperature: {e.New.Temperature}");
}
}
Sample projects available on GitHub
Purchasing
The HIH6130 sensor is available on a breakout board from Sparkfun.
Example:
public class MeadowApp : App<F7Micro, MeadowApp>
{
Hih6130 sensor;
public MeadowApp()
{
Initialize();
sensor.StartUpdating();
sensor.Updated += Sensor_Updated;
}
private void Sensor_Updated(object sender, Meadow.Peripherals.Sensors.Atmospheric.AtmosphericConditionChangeResult e)
{
Console.WriteLine($"Humidity: {e.New.Humidity}, Temperature: {e.New.Temperature}");
}
public void Initialize()
{
Console.WriteLine("Init...");
sensor = new Hih6130(Device.CreateI2cBus());
}
}
Wiring Example
The HIH6130 requires only four connections between Meadow and the breakout board.
Meadow Pin | Sensor Pin | Wire Color |
---|---|---|
3.3V | Vcc | Red |
GND | GND | Black |
SC | SCK | Blue |
SD | SDC | White |
Characteristic | Locus |
---|---|
Inheritance | System.Object FilterableChangeObservableBase<AtmosphericConditionChangeResult, AtmosphericConditions> > Hih6130 |
Implements | System.IObservable<AtmosphericConditionChangeResult> IAtmosphericSensor ITemperatureSensor IHumiditySensor |
Inherited Members | FilterableChangeObservableBase<AtmosphericConditionChangeResult, AtmosphericConditions>._observers FilterableChangeObservableBase<AtmosphericConditionChangeResult, AtmosphericConditions>.NotifyObservers(AtmosphericConditionChangeResult) FilterableChangeObservableBase<AtmosphericConditionChangeResult, AtmosphericConditions>.Subscribe(IObserver<AtmosphericConditionChangeResult>) 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.Atmospheric |
Assembly | Hih6130.dll |
Syntax
public class Hih6130 : FilterableChangeObservableBase<AtmosphericConditionChangeResult, AtmosphericConditions>, IObservable<AtmosphericConditionChangeResult>, IAtmosphericSensor, ITemperatureSensor, IHumiditySensor
Constructors
Hih6130(II2cBus, Byte)
Create a new HIH6130 object using the default parameters for the component.
Declaration
public Hih6130(II2cBus i2cBus, byte address = 39)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | I2C bus (default = 100 KHz). |
System.Byte | address | Address of the HIH6130 (default = 0x27). |
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 ADC. Call StartSampling() to spin up the sampling process.
Declaration
public bool IsSampling { get; protected set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Temperature
The temperature, in degrees celsius (°C), from the last reading.
Declaration
public float Temperature { get; }
Property Value
Type | Description |
---|---|
System.Single |
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> |