Skip to main content

Class Ens160

Represents an ENS160 Digital Metal-Oxide Multi-Gas Sensor

Assembly: Ens160.dll
View Source
Declaration
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>

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
Declaration
public Concentration? Concentration { get; }

CO2Concentration

The current C02 concentration value

View Source
Declaration
public Concentration? CO2Concentration { get; }

EthanolConcentration

The current ethanol concentration value

View Source
Declaration
public Concentration? EthanolConcentration { get; }

TVOCConcentration

The current Total Volatile Organic Compounds (TVOC) concentration value

View Source
Declaration
public Concentration? TVOCConcentration { get; }

CurrentOperatingMode

The current device operating mode

View Source
Declaration
public Ens160.OperatingMode CurrentOperatingMode { get; set; }

DefaultI2cAddress

The default I2C address for the peripheral

View Source
Declaration
public byte DefaultI2cAddress { get; }

Methods

Initialize()

Initialize the sensor

View Source
Declaration
protected Task Initialize()
Returns

System.Threading.Tasks.Task

Reset()

Reset the sensor

View Source
Declaration
public Task Reset()
Returns

System.Threading.Tasks.Task

GetDeviceID()

Get the sensor ID from PART_ID register Default value is 0x0160 (352)

View Source
Declaration
public ushort GetDeviceID()
Returns

System.UInt16: ID as a ushort (2 bytes)### GetFirmwareVersion() Get the sensor app / firmware version

View Source
Declaration
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
Declaration
public void SetTemperature(Temperature ambientTemperature)
Parameters
TypeName
Meadow.Units.TemperatureambientTemperature

SetHumidity(RelativeHumidity)

Set relative humidity

View Source
Declaration
public void SetHumidity(RelativeHumidity humidity)
Parameters
TypeName
Meadow.Units.RelativeHumidityhumidity

GetAirQualityIndex()

Get the air quality index (AQI)

View Source
Declaration
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
Declaration
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
Declaration
public RelativeHumidity GetHumidity()
Returns

Meadow.Units.RelativeHumidity

StartUpdating(TimeSpan?)

Starts updating the sensor on the updateInterval frequency specified

View Source
Declaration
public override void StartUpdating(TimeSpan? updateInterval = null)
Parameters
TypeName
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
Declaration
public override void StopUpdating()

ReadSensor()

Get Scdx40 C02 Gas Concentration and Update the Concentration property

View Source
Declaration
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
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(Concentration? CO2Concentration, Concentration? EthanolConcentration, Concentration? TVOCConcentration)> changeResult)
Parameters
TypeNameDescription
Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>,System.Nullable<Meadow.Units.Concentration>>>changeResultThe change result with the current sensor data

Events

CO2ConcentrationUpdated

Raised when the CO2 concentration changes

View Source
Declaration
public event EventHandler<IChangeResult<Concentration>> CO2ConcentrationUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Concentration>>

EthanolConcentrationUpdated

Raised when the ethanol concentration changes

View Source
Declaration
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
Declaration
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