API Documentation

SCD30

Scd30Device

The class Scd30DeviceBase implements the low level interface of the sensor. The class Scd30Device extends the Scd30DeviceBase. It provides additional functions to ease the use of the sensor.

class sensirion_i2c_scd30.device.Scd30DeviceBase(channel)[source]

Low level API implementation of SCD30

__init__(channel)[source]
property channel
start_periodic_measurement(ambient_pressure)[source]

Starts continuous measurement of the SCD30 to measure CO₂ concentration, humidity and temperature. Measurement data which is not read from the sensor will be overwritten. The CO₂ 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). For setting a new ambient pressure when continuous measurement is running the whole command has to be written to SCD30.

Parameters:

ambient_pressure – Ambient pressure in millibar.

Example:
sensor.start_periodic_measurement(0)
stop_periodic_measurement()[source]

Stops the continuous measurement of the SCD30.

set_measurement_interval(interval)[source]

Sets the interval used by the SCD30 sensor to measure in continuous measurement mode. Initial value is 2s. The chosen measurement interval is saved in non-volatile memory and thus is not reset to its initial value after power up.

Parameters:

interval – Measurement interval in seconds.

Example:
sensor.set_measurement_interval(4)
get_measurement_interval()[source]

Reads out the active measurement interval.

Return interval:

Configured measurement interval

get_data_ready()[source]

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 SCD30 the return value changes to 0.

Return data_ready_flag:

Data ready flag

Note

The read header should be sent with a delay of >3ms following the write sequence.

read_measurement_data()[source]

Allows to read new measurement data if data is available.

Return co2_concentration:

Return temperature:

Return humidity:

activate_auto_calibration(do_activate)[source]

Continuous automatic self-calibration (ASC) 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.

Parameters:

do_activate – Set activate flag.

Note

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 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.

Example:
sensor.activate_auto_calibration(1)
get_auto_calibration_status()[source]

Read out the status of the active self calibration.

Return is_active:

Indication if automatic calibration is active

force_recalibration(co2_ref_concentration)[source]

Forced recalibration (FRC) is used to compensate for sensor drifts when a reference value of the CO₂ 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 CO₂ concentration by the method described here will always supersede corrections from the ASC (see command activate_auto_calibration) and vice-versa. The reference CO₂ concentration has to be within the range 400 ppm ≤ cref(CO₂) ≤ 2000 ppm. The FRC method imposes a permanent update of the CO₂ 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.

Parameters:

co2_ref_concentration – New CO2 reference concentration.

Example:
sensor.force_recalibration(500)
get_force_recalibration_status()[source]

Read out the CO₂ reference concentration.

Return co2_ref_concentration:

Currently used CO2 reference concentration.

set_temperature_offset(temperature_offset)[source]

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.

Parameters:

temperature_offset

Example:
sensor.set_temperature_offset(2000)
get_temperature_offset()[source]

Read out the actual temperature offset. The result can be converted to ℃ by dividing it by 100.

Return temperature_offset:

get_altitude_compensation()[source]

Read out the configured altitude (height in [m] over sea level).

Return altitude:

set_altitude_compensation(altitude)[source]

Measurements of CO₂ 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 (see command start_periodic_measurement). Altitude value is saved in non-volatile memory. The last set value will be used for altitude compensation after repowering.

Parameters:

altitude

Example:
sensor.set_altitude_compensation(440)
read_firmware_version()[source]

Read the version of the current firmware.

Return major:

Major version number.

Return minor:

Minor version number.

soft_reset()[source]

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.

class sensirion_i2c_scd30.device.Scd30Device(channel)[source]

Driver class implementation of SCD30

scd30

Access to base class

__init__(channel)[source]
await_data_ready()[source]

Repeatedly call the get_data_ready() until the ready flag is set to 1. If the minimal measurement interval is 2s we iterate at most 200 times. Note that this is blocking the system for a considerable amount of time!

blocking_read_measurement_data()[source]

This is a convenience method that combines polling the data ready flag and reading out the data. Note that this is blocking the system for a considerable amount of time!

Return co2_concentration:

Return temperature:

Return humidity:

Commands

The transfer classes specify the data that is transferred between host and sensor. The generated transfer classes are used by the driver class and not intended for direct use.

class sensirion_i2c_scd30.commands.StartPeriodicMeasurement(ambient_pressure)[source]

Starts continuous measurement of the SCD30 to measure CO₂ concentration, humidity and temperature. Measurement data which is not read from the sensor will be overwritten. The CO₂ 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). For setting a new ambient pressure when continuous measurement is running the whole command has to be written to SCD30.

CMD_ID = 16
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_scd30.commands.StopPeriodicMeasurement[source]

Stops the continuous measurement of the SCD30.

CMD_ID = 260
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_scd30.commands.SetMeasurementInterval(interval)[source]

Sets the interval used by the SCD30 sensor to measure in continuous measurement mode. Initial value is 2s. The chosen measurement interval is saved in non-volatile memory and thus is not reset to its initial value after power up.

CMD_ID = 17920
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_scd30.commands.GetMeasurementInterval[source]

Reads out the active measurement interval.

CMD_ID = 17920
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_scd30.commands.GetDataReady[source]

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 SCD30 the return value changes to 0.

CMD_ID = 514
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_scd30.commands.ReadMeasurementData[source]

Allows to read new measurement data if data is available.

CMD_ID = 768
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_scd30.commands.ActivateAutoCalibration(do_activate)[source]

Continuous automatic self-calibration (ASC) 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.

CMD_ID = 21254
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_scd30.commands.GetAutoCalibrationStatus[source]

Read out the status of the active self calibration.

CMD_ID = 21254
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_scd30.commands.ForceRecalibration(co2_ref_concentration)[source]

Forced recalibration (FRC) is used to compensate for sensor drifts when a reference value of the CO₂ 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 CO₂ concentration by the method described here will always supersede corrections from the ASC (see command activate_auto_calibration) and vice-versa. The reference CO₂ concentration has to be within the range 400 ppm ≤ cref(CO₂) ≤ 2000 ppm. The FRC method imposes a permanent update of the CO₂ 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.

CMD_ID = 20996
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_scd30.commands.GetForceRecalibrationStatus[source]

Read out the CO₂ reference concentration.

CMD_ID = 20996
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_scd30.commands.SetTemperatureOffset(temperature_offset)[source]

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.

CMD_ID = 21507
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_scd30.commands.GetTemperatureOffset[source]

Read out the actual temperature offset. The result can be converted to ℃ by dividing it by 100.

CMD_ID = 21507
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_scd30.commands.GetAltitudeCompensation[source]

Read out the configured altitude (height in [m] over sea level).

CMD_ID = 20738
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_scd30.commands.SetAltitudeCompensation(altitude)[source]

Measurements of CO₂ 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 (see command start_periodic_measurement). Altitude value is saved in non-volatile memory. The last set value will be used for altitude compensation after repowering.

CMD_ID = 20738
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
class sensirion_i2c_scd30.commands.ReadFirmwareVersion[source]

Read the version of the current firmware.

CMD_ID = 53504
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>
rx = <sensirion_driver_adapters.rx_tx_data.RxData object>
class sensirion_i2c_scd30.commands.SoftReset[source]

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.

CMD_ID = 54020
pack()[source]
tx = <sensirion_driver_adapters.rx_tx_data.TxData object>

Result Types

The signal classes specify transformations of the raw sensor signals into a meaningful units. The generated signal types are used by the driver class and not intended for direct use.