Switch to fork with CO2 level target get & set
This commit is contained in:
parent
d6213d2498
commit
8b923b8a8b
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -2000,8 +2000,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "scd4x"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "550fedc97e7880654aa7dc840f5eb3b2201a01aae566c4584a3601bb0086cd4c"
|
||||
source = "git+https://github.com/twokilohertz/scd4x-rs.git?branch=self-calib-tgt#3ec7b975b32ed8ec47c71ecee3711f430871bd2e"
|
||||
dependencies = [
|
||||
"embedded-hal 1.0.0",
|
||||
"log",
|
||||
|
@ -44,7 +44,7 @@ embedded-graphics = "0.8.1"
|
||||
embedded-graphics-framebuf = "0.5.0"
|
||||
|
||||
# Peripherals
|
||||
scd4x = { version = "0.4.0", features = ["scd41"] }
|
||||
scd4x = { git = "https://github.com/twokilohertz/scd4x-rs.git", branch = "self-calib-tgt", features = ["scd41"] }
|
||||
ssd1351 = "0.5.0"
|
||||
display-interface-spi = "0.5.0"
|
||||
|
||||
|
@ -8,11 +8,15 @@ use scd4x::Scd4x;
|
||||
|
||||
use crate::{I2c0BusMutex, SENSOR_DATA_SIGNAL};
|
||||
|
||||
const BACKGROUND_CO2_PPM: u16 = 427;
|
||||
|
||||
/// Read CO2/temp./humidity data from the sensor
|
||||
#[embassy_executor::task]
|
||||
pub async fn sensor_read_task(i2c_bus: &'static I2c0BusMutex) {
|
||||
debug_rprintln!("Sensor read task started");
|
||||
|
||||
// Initialise SCD41
|
||||
|
||||
Timer::after_millis(30).await; // SCD41 power-up delay
|
||||
let i2c_dev = I2cDevice::new(i2c_bus);
|
||||
|
||||
@ -20,6 +24,11 @@ pub async fn sensor_read_task(i2c_bus: &'static I2c0BusMutex) {
|
||||
scd41.wake_up();
|
||||
scd41.reinit().unwrap();
|
||||
|
||||
// https://climate.nasa.gov/vital-signs/carbon-dioxide/?intent=121
|
||||
scd41
|
||||
.set_automatic_self_calibration_target(BACKGROUND_CO2_PPM)
|
||||
.unwrap();
|
||||
|
||||
match scd41.serial_number() {
|
||||
Ok(serial) => debug_rprintln!("[SCD41] Serial number: {}", serial),
|
||||
Err(error) => debug_rprintln!(
|
||||
@ -28,6 +37,8 @@ pub async fn sensor_read_task(i2c_bus: &'static I2c0BusMutex) {
|
||||
),
|
||||
}
|
||||
|
||||
// Measurement loop
|
||||
|
||||
scd41.start_periodic_measurement().unwrap();
|
||||
|
||||
loop {
|
||||
@ -53,4 +64,6 @@ pub async fn sensor_read_task(i2c_bus: &'static I2c0BusMutex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scd41.stop_periodic_measurement().unwrap();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user