Syntax
public abstract class Scd4xBase : ByteCommsSensorBase<(Concentration? Concentration, Temperature? Temperature, RelativeHumidity? Humidity)>, IObservable<IChangeResult<(Concentration? Concentration, Temperature? Temperature, RelativeHumidity? Humidity)>>, ISamplingSensor<(Concentration? Concentration, Temperature? Temperature, RelativeHumidity? Humidity)>, ISensor<(Concentration? Concentration, Temperature? Temperature, RelativeHumidity? Humidity)>, IDisposable, ITemperatureSensor, ISamplingSensor<Temperature>, ISensor<Temperature>, IHumiditySensor, ISamplingSensor<RelativeHumidity>, ISensor<RelativeHumidity>, IConcentrationSensor, ISamplingSensor<Concentration>, ISensor<Concentration>, II2cPeripheral
Constructors
Scd4xBase(II2cBus, byte)
Create a new Scd4xBase object
Declaration
public Scd4xBase(II2cBus i2cBus, byte address = 98)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | The I2C bus |
byte | address | The I2C address |
Remarks
The constructor sends the stop periodic updates method otherwise the sensor may not respond to new commands
Properties
Concentration
The current C02 concentration value
Declaration
public Concentration? Concentration { get; }
Property Value
Type | Description |
---|---|
Concentration? |
DefaultI2cAddress
The default I2C address for the peripheral
Declaration
public byte DefaultI2cAddress { get; }
Property Value
Type | Description |
---|---|
byte |
Humidity
The current humidity
Declaration
public RelativeHumidity? Humidity { get; }
Property Value
Type | Description |
---|---|
RelativeHumidity? |
Temperature
The current temperature
Declaration
public Temperature? Temperature { get; }
Property Value
Type | Description |
---|---|
Temperature? |
Methods
GetSerialNumber()
Get Serial Number from the device
Declaration
public byte[] GetSerialNumber()
Returns
Type | Description |
---|---|
byte[] | a 48bit (6 byte) serial number as a byte array |
IsDataReady()
Is there sensor measurement data ready Sensor returns data ~5 seconds in normal operation and ~30 seconds in low power mode
Declaration
protected bool IsDataReady()
Returns
Type | Description |
---|---|
bool | True if ready |
PerformFactoryReset()
Device factory reset and clear all saved settings
Declaration
public void PerformFactoryReset()
PerformForcedRecalibration()
Forced recalibration allows recalibration using an external CO2 reference
Declaration
public Task PerformForcedRecalibration()
Returns
Type | Description |
---|---|
Task |
PersistSettings()
Persist settings to EEPROM
Declaration
public void PersistSettings()
RaiseChangedAndNotify(IChangeResult<(Concentration? Concentration, Temperature? Temperature, RelativeHumidity? Humidity)>)
Raise change events for subscribers
Declaration
protected void RaiseChangedAndNotify(IChangeResult<(Concentration? Concentration, Temperature? Temperature, RelativeHumidity? Humidity)> changeResult)
Parameters
Type | Name | Description |
---|---|---|
IChangeResult<(Concentration? Concentration, Temperature? Temperature, RelativeHumidity? Humidity)> | changeResult | The change result with the current sensor data |
ReInitialize()
Re-initialize the sensor
Declaration
public Task ReInitialize()
Returns
Type | Description |
---|---|
Task |
ReadSensor()
Get Scdx40 C02 Gas Concentration and Update the Concentration property
Declaration
protected override Task<(Concentration? Concentration, Temperature? Temperature, RelativeHumidity? Humidity)> ReadSensor()
Returns
Type | Description |
---|---|
Task<(Concentration? Concentration, Temperature? Temperature, RelativeHumidity? Humidity)> |
Overrides
StartUpdating(TimeSpan?)
Starts updating the sensor on the updateInterval frequency specified The sensor updates every 5 seconds, its recommended to choose an interval of 5s or longer If the update interval is 30 seconds or longer, the sensor will run in low power mode
Declaration
public override void StartUpdating(TimeSpan? updateInterval = null)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan? | updateInterval |
Overrides
StopUpdating()
Stop updating the sensor The sensor will not respond to commands for 500ms The call will delay the calling thread for 500ms
Declaration
public override void StopUpdating()
Overrides
Events
ConcentrationUpdated
Raised when the concentration changes
Declaration
public event EventHandler<IChangeResult<Concentration>> ConcentrationUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Concentration>> |
HumidityUpdated
Raised when the humidity value changes
Declaration
public event EventHandler<IChangeResult<RelativeHumidity>> HumidityUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<RelativeHumidity>> |
TemperatureUpdated
Raised when the temperature value changes
Declaration
public event EventHandler<IChangeResult<Temperature>> TemperatureUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Temperature>> |