Line data Source code
1 1 : /*
2 : * Copyright (c) 2024 Jan Fäh
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /**
8 : * @file
9 : * @brief Header file for extended sensor API of SCD4X sensor
10 : * @ingroup scd4x_interface
11 : */
12 :
13 : #ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_SCD4X_H_
14 : #define ZEPHYR_INCLUDE_DRIVERS_SENSOR_SCD4X_H_
15 :
16 : /**
17 : * @brief Sensirion SCD4X CO<sub>2</sub> sensor
18 : * @defgroup scd4x_interface SCD4X
19 : * @ingroup sensor_interface_ext
20 : * @{
21 : */
22 :
23 : #include <zephyr/drivers/sensor.h>
24 :
25 : /**
26 : * @brief Custom sensor attributes for SCD4X
27 : */
28 1 : enum sensor_attribute_scd4x {
29 : /**
30 : * Temperature offset
31 : *
32 : * @f[
33 : * T_{offset\_actual} = T_{scd4x} - T_{reference} + T_{offset\_previous}
34 : * @f]
35 : *
36 : * 0 - 20°C
37 : */
38 : SENSOR_ATTR_SCD4X_TEMPERATURE_OFFSET = SENSOR_ATTR_PRIV_START,
39 : /**
40 : * Altitude of the sensor
41 : *
42 : * 0 - 3000m
43 : */
44 : SENSOR_ATTR_SCD4X_SENSOR_ALTITUDE,
45 : /**
46 : * Ambient pressure in hPa
47 : *
48 : * 700 - 1200hPa
49 : */
50 : SENSOR_ATTR_SCD4X_AMBIENT_PRESSURE,
51 : /**
52 : * Automatic calibration enable (enabled: 1 / disabled: 0).
53 : *
54 : * Default: enabled.
55 : */
56 : SENSOR_ATTR_SCD4X_AUTOMATIC_CALIB_ENABLE,
57 : /**
58 : * Initial period for automatic self calibration correction (in hours).
59 : *
60 : * Allowed values are integer multiples of 4 hours.
61 : * Default: 44
62 : */
63 : SENSOR_ATTR_SCD4X_SELF_CALIB_INITIAL_PERIOD,
64 : /**
65 : * Standard period for automatic self calibration correction (in hours).
66 : *
67 : * Allowed values are integer multiples of 4 hours.
68 : * Default: 156
69 : */
70 : SENSOR_ATTR_SCD4X_SELF_CALIB_STANDARD_PERIOD,
71 : };
72 :
73 : /**
74 : * @brief Performs a forced recalibration.
75 : *
76 : * Operate the SCD4x in the operation mode for at least 3 minutes in an environment with a
77 : * homogeneous and constant CO2 concentration. Otherwise the recalibratioin will fail. The sensor
78 : * must be operated at the voltage desired for the application when performing the FRC sequence.
79 : *
80 : * @param dev Pointer to the sensor device
81 : * @param target_concentration Reference CO2 concentration.
82 : * @param frc_correction Previous differences from the target concentration
83 : *
84 : * @return 0 if successful, negative errno code if failure.
85 : */
86 1 : int scd4x_forced_recalibration(const struct device *dev, uint16_t target_concentration,
87 : uint16_t *frc_correction);
88 :
89 : /**
90 : * @brief Performs a self test.
91 : *
92 : * The self_test command can be used as an end-of-line test to check the sensor functionality
93 : *
94 : * @param dev Pointer to the sensor device
95 : *
96 : * @return 0 if successful, negative errno code if failure.
97 : */
98 1 : int scd4x_self_test(const struct device *dev);
99 :
100 : /**
101 : * @brief Performs a self test.
102 : *
103 : * The persist_settings command can be used to save the actual configuration. This command
104 : * should only be sent when persistence is required and if actual changes to the configuration have
105 : * been made. The EEPROM is guaranteed to withstand at least 2000 write cycles
106 : *
107 : * @param dev Pointer to the sensor device
108 : *
109 : * @return 0 if successful, negative errno code if failure.
110 : */
111 1 : int scd4x_persist_settings(const struct device *dev);
112 :
113 : /**
114 : * @brief Performs a factory reset.
115 : *
116 : * The perform_factory_reset command resets all configuration settings stored in the EEPROM and
117 : * erases the FRC and ASC algorithm history.
118 : *
119 : * @param dev Pointer to the sensor device
120 : *
121 : * @return 0 if successful, negative errno code if failure.
122 : */
123 1 : int scd4x_factory_reset(const struct device *dev);
124 :
125 : /**
126 : * @}
127 : */
128 :
129 : #endif /* ZEPHYR_INCLUDE_DRIVERS_SENSOR_SCD4X_H_ */
|