scd30_interface/
lib.rs

1//! # SCD30 Driver
2//!
3//! A driver for interacting with Sensirion's [SCD30](https://sensirion.com/products/catalog/SCD30)
4//! CO2 measuring sensor via I2C. This driver is based on
5//! [embedded-hal](https://docs.rs/embedded-hal/latest/embedded_hal/) traits.
6//!
7//! # Example
8//!
9//! ```ignore
10//! use scd30_interface::blocking::Scd30;
11//! use scd30_interface::data::DataStatus;
12//! use esp_hal::i2c::master::{Config, I2c};
13//! use dfmt;
14//!
15//! #[entry]
16//! fn main() {
17//!     let peripherals = esp_hal::init(esp_hal::Config::default());
18//!
19//!     let i2c = I2c::new(peripherals.I2C0, Config::default())
20//!         .with_sda(peripherals.GPIO4)
21//!         .with_scl(peripherals.GPIO5);
22//!
23//!     let sensor = Scd30::new(i2c);
24//!
25//!     // Read out firmware version
26//!     let firmware_version = sensor.read_firmware_version().unwrap();
27//!
28//!     loop {
29//!         while sensor.is_data_ready() != DataStatus::Ready {}
30//!         let measurement = sensor.read_measurement().unwrap();
31//!         dfmt::log!("{}", measurement);
32//!     }
33//! }
34//! ```
35
36#![cfg_attr(not(test), no_std)]
37#![forbid(unsafe_code)]
38#![deny(missing_docs)]
39
40pub mod command;
41pub mod data;
42pub mod error;
43mod interface;
44mod util;
45
46#[cfg(feature = "blocking")]
47/// Blocking interface for the SCD30
48pub use interface::blocking;
49
50#[cfg(feature = "async")]
51/// Async interface for the SCD30
52pub use interface::asynch;