File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,20 @@ int16_t scd4x_read_measurement_raw(uint16_t* co2_concentration,
159
159
return local_error ;
160
160
}
161
161
162
+ int16_t scd4x_read_measurement (uint16_t * co2 , int32_t * temperature_m_deg_c ,
163
+ int32_t * humidity_m_percent_rh ) {
164
+ int16_t error ;
165
+ uint16_t temperature ;
166
+ uint16_t humidity ;
167
+ error = scd4x_read_measurement_raw (co2 , & temperature , & humidity );
168
+ if (error ) {
169
+ return error ;
170
+ }
171
+ * temperature_m_deg_c = ((21875 * (int32_t )temperature ) >> 13 ) - 45000 ;
172
+ * humidity_m_percent_rh = ((12500 * (int32_t )humidity ) >> 13 );
173
+ return NO_ERROR ;
174
+ }
175
+
162
176
int16_t scd4x_stop_periodic_measurement () {
163
177
int16_t local_error = NO_ERROR ;
164
178
uint8_t * buffer_ptr = communication_buffer ;
Original file line number Diff line number Diff line change @@ -195,6 +195,21 @@ int16_t scd4x_read_measurement_raw(uint16_t* co2_concentration,
195
195
uint16_t * temperature ,
196
196
uint16_t * relative_humidity );
197
197
198
+ /**
199
+ * @brief Read sensor output and convert to pyhsical unit.
200
+ *
201
+ * See @ref scd4x_read_measurement_raw() for more details.
202
+ *
203
+ * @param[out] co2 CO₂ concentration in ppm
204
+ * @param[out] temperature_m_deg_c Temperature in milli degrees celsius (°C *
205
+ * 1000)
206
+ * @param[out] humidity_m_percent_rh Relative humidity in milli percent RH
207
+ * (%RH * 1000)
208
+ * @return 0 on success, an error code otherwise
209
+ */
210
+ int16_t scd4x_read_measurement (uint16_t * co2 , int32_t * temperature_m_deg_c ,
211
+ int32_t * humidity_m_percent_rh );
212
+
198
213
/**
199
214
* @brief Stop periodic measurement to change the sensor configuration or to
200
215
* save power.
You can’t perform that action at this time.
0 commit comments