API Reference
adafruit_scd4x
Driver for Sensirion SCD4X CO2 sensor
Author(s): ladyada
Implementation Notes
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
- class adafruit_scd4x.SCD4X(i2c_bus: I2C, address: int = 98)
CircuitPython helper class for using the SCD4X CO2 sensor
- Parameters:
Quickstart: Importing and using the SCD4X
Here is an example of using the
SCD4Xclass. First you will need to import the libraries to use the sensorimport board import adafruit_scd4x
Once this is done you can define your
board.I2Cobject and define your sensor objecti2c = board.I2C() # uses board.SCL and board.SDA scd = adafruit_scd4x.SCD4X(i2c) scd.start_periodic_measurement()
Now you have access to the CO2, temperature and humidity using the
CO2,temperatureandrelative_humidityattributesif scd.data_ready: temperature = scd.temperature relative_humidity = scd.relative_humidity co2_ppm_level = scd.CO2
- property CO2: int
Returns the CO2 concentration in PPM (parts per million)
Note
Between measurements, the most recent reading will be cached and returned.
- 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 will NOT be saved and will be reset on boot unless saved with persist_settings().
- factory_reset() None
Resets all configuration settings stored in the EEPROM and erases the FRC and ASC algorithm history.
- measure_single_shot() None
On-demand measurement of CO2 concentration, relative humidity, and temperature for SCD41 only
- measure_single_shot_rht_only() None
On-demand measurement of relative humidity and temperature for SCD41 only
- persist_settings() None
Save temperature offset, altitude offset, and selfcal enable settings to EEPROM
- property relative_humidity: float
Returns the current relative humidity in %rH.
Note
Between measurements, the most recent reading will be cached and returned.
- 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
This value will NOT be saved and will be reset on boot unless saved with persist_settings().
- property serial_number: Tuple[int, int, int, int, int, int]
Request a 6-tuple containing the unique serial number for this sensor
- set_ambient_pressure(ambient_pressure: int) None
Set the ambient pressure in hPa at any time to adjust CO2 calculations
- start_low_periodic_measurement() None
Put sensor into low power working mode, about 30s per measurement. See
start_periodic_measurement()for more details.
- start_periodic_measurement() None
Put sensor into working mode, about 5s per measurement
Note
Only the following commands will work once in working mode:
- property temperature: float
Returns the current temperature in degrees Celsius
Note
Between measurements, the most recent reading will be cached and returned.
- 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 374 C.
Note
This value will NOT be saved and will be reset on boot unless saved with persist_settings().