| Crates.io | sds011-nostd-rs |
| lib.rs | sds011-nostd-rs |
| version | 0.3.0 |
| created_at | 2025-04-24 19:31:36.927213+00 |
| updated_at | 2025-05-19 14:26:38.961542+00 |
| description | An nostd async library to interact with the SDS011 sensor using UART protocol |
| homepage | https://github.com/etiennetremel/sds011-nostd-rs |
| repository | https://github.com/etiennetremel/sds011-nostd-rs |
| max_upload_size | |
| id | 1647735 |
| size | 46,599 |
This library provide an interface of the SDS011 air quality sensor using asynchronous I/O traits compatible with no_std environments.
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 implementation of this library on a esp32 chip can be found in the etiennetremel/esp32-home-sensor repository.