2 releases
new 0.1.1 | Apr 24, 2025 |
---|---|
0.1.0 | Apr 24, 2025 |
#1981 in Embedded development
11KB
214 lines
Rust SDS011 driver no_std environments compatible
This library provide an interface of the SDS011 air quality sensor using asynchronous I/O traits compatible with no_std environments.
Getting started
Below is an example demonstrating how to initialize the SDS011 sensor, set it up, and read air quality data from it:
#![no_std]
// ...
use sds011_nostd_rs::Sds011
// ...
let uart = ...
// Initialize the sensor configuration
let config = Config {
id: DeviceID {
id1: 0xFF,
id2: 0xFF,
},
mode: DeviceMode::Passive,
};
// Create a new instance of the sensor
let mut sds011 = Sds011::new(uart, config);
// Initialize the sensor
sds011.init().await.unwrap();
// Read a sample from the sensor
let sample = sds011.read_sample().await.unwrap();
// Print the sample values
println!("PM2.5: {} µg/m³, PM10: {} µg/m³", sample.pm2_5, sample.pm10);
Example
Example implementation of this library on a esp32 chip can be found in the etiennetremel/esp32-home-sensor repository.
References
Dependencies
~135KB