10 releases (5 breaking)
0.6.1 | Feb 3, 2024 |
---|---|
0.6.0 | Jan 24, 2024 |
0.5.1 | Jan 2, 2024 |
0.4.1 | Dec 29, 2023 |
0.1.2 | Sep 29, 2022 |
#493 in Embedded development
89 downloads per month
19KB
357 lines
ENS160 driver
Implementation of an ENS160 sensor driver written in rust. This sensor can measure TVOC
and ECO2
. Implementation is inspired by the driver implementation by dfrobots written in python.
For more information about the sensor here.
Usage
To use this crate in a no-std
environment, add it to your Cargo.toml
as follows:
[dependencies.ens160]
version = "0.6"
default-features = false
Example
let i2c = ...; // I2C bus to use
let mut device = Ens160::new(i2c);
device.reset().unwrap();
sleep(250)
device.operational().unwrap();
sleep(50)
loop {
if let Ok(status) = device.status() {
if status.data_is_ready() {
let tvoc = device.tvoc().unwrap();
let eco2 = device.eco2().unwrap();
// from eCO2
let air_quality_index = AirQualityIndex::try_from(eco2).unwrap();
// directly
let air_quality_index = device.air_quality_index().unwrap();
}
}
}
let i2c = device.release(); // destruct driver to use bus with other drivers
Dependencies
~1.5MB
~38K SLoC