Class Ens160
Represents an ENS160 Digital Metal-Oxide Multi-Gas Sensor
Assembly: Ens160.dll
View Source
public class Ens160 : ByteCommsSensorBase<(Concentration? CO2Concentration, Concentration? EthanolConcentration, Concentration? TVOCConcentration)>, IObservable<IChangeResult<(Concentration? CO2Concentration, Concentration? EthanolConcentration, Concentration? TVOCConcentration)>>, ISamplingSensor<(Concentration? CO2Concentration, Concentration? EthanolConcentration, Concentration? TVOCConcentration)>, ISensor<(Concentration? CO2Concentration, Concentration? EthanolConcentration, Concentration? TVOCConcentration)>, IDisposable, ICO2ConcentrationSensor, ISamplingSensor<Concentration>, ISensor<Concentration>, ISensor, ISamplingSensor, II2cPeripheral
Inheritance: System.Object
-> Meadow.Foundation.ObservableBase<UNIT> -> Meadow.Foundation.SamplingSensorBase<UNIT> -> Meadow.Foundation.PollingSensorBase<UNIT> -> Meadow.Foundation.ByteCommsSensorBase<UNIT>
Implements:
Expand
System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>>>>
, Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>>>
, Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>>>
, System.IDisposable
, Meadow.Peripherals.Sensors.Environmental.ICO2ConcentrationSensor
, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Concentration>
, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Concentration>
, Meadow.Peripherals.Sensors.ISensor
, Meadow.Peripherals.Sensors.ISamplingSensor
, Meadow.Hardware.II2cPeripheral
Properties
Concentration
The current C02 concentration value
View Source
public Concentration? Concentration { get; }
CO2Concentration
The current C02 concentration value
View Source
public Concentration? CO2Concentration { get; }
EthanolConcentration
The current ethanol concentration value
View Source
public Concentration? EthanolConcentration { get; }
TVOCConcentration
The current Total Volatile Organic Compounds (TVOC) concentration value
View Source
public Concentration? TVOCConcentration { get; }
CurrentOperatingMode
The current device operating mode
View Source
public Ens160.OperatingMode CurrentOperatingMode { get; set; }
DefaultI2cAddress
The default I2C address for the peripheral
View Source
public byte DefaultI2cAddress { get; }
Methods
Initialize()
Initialize the sensor
View Source
protected Task Initialize()
Returns
System.Threading.Tasks.Task
Reset()
Reset the sensor
View Source
public Task Reset()
Returns
System.Threading.Tasks.Task
GetDeviceID()
Get the sensor ID from PART_ID register Default value is 0x0160 (352)
View Source
public ushort GetDeviceID()
Returns
System.UInt16
: ID as a ushort (2 bytes)### GetFirmwareVersion()
Get the sensor app / firmware version
View Source
public (byte Major, byte Minor, byte Release) GetFirmwareVersion()
Returns
System.ValueTuple<System.Byte,System.Byte,System.Byte>
: The major, minor, release values as a tuple of bytes### SetTemperature(Temperature)
Set ambient temperature
View Source
public void SetTemperature(Temperature ambientTemperature)
Parameters
Type | Name |
---|---|
Meadow.Units.Temperature | ambientTemperature |
SetHumidity(RelativeHumidity)
Set relative humidity
View Source
public void SetHumidity(RelativeHumidity humidity)
Parameters
Type | Name |
---|---|
Meadow.Units.RelativeHumidity | humidity |
GetAirQualityIndex()
Get the air quality index (AQI)
View Source
public Ens160.UBAAirQualityIndex GetAirQualityIndex()
Returns
Meadow.Foundation.Sensors.Environmental.Ens160.UBAAirQualityIndex
GetTemperature()
Get the temperature used for calculations - taken from TEMP_IN if supplied
View Source
public Temperature GetTemperature()
Returns
Meadow.Units.Temperature
: Temperature### GetHumidity()
Get the relative humidity used in its calculations -b taken from RH_IN if supplied
View Source
public RelativeHumidity GetHumidity()
Returns
Meadow.Units.RelativeHumidity
StartUpdating(TimeSpan?)
Starts updating the sensor on the updateInterval frequency specified
View Source
public override void StartUpdating(TimeSpan? updateInterval = null)
Parameters
Type | Name |
---|---|
System.Nullable<System.TimeSpan> | updateInterval |
StopUpdating()
Stop updating the sensor The sensor will not respond to commands for 500ms The call will delay the calling thread for 500ms
View Source
public override void StopUpdating()
ReadSensor()
Get Scdx40 C02 Gas Concentration and Update the Concentration property
View Source
protected override Task<(Concentration? CO2Concentration, Concentration? EthanolConcentration, Concentration? TVOCConcentration)> ReadSensor()
Returns
System.Threading.Tasks.Task<System.ValueTuple<System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>>>
RaiseEventsAndNotify(IChangeResult<(Concentration? CO2Concentration, Concentration? EthanolConcentration, Concentration? TVOCConcentration)>)
Raise change events for subscribers
View Source
protected override void RaiseEventsAndNotify(IChangeResult<(Concentration? CO2Concentration, Concentration? EthanolConcentration, Concentration? TVOCConcentration)> changeResult)
Parameters
Type | Name | Description |
---|---|---|
Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>>> | changeResult | The change result with the current sensor data |
Events
CO2ConcentrationUpdated
Raised when the CO2 concentration changes
View Source
public event EventHandler<IChangeResult<Concentration>> CO2ConcentrationUpdated
Event Type
System.EventHandler<Meadow.IChangeResult<Meadow.Units.Concentration>>
EthanolConcentrationUpdated
Raised when the ethanol concentration changes
View Source
public event EventHandler<IChangeResult<Concentration>> EthanolConcentrationUpdated
Event Type
System.EventHandler<Meadow.IChangeResult<Meadow.Units.Concentration>>
TVOCConcentrationUpdated
Raised when the Total Volatile Organic Compounds (TVOC) concentration changes
View Source
public event EventHandler<IChangeResult<Concentration>> TVOCConcentrationUpdated
Event Type
System.EventHandler<Meadow.IChangeResult<Meadow.Units.Concentration>>
Implements
System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>>>>
Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>>>
Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>>>
System.IDisposable
Meadow.Peripherals.Sensors.Environmental.ICO2ConcentrationSensor
Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Concentration>
Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Concentration>
Meadow.Peripherals.Sensors.ISensor
Meadow.Peripherals.Sensors.ISamplingSensor
Meadow.Hardware.II2cPeripheral