1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2024, F. Stan
//
// Licensed under the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>,
// This file may not be copied, modified, or distributed
// except according to those terms.
//! SCD30 trait implementing basic SCD30 I2C CO2 sensor operations
//!
//! Operations taken from [interface description](https://sensirion.com/media/documents/D7CEEF4A/6165372F/Sensirion_CO2_Sensors_SCD30_Interface_Description.pdf)
//! At current version 1.0.0 we support all basic operations from the interface
//! ## Basic Example
//!
//! Obtaining measurements, co2, temperature and humidity
//!
//!
//!```
//!use scd30_i2c::scd30::Scd30;
//!use std::thread;
//!use std::time::Duration;
//!
//!fn main() {
//! // Open the I2C device
//! let mut scd = Scd30::new().unwrap();
//! let mut counter = 0;
//! scd.trigger_cont_measurements();
//!
//! scd.set_measurements_interval(2);
//!
//! loop {
//! match scd.get_measurements() {
//! Ok((a, b, c)) => {
//! println!("Co2: {} ppm Temp: {} C RH: {} %", a, b, c);
//! thread::sleep(Duration::from_secs(2));
//! counter += 1;
//! println!("{}", counter);
//! }
//! Err(e) => {
//! println!(
//! "Error obtaining measurements. More details: {}. Waiting 10 seconds for recovering",
//! e
//! );
//! thread::sleep(Duration::from_secs(10));
//! }
//! }
//! }
//!}
//!```
//!
/// Trait implementing SCD30 device related operations