Class Scd30Sensor
Sensirion SCD30 Sensor Module (CO2, humidity, and temperature sensor).
public class Scd30Sensor
- Inheritance
-
Scd30Sensor
Remarks
Most of the SCD30 documentation below is derived or copied from the original documentation at https://sensirion.com/media/documents/D7CEEF4A/6165372F/Sensirion_CO2_Sensors_SCD30_Interface_Description.pdf .
Constructors
Scd30Sensor(SerialPort)
Initializes a new instance of the Scd30Sensor class to control the SCD30 via SerialPort. The BaudRate, DataBits, Parity, StopBits and timeouts will be configured automatically to interact with the SCD30.
public Scd30Sensor(SerialPort serial)
Parameters
serial
SerialPortThe serial port to use to communicate with the SCD30 sensor.
Methods
GetAltitudeCompensation()
Get the currently configured altitude compensation. See SetAltitudeCompensation(Length) for more information.
public Length GetAltitudeCompensation()
Returns
- Length
The currently configured altitude compensation.
GetAutomaticSelfCalibration()
Get the current setting for the ASC (Automatic Self Calibration). See SetAutomaticSelfCalibration(bool) for more information.
public bool GetAutomaticSelfCalibration()
Returns
- bool
True when Automatic Self Calibration is enabled, false otherwise.
GetDataReadyStatus()
Data ready command is used to determine if a measurement can be read from the sensor’s buffer. Whenever there is a measurement available from the internal buffer this command returns 1 and 0 otherwise. As soon as the measurement has been read by the return value changes to 0. Note that the read header should be send with a delay of > 3ms following the write sequence.
It is recommended to use data ready status byte before readout of the measurement values.
public bool GetDataReadyStatus()
Returns
- bool
True when there's a measurement available to be read out, otherwise false.
GetForcedRecalibrationValue()
Get the current value for the Forced Recalibration (FRC) setting. See SetForcedRecalibrationValue(VolumeConcentration) for more information.
public VolumeConcentration GetForcedRecalibrationValue()
Returns
- VolumeConcentration
The current Forced Recalibration (FRC) value.
GetMeasurementInterval()
Reads the currently set measurement interval on the SCD30 sensor.
public TimeSpan GetMeasurementInterval()
Returns
GetTemperatureOffset()
Get the currently configured temperature offset. See SetTemperatureOffset(Temperature) for more information.
public Temperature GetTemperatureOffset()
Returns
- Temperature
The currently configured temperature offset.
ReadFirmwareVersion()
This command can be used to read out the firmware version of SCD30 module.
public Version ReadFirmwareVersion()
Returns
- Version
The firmware version of the SCD30 sensor.
ReadMeasurement()
Data ready command is used to determine if a measurement can be read from the sensor’s buffer. Whenever there is a measurement available from the internal buffer this command returns 1 and 0 otherwise. As soon as the measurement has been read by the return value changes to 0.
It is recommended to use data ready status byte before readout of the measurement values.
public Measurement ReadMeasurement()
Returns
- Measurement
The measured values.
SetAltitudeCompensation(Length)
Measurements of CO2 concentration based on the NDIR principle are influenced by altitude. SCD30 offers to compensate deviations due to altitude by using this command. Setting altitude is disregarded when an ambient pressure is given to the sensor, please see section 1.4.1.
Altitude value is saved in non-volatile memory. The last set value will be used for altitude compensation after repowering.
public void SetAltitudeCompensation(Length altitudeAboveSeaLevel)
Parameters
altitudeAboveSeaLevel
LengthHeight over sea level above 0.
SetAutomaticSelfCalibration(bool)
Continuous automatic self-calibration can be (de-)activated with this command. When activated for the first time a period of minimum 7 days is needed so that the algorithm can find its initial parameter set for ASC. The sensor has to be exposed to fresh air for at least 1 hour every day. Also during that period, the sensor may not be disconnected from the power supply, otherwise the procedure to find calibration parameters is aborted and has to be restarted from the beginning. The successfully calculated parameters are stored in non-volatile memory of the SCD30 having the effect that after a restart the previously found parameters for ASC are still present. Note that the most recently found self-calibration parameters will be actively used for self-calibration disregarding the status of this feature. Finding a new parameter set by the here described method will always overwrite the settings from external recalibration (see chapter 0) and vice-versa. The feature is switched off by default.
To work properly SCD30 has to see fresh air on a regular basis. Optimal working conditions are given when the sensor sees fresh air for one hour every day so that ASC can constantly re-calibrate. ASC only works in continuous measurement mode.
ASC status is saved in non-volatile memory. When the sensor is powered down while ASC is activated SCD30 will continue with automatic self-calibration after repowering without sending the command.
public void SetAutomaticSelfCalibration(bool activate)
Parameters
activate
boolTrue to activate automatic self-calibration, false to deactivate.
SetForcedRecalibrationValue(VolumeConcentration)
Forced recalibration (FRC) is used to compensate for sensor drifts when a reference value of the CO2 concentration in close proximity to the SCD30 is available. For best results, the sensor has to be run in a stable environment in continuous mode at a measurement rate of 2s for at least two minutes before applying the FRC command and sending the reference value. Setting a reference CO2 concentration by the method described here will always supersede corrections from the ASC (see chapter 1.4.6) and vice-versa. The reference CO2 concentration has to be within the range 400 ppm ≤ cref(CO2) ≤ 2000 ppm.
The FRC method imposes a permanent update of the CO2 calibration curve which persists after repowering the sensor. The most recently used reference value is retained in volatile memory and can be read out with the command sequence given below.
After repowering the sensor, the command will return the standard reference value of 400 ppm.
public void SetForcedRecalibrationValue(VolumeConcentration referenceCo2Concentration)
Parameters
referenceCo2Concentration
VolumeConcentrationThe reference CO2 concentration in the range 400-2000 ppm.
SetMeasurementInterval(TimeSpan)
Sets the interval used by the SCD30 sensor to measure in continuous measurement mode (see chapter 1.4.1). Initial value is 2 s. The chosen measurement interval is saved in non-volatile memory and thus is not reset to its initial value after power up.
public void SetMeasurementInterval(TimeSpan measurementInterval)
Parameters
measurementInterval
TimeSpanThe new measurement interval. Must be within 2 seconds and 1800 seconds, and will be floored to full seconds if a smaller unit is used.
Exceptions
- ArgumentOutOfRangeException
When the given interval is not within the acceptable range.
SetTemperatureOffset(Temperature)
The on-board RH/T sensor is influenced by thermal self-heating of SCD30 and other electrical components. Design-in alters the thermal properties of SCD30 such that temperature and humidity offsets may occur when operating the sensor in end-customer devices. Compensation of those effects is achievable by writing the temperature offset found in continuous operation of the device into the sensor.
Temperature offset value is saved in non-volatile memory. The last set value will be used for temperature offset compensation after repowering.
public void SetTemperatureOffset(Temperature temperatureOffset)
Parameters
temperatureOffset
TemperatureThe temperature offset to be used.
SoftReset()
The SCD30 provides a soft reset mechanism that forces the sensor into the same state as after powering up without the need for removing the power-supply. It does so by restarting its system controller. After soft reset the sensor will reload all calibrated data. However, it is worth noting that the sensor reloads calibration data prior to every measurement by default. This includes previously set reference values from ASC or FRC as well as temperature offset values last setting.
The sensor is able to receive the command at any time, regardless of its internal state.
public void SoftReset()
StartContinuousMeasurement()
Starts continuous measurement of the SCD30 to measure CO2 concentration, humidity and temperature. Measurement data which is not read from the sensor will be overwritten. The measurement interval is adjustable via SetMeasurementInterval(TimeSpan). Initial measurement rate is 2s.
Continuous measurement status is saved in non-volatile memory. When the sensor is powered down while continuous measurement mode is active SCD30 will measure continuously after repowering without sending the measurement command. The CO2 measurement value can be compensated for ambient pressure by feeding the pressure value in mBar to the sensor.
Setting the ambient pressure will overwrite previous settings of altitude compensation. Setting the argument to zero will deactivate the ambient pressure compensation (default ambient pressure = 1013.25 mBar).
public void StartContinuousMeasurement()
StartContinuousMeasurement(Pressure)
Starts continuous measurement of the SCD30 to measure CO2 concentration, humidity and temperature. Measurement data which is not read from the sensor will be overwritten. The measurement interval is adjustable via SetMeasurementInterval(TimeSpan). Initial measurement rate is 2s.
Continuous measurement status is saved in non-volatile memory. When the sensor is powered down while continuous measurement mode is active SCD30 will measure continuously after repowering without sending the measurement command.
The CO2 measurement value can be compensated for ambient pressure by feeding the pressure value in mBar to the sensor. Setting the ambient pressure will overwrite previous settings of altitude compensation. Setting the argument to zero will deactivate the ambient pressure compensation (default ambient pressure = 1013.25 mBar).
public void StartContinuousMeasurement(Pressure ambientPressureCompentation)
Parameters
ambientPressureCompentation
PressureSet 0 millibars to use default ambient pressure (1013.25mBar), or pass the pressure to use instead (range 700-1400 millibars).
Exceptions
- ArgumentOutOfRangeException
When the pressure is not within the acceptable range.
StopContinuousMeasurement()
Stops the continuous measurement of the SCD30.
public void StopContinuousMeasurement()