API Reference

adafruit_scd30

Helper library for the SCD30 CO2 sensor

  • Author(s): Bryan Siepert

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_scd30.SCD30(i2c_bus: I2C, ambient_pressure: int = 0, address: int = 97)

CircuitPython helper class for using the SCD30 CO2 sensor

Parameters:
  • i2c_bus (I2C) – The I2C bus the SCD30 is connected to.

  • ambient_pressure (int) – Ambient pressure compensation. Defaults to 0

  • address (int) – The I2C device address for the sensor. Default is 0x61

Quickstart: Importing and using the SCD30

Here is an example of using the SCD30 class. First you will need to import the libraries to use the sensor

import board
import adafruit_scd30

Once this is done you can define your board.I2C object and define your sensor object

i2c = board.I2C()   # uses board.SCL and board.SDA
scd = adafruit_scd30.SCD30(i2c)

Now you have access to the CO2, temperature and humidity using the CO2, temperature and relative_humidity attributes

temperature = scd.temperature
relative_humidity = scd.relative_humidity
co2_ppm_level = scd.CO2

Note

ambient_pressure default: disabled is written on every construction of this object (to start continuous measurement). measurement_interval defaults to 2 on a new sensor but persists in NVM so if changed by your application will persist across power cycles.

Parameters:
  • i2c_bus (I2C) – The I2C bus the SCD30 is connected to.

  • ambient_pressure (int) – Ambient pressure compensation in mBar, 0 (disabled) or 700-1400. Defaults to 0.

  • address (int) – The I2C device address for the sensor. Defaults to 0x61.

Raises:

AttributeError – if ambient_pressure is nonzero and outside 700-1400 mBar.

property CO2: float

Returns the CO2 concentration in PPM (parts per million)

Note

Between measurements, the most recent reading will be cached and returned. If called before the first measurement has completed, returns None.

Returns:

CO2 concentration in ppm, or None if no measurement has completed yet

Return type:

float or None

property altitude: int

Specifies the altitude at the measurement location in meters above sea level. Setting this value adjusts the CO2 measurement calculations to account for the air pressure’s effect on readings.

Note

This value is only used when ambient_pressure is set to 0=(disabled). It is saved in NVR and will not be reset on boot, reset or powercycle.

Returns:

the currently configured altitude compensation, in meters above sea level

Return type:

int

property ambient_pressure: int

Specifies the ambient air pressure at the measurement location in mBar. Setting this value adjusts the CO2 measurement calculations to account for the air pressure’s effect on readings. Values must be in mBar, from 700 to 1400 mBar

Note

This value is not saved and will be reset to 0=disabled on powercycle, boot or by calling reset. For non-volatile compensation use altitude instead (saved in nvm)

Returns:

the currently configured ambient pressure compensation, in mBar

Return type:

int

property data_available: bool

Check the sensor to see if new data is available.

Returns:

True if a new measurement is ready to be read

Return type:

bool

property firmware_version: str

Returns the firmware version of the sensor. Can also be used to check whether sensor is present and responding.

Returns:

the sensor firmware version major/minor rev

Return type:

str

property forced_recalibration_reference: int

Specifies the concentration of a reference source of CO2 placed in close proximity to the sensor. The value must be from 400 to 2000 ppm.

Note

Specifying a forced recalibration reference will override any calibration values set by Automatic Self Calibration

Warning

Before applying, the sensor should be running in continuous measurement mode, at the default 2 second interval, in a stable known-CO2 environment, for at least 2 minutes. This permanently updates the sensor’s calibration curve.

Returns:

the currently configured forced recalibration reference, in ppm

Return type:

int

property measurement_interval: int

Sets the interval between readings in seconds. The interval value must be from 2-1800

Note

This value will be saved in nvm and will persist across powercycles, reboots or by calling reset.

Returns:

the currently configured measurement interval, in seconds

Return type:

int

property relative_humidity: float

Returns the current relative humidity in %rH.

Note

Between measurements, the most recent reading will be cached and returned. If called before the first measurement has completed, returns None.

Returns:

relative humidity in %rH, or None if no measurement has completed yet

Return type:

float or None

reset() None

Perform a soft reset on the sensor, restoring default values.

Returns:

None

Return type:

None

property self_calibration_enabled: bool

Enables or disables automatic self calibration (ASC). To work correctly, the sensor must be on and active for 7 days after enabling ASC, and exposed to fresh air for at least 1 hour per day. Consult the manufacturer’s documentation for more information.

Note

Enabling self calibration will override any values set by specifying a forced_recalibration_reference

Note

This value will be saved and will not be reset on boot or by calling reset.

Returns:

whether automatic self calibration is currently enabled

Return type:

bool

start_continuous_measurement(pressure_mbar: int = 0) None

Start continuous measurement - with optional ambient pressure

Parameters:

pressure_mbar (int) – the ambient pressure in mbar from 700-1400

Returns:

None

Return type:

None

stop_continuous_measurement() None

Stops the continuous measurement of the SCD30

This is provide for completness. There is only one SC30 mode: continuous_measurement so stop_continuous_measurement() freezes measurements at the last measurement.

Returns:

None

Return type:

None

property temperature: float

Returns the current temperature in degrees Celsius

Note

Between measurements, the most recent reading will be cached and returned. If called before the first measurement has completed, returns None.

Returns:

temperature in degrees Celsius, or None if no measurement has completed yet

Return type:

float or None

property temperature_offset: float

Specifies the offset to be added to the reported measurements to account for a bias in the measured signal. Value is in degrees Celsius with a resolution of 0.01 degrees and a maximum value of 655.35 C

Note

This value will be saved and will not be reset on boot or by calling reset.

Returns:

the currently configured temperature offset, in degrees Celsius

Return type:

float