# scd41-embedded
A platform-agnostic, `no_std` driver for the **Sensirion SCD41** CO₂ / temperature / humidity sensor, built on the [`embedded-hal`](https://crates.io/crates/embedded-hal) traits.
This crate provides:
- Blocking (synchronous) API using `embedded-hal` 1.0 (`I2c` + `DelayNs`)
- Optional **async I2C + delay API** behind the `async` feature using `embedded-hal-async`
## Features
- `async`: enables async I2C + delay support via `embedded-hal-async`.
## Blocking example
```rust,ignore
use scd41_embedded::Scd41;
# let i2c = todo!("provide an embedded-hal I2C implementation");
# let delay = todo!("provide an embedded-hal DelayNs implementation");
let mut scd = Scd41::new(i2c, delay);
scd.start_periodic_measurement()?;
loop {
if scd.data_ready()? {
let m = scd.measurement()?;
// m.co2_ppm, m.temperature_c, m.relative_humidity_percent
break;
}
}
# Ok::<(), scd41_embedded::Error<_>>(())
```
## Async example
Enable the feature:
```toml
[dependencies]
scd41-embedded = { version = "0.1", features = ["async"] }
```
```rust,ignore
use scd41_embedded::r#async::Scd41Async;
# let i2c = todo!("provide an embedded-hal-async I2C implementation");
# let delay = todo!("provide an embedded-hal-async DelayNs implementation");
let mut scd = Scd41Async::new(i2c, delay);
scd.start_periodic_measurement().await?;
loop {
if scd.data_ready().await? {
let m = scd.measurement().await?;
break;
}
}
# Ok::<(), scd41_embedded::Error<_>>(())
```
## License
MIT