Gases - CO2 SCD4x

CO2, Humidity and Temperature sensor

Plugin details

Type: Gases

Name: CO2 SCD4x

Status: COLLECTION E CLIMATE

GitHub: P135_SCD4x.ino

Maintainer: tonhuisman

Used libraries: https://github.com/sparkfun/SparkFun_SCD4x_Arduino_Library

Description

The SCD40 and SCD41 are CO2 sensor units that also provide Humidity and Temperature measurement, support auto-calibration, and have temperature and altitude compensation settings. By using the low-power operation option the measurements will be available slower, but average power usage will be much lower.

The SCD41 measures CO2 values up to 5000 ppm (SCD40 up to 2000 ppm), and also supports single-shot measurement, to enable really low average power consumption as it will enter a power-saving state when not measuring.

Configuration

Device configuration
  • Name: Required by ESPEasy, must be unique among the list of available devices/tasks.

  • Enabled: The device can be disabled or enabled. When not enabled the device should not use any resources.

I2C options

The available settings here depend on the build used. At least the Force Slow I2C speed option is available, but selections for the I2C Multiplexer can also be shown. For details see the Hardware page

Note

According to the documentation, the SCD4x sensors support a max. I2C Clock Speed of 100 kHz, but during testing it worked fine at the regular 400 kHz speed, so your milage may vary. If the readings are out of range, or other issues arise, Force Slow I2C speed should be checked! (ESPEasy has a default setting of 100 kHz for I2C Slow device Clock Speed).

Device Settings

  • Sensor model: Select the sensor model used, available options:

Sensor model options
  • SCD40 The default, ‘basic’, sensor model, that can measure CO2 up to 2000 ppm and does not support Single-shot measurements (might show values when configured, but the values are undefined).

  • SCD41 The ‘advanced’ model that supports measuring CO2 up to 5000 ppm and Single-shot measurements.

When this setting is changed, the page is saved and reloaded to show/hide the extra setting to enable Single-shot measurements (SCD41 only).

  • Altitude: Set the altitude above sealevel in meters, where the sensor is placed. The range is 0..2000 meter.

  • Temp offset: Offset for temperature correction. Can be set to compensate any self-heating of the device, by comparing the temperature measurement with another calibrated temperature measured close to the device. The difference can be set here, and can then be stored in the sensor by using the scd4x,storesettings command.

Note

ESPEasy will not update the Altitude or Temperature offset of the sensor if the values are set to 0.

  • Low-power measurement: To use the low power mode of the chip, this option can be checked. Instead of the regular 5 seconds per measurement, it will take up to 30 seconds to obtain a result.

  • Single-shot measurements (SCD41 only): (Not shown when Sensor model SCD40 is selected) This option enables the use of Single-shot measurements, that will be started on every Interval trigger, and provide a result 5 seconds later. By using this option with a long Interval the power consumption can be really low, as it does not continuously perform measurements, but puts the chip in a power-saving mode until the next measurement. This option only works when having a SCD41 sensor connected, when enabled on an SCD40 the values are undefined, even though they may seem somewhat reasonable.

  • Automatic Self Calibration: When enabled, the automatic self-calibration will be activated when the plugin is started. If the calibration is reset via the scd4x,factoryreset command, the calibration is reset to initial factory settings, and calibration data will have to be built up again.

Warning

Automatic Self Calibration is a useful process to ensure long term stability of the sensor, and assumes the sensor is exposed to fresh air of 400 ppm at least once per 7 days.

Data Acquisition

This group of settings, Single event with all values, Send to Controller and Interval settings are standard available configuration items. Send to Controller is only visible when one or more Controllers are configured.

  • Interval By default, Interval will be set to 60 sec. The data will be collected and optionally sent to any configured controllers using this interval.

Values

The plugin provides measurements CO2 in ppm, Humidity in a range of 0..100%, and Temperature in degrees Celcius, with the Temp offset applied.

Per Value is a Stats checkbox available, that when checked, gathers the data and presents recent data in a graph, as described here: Task Value Statistics:

Commands available

Command Syntax

Extra information

scd4x,storesettings
Saves the current Altitude and Temperature offset values in the sensor. After applying this command, the Device configuration for Altitude and Temp offset can be set to 0, so they won’t be reset.
scd4x,factoryreset[,resetcode]
This command resets the sensor to factory default settings.
To protect the carefully built up calibration, this command has to be applied twice, a first time to generate a reset code (output to the log at ERROR level), and a second time with that code included to actually apply the reset. This reset will take about 2.5 seconds, blocking the entire ESPEsy unit, blocking any ESPEasy operation to run during that time! so be careful when applying this command.
After successful completion, this will be written to the log at INFO level, if unsuccessful it will report on ERROR log level.
scd4x,selftest[,selftestcode]
This command will initiate a selftest of the unit, that will take up to 11 seconds to complete, blocking any ESPEasy operation to run during that time!
To protect the regular operation of ESPEasy, this command has to be applied twice, a first time to generate a selftest code (output to the log at ERROR level), and a second time with that code included to actually apply the selftest.
After successful completion, this will be written to the log at INFO level, if unsuccessful it will report on ERROR log level.
scd4x,setfrc,<co2level>
co2level range: SCD40: 400..2000 ppm, SCD41: 400..5000 ppm.
Force-reset the calibration to a specific CO2 level. This will take up to 1 second to execute, blocking any ESPEasy operation to run during that time.
Before using this command, the sensor should have been running for at least 3 minutes, to stabilize the measurements.
After successful execution, the applied correction will be logged at INFO level.

Get Config Values

Get Config Values retrieves values or settings from the sensor or plugin, and can be used in Rules, Display plugins, Formula’s etc. The square brackets are part of the variable. Replace <taskname> by the Name of the task.

Config value

Information

[<taskname>#GetAltitude]
Returns the current Altitude setting of the sensor in meters above sealevel.
[<taskname>#GetTempOffset]
Returns the current Temperature offset setting of the sensor in degrees Celcius. Includes by default 2 decimal positions, that can be adjusted using Rules: Formatting referred values.
[<taskname>#GetDataReady]
Returns 1 if new data is available at the sensor, and 0 if not.
[<taskname>#GetSelfCalibration]
Returns 1 if Automatic Self Calibration is enabled at the sensor, and 0 if not.
[<taskname>#SerialNumber]
Returns the electronic serial number of the sensor.

Change log

Changed in version 2.0:

added 2022-08-03 Initial release version.