co2mon 2.1.1

Driver for the Holtek ZyTemp CO₂ USB HID sensors
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use co2mon::{Result, Sensor};
use std::thread;
use std::time::Duration;

fn main() -> Result<()> {
    let sensor = Sensor::open_default()?;
    loop {
        match sensor.read() {
            Ok(reading) => println!("{:.4} °C, {} ppm CO₂", reading.temperature(), reading.co2()),
            Err(e) => eprintln!("{}", e),
        }
        thread::sleep(Duration::from_secs(5));
    }
}