ENS160-AQ
A Rust crate for ScioSense ENS160 air quality sensor
https://github.com/marvinrobot42/ens160-aq.git
A benefit of using the ENS160 is the combined air quality index is calculated within the device, no external proprietary calculation programme is required.
Features
-
updated to use embedded-hal version 1.0.x
-
designed for embedded use (ESP32-C3, -C6 and -S3 and STM32F3DISCOVERY)
-
configurable interrupt pin
-
supports both 0x52 (default) and 0x53 (secondary) I2C device addresses
-
set temperature and humidity for ENS160 compensation calulation
-
reads air quality index, eCO2, TVOC, ethanol concentration and raw hot plate resistance (in ohms)
-
an easy to use Measurements struct
-
an easy to use initialize function
-
no_std embedded compatible
-
(SPI not supported, yet)
Notes
This is my first device driver project. I was inspired by Alexander Hübener's excellent ENS160 crate.
Recent version history
- 0.2.7 added Raspberry Pi example
- 0.2.6 fixed README.MD
- 0.2.5 added more documentation comments
- 0.2.2 fixed small bug in InterruptPinConfig, added build() method which just returns the .0 property as u8. Updated the examples/airquality.rs file
Usage
Add the dependency to Cargo.toml
.
[]
= "0.2"
Create an Ens160 struct from an I²C interface and a delay function.
Configure interrupt pin properties if required.
Initialize ENS160.
set_temp_rh_comp() can be called anytime for temperature and humidity compensation.
Read the ENS160 status and check if new data or group data (if needed) is ready
then get_measurements(). Or you can get ECO2 or TVOC or air quality index separately.
Note that set_operation_mode(OperationMode::Reset) is available but it will put the ENS160
back to factory defaults including the 24 hour "burn-in" mode. It does not need to be called
for any other reason.
Simple Example
A more complete example is in the repository examples path
use ;
use Ens160;
...
License
You are free to copy, modify, and distribute this application with attribution under the terms of either
- Apache License, Version 2.0 (LICENSE-Apache-2.0 or https://opensource.org/licenses/Apache-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
This project is not affiliated with nor endorsed in any way by ScioSense.