|
Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
|
Sensirion STC31 CO2 sensor. More...
Files | |
| file | stc31.h |
| Header file for extended sensor API of STC31 sensor. | |
| file | stc31.h |
| Devicetree binding constants for the Sensirion STC31 CO2 sensor. | |
Enumerations | |
| enum | sensor_attribute_stc31 { SENSOR_ATTR_STC31_REL_HUMIDITY = SENSOR_ATTR_PRIV_START , SENSOR_ATTR_STC31_TEMPERATURE , SENSOR_ATTR_STC31_PRESSURE , SENSOR_ATTR_STC31_BINARY_GAS } |
| Custom sensor attributes for STC31. More... | |
Functions | |
| int | stc31_forced_recalibration (const struct device *dev, uint32_t reference_ppm) |
| Perform a forced recalibration (FRC). | |
| int | stc31_soft_reset (const struct device *dev) |
| Soft-reset the STC31 via I2C general call. | |
Binary gas / measurement mode | |
Values for the binary-gas devicetree property (STC31-C datasheet section 3.3.2). | |
| #define | STC31_DT_BINARY_GAS_CO2_IN_N2_100_LN 0x0000 |
| CO2 in N2, 0...100 vol% (low-noise). | |
| #define | STC31_DT_BINARY_GAS_CO2_IN_AIR_100_LN 0x0001 |
| CO2 in air, 0...100 vol% (low-noise). | |
| #define | STC31_DT_BINARY_GAS_CO2_IN_N2_25_LN 0x0002 |
| CO2 in N2, 0...25 vol% (low-noise). | |
| #define | STC31_DT_BINARY_GAS_CO2_IN_AIR_25_LN 0x0003 |
| CO2 in air, 0...25 vol% (low-noise). | |
| #define | STC31_DT_BINARY_GAS_CO2_IN_N2_100 0x0010 |
| CO2 in N2, 0...100 vol%. | |
| #define | STC31_DT_BINARY_GAS_CO2_IN_AIR_100 0x0011 |
| CO2 in air, 0...100 vol%. | |
| #define | STC31_DT_BINARY_GAS_CO2_IN_N2_40 0x0012 |
| CO2 in N2, 0...40 vol%. | |
| #define | STC31_DT_BINARY_GAS_CO2_IN_AIR_40 0x0013 |
| CO2 in air, 0...40 vol%. | |
Sensirion STC31 CO2 sensor.
Sensirion STC31 CO2 sensor.
SENSOR_CHAN_CO2 is ppm. Datasheet section 3.5.1 defines vol% as (raw - 16384) * 100 / 32768, and 1 vol% is 10000 ppm. SENSOR_CHAN_DIE_TEMP is the bulk-silicon temperature in deg C, raw / 200 (section 3.5.2).
sensor_sample_fetch() and stc31_forced_recalibration() return -EAGAIN when the previous measurement command is still inside the section 2.4 maximum period: 100 ms in low-noise mode (10 Hz) and 143 ms in low-cross-sensitivity mode (7 Hz). The driver does not sleep to extend that period. sensor_channel_get() returns -ENODATA until a sample has been fetched.
| #define STC31_DT_BINARY_GAS_CO2_IN_AIR_100 0x0011 |
#include <zephyr/dt-bindings/sensor/stc31.h>
CO2 in air, 0...100 vol%.
| #define STC31_DT_BINARY_GAS_CO2_IN_AIR_100_LN 0x0001 |
#include <zephyr/dt-bindings/sensor/stc31.h>
CO2 in air, 0...100 vol% (low-noise).
| #define STC31_DT_BINARY_GAS_CO2_IN_AIR_25_LN 0x0003 |
#include <zephyr/dt-bindings/sensor/stc31.h>
CO2 in air, 0...25 vol% (low-noise).
| #define STC31_DT_BINARY_GAS_CO2_IN_AIR_40 0x0013 |
#include <zephyr/dt-bindings/sensor/stc31.h>
CO2 in air, 0...40 vol%.
| #define STC31_DT_BINARY_GAS_CO2_IN_N2_100 0x0010 |
#include <zephyr/dt-bindings/sensor/stc31.h>
CO2 in N2, 0...100 vol%.
| #define STC31_DT_BINARY_GAS_CO2_IN_N2_100_LN 0x0000 |
#include <zephyr/dt-bindings/sensor/stc31.h>
CO2 in N2, 0...100 vol% (low-noise).
| #define STC31_DT_BINARY_GAS_CO2_IN_N2_25_LN 0x0002 |
#include <zephyr/dt-bindings/sensor/stc31.h>
CO2 in N2, 0...25 vol% (low-noise).
| #define STC31_DT_BINARY_GAS_CO2_IN_N2_40 0x0012 |
#include <zephyr/dt-bindings/sensor/stc31.h>
CO2 in N2, 0...40 vol%.
#include <zephyr/drivers/sensor/stc31.h>
Custom sensor attributes for STC31.
| Enumerator | |
|---|---|
| SENSOR_ATTR_STC31_REL_HUMIDITY | Relative humidity compensation input. Unit: RH. Datasheet section 3.5.3 encodes it as an unsigned 16-bit value, 65535 for 100 RH. Values outside 0 to 100 RH are clamped. When never set after power-up/reset, the sensor assumes 0 RH. |
| SENSOR_ATTR_STC31_TEMPERATURE | External temperature compensation input. Unit: deg C. Datasheet section 3.5.2 encodes it as a signed 16-bit value, 200 ticks per deg C. Values outside that encoding are clamped. Prefer a more accurate external sensor (e.g. SHT4x). When never set, the sensor uses its internal temperature signal. |
| SENSOR_ATTR_STC31_PRESSURE | Ambient pressure compensation input. Unit: mbar, rounded to an integer (datasheet section 3.5.4). Compensation is valid from 600 to 1500 mbar (section 3.3.5); values outside that range are rejected. When never set after power-up/reset, 1013 mbar is assumed. |
| SENSOR_ATTR_STC31_BINARY_GAS | Binary gas / measurement mode argument for command 0x3615. See :c:macro:STC31_DT_BINARY_GAS_* in :file:zephyr/dt-bindings/sensor/stc31.h. |
#include <zephyr/drivers/sensor/stc31.h>
Perform a forced recalibration (FRC).
| dev | Pointer to the sensor device |
| reference_ppm | Reference CO2 concentration in ppm (0-1000000) (converted internally to the sensor vol% encoding) |
| int stc31_soft_reset | ( | const struct device * | dev | ) |
#include <zephyr/drivers/sensor/stc31.h>
Soft-reset the STC31 via I2C general call.
Uses the I2C general call address and therefore resets every Sensirion device on the same bus that responds to it. Blocks for the sensor soft-reset time, then restores the last configured binary gas selection. RH, temperature, and pressure compensation inputs are not restored.
| dev | Pointer to the sensor device |