| Crates.io | scd30pi |
| lib.rs | scd30pi |
| version | 1.0.0 |
| created_at | 2021-03-02 15:08:39.099062+00 |
| updated_at | 2025-12-16 14:47:27.293478+00 |
| description | Interfaces the SCD30 i2c CO2, temperature and humidity sensor from Sensirion for Raspberry Pi |
| homepage | |
| repository | https://github.com/crisobal/scd30pi |
| max_upload_size | |
| id | 362719 |
| size | 28,597 |
This is yet another implementation of a Sensirion SCD30 i2c sensor driver in pure rust. The sensor measures CO2, temperature and humidity.
The sensor documentation can be obtained directly from Sensirion: https://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/9.5_CO2/Sensirion_CO2_Sensors_SCD30_Interface_Description.pdf
The target platform is a Raspberry pi so either you compile it on an rpi or use crosscompiling. It is based on Raspberry Pi Peripheral Access Library (https://crates.io/crates/rppal). The physical SCD30 connection to i2c can be done by wiring the device to the first i2c ports of the GPIO connector.
Connect to RaspberryPi GPIO:
use scd30pi::i2c::SCD30;
use std::{thread, time};
fn main() {
let mut sensor = SCD30::from_default_device().unwrap();
let speed = sensor.get_bus_speed().unwrap();
println!("bus Speed: {}", speed);
sensor.start().unwrap();
sensor.set_measure_interval(2).unwrap();
let version = sensor.read_firmware_version().unwrap();
println!("Current firmware version {}", version);
while !sensor.data_available().unwrap() {
thread::sleep(time::Duration::from_millis(200));
}
let temperature = sensor.temperature().unwrap();
let co2 = sensor.co2().unwrap();
let humidity = sensor.humidity().unwrap();
println!(
"co2 = {:.0} ppm, temp = {:.2} °C, humidity = {:.0} %",
co2, temperature, humidity
);
}
cross build --target=aarch64-unknown-linux-gnu --release