Expand description
Platform agnostic Rust driver for Sensirion SVM40 device with
gas, temperature and humidity sensors based on
the embedded-hal
traits.
§Sensirion SVM40
Sensirion SGPC3 is a low-power accurate gas sensor for air quality application. The sensor has different sampling rates to optimize power-consumption per application bases as well as ability save and set the baseline for faster start-up accuracy. The sensor uses I²C interface and measures TVOC (Total Volatile Organic Compounds)
Evaluation board: https://www.sensirion.com/cn/environmental-sensors/evaluation-kit-sek-svm40/
§Usage
§Instantiating
Import this crate and an embedded_hal
implementation, then instantiate
the device:
use linux_embedded_hal as hal;
use hal::{Delay, I2cdev};
use svm40::Svm40;
fn main() {
let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut sgp = Svm40::new(dev, 0x6a, Delay);
}
§Doing Measurements
The device is doing measurements independently of the driver and calls to the device will just fetch the latest information making the usage easy.
use linux_embedded_hal as hal;
use hal::{Delay, I2cdev};
use std::time::Duration;
use std::thread;
use svm40::Svm40;
fn main() {
let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut sensor = Svm40::new(dev, 0x6A, Delay);
let version = sensor.version().unwrap();
println!("Version information {:?}", version);
let mut serial = [0; 26];
sensor.serial(&mut serial).unwrap();
println!("Serial {:?}", serial);
sensor.start_measurement().unwrap();
thread::sleep(Duration::new(2_u64, 0));
for _ in 1..20 {
let signals = sensor.get_measurements().unwrap();
println!("Measurements: {:?}", signals);
thread::sleep(Duration::new(1_u64, 0));
let signals = sensor.get_raw_measurements().unwrap();
println!("Measurements: {:?}", signals);
thread::sleep(Duration::new(1_u64, 0));
}
sensor.stop_measurement().unwrap();
}
Structs§
- RawSignals
- Raw signal measurement. Raw signals include the standard signals.
- Signals
- Standard signal measurement
- Svm40
- Svm40 main driver to manipulate the sensor
- Version
- Version information structure
Enums§
- Error
- Svm40 errors