add a delay before reading

This commit is contained in:
Denis-Cosmin Nutiu 2024-11-21 00:13:28 +02:00
parent 312a079979
commit ddbd11561a
2 changed files with 3 additions and 1 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "bme680-json" name = "bme680-json"
version = "1.0.0" version = "1.0.1"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View file

@ -2,6 +2,7 @@ use bme680::i2c::Address;
use bme680::{Bme680, IIRFilterSize, OversamplingSetting, PowerMode, SettingsBuilder}; use bme680::{Bme680, IIRFilterSize, OversamplingSetting, PowerMode, SettingsBuilder};
use core::time::Duration; use core::time::Duration;
use clap::Parser; use clap::Parser;
use embedded_hal::delay::DelayNs;
use linux_embedded_hal as hal; use linux_embedded_hal as hal;
use linux_embedded_hal::Delay; use linux_embedded_hal::Delay;
@ -42,6 +43,7 @@ fn main() -> Result<(), anyhow::Error> {
dev.set_sensor_settings(&mut delay, &settings)?; dev.set_sensor_settings(&mut delay, &settings)?;
dev.set_sensor_mode(&mut delay, PowerMode::ForcedMode)?; dev.set_sensor_mode(&mut delay, PowerMode::ForcedMode)?;
Delay {}.delay_ms(5000u32);
let (data, _) = dev.get_measurement(&mut delay)?; let (data, _) = dev.get_measurement(&mut delay)?;
let serialized = serde_json::to_string(&JsonData{ let serialized = serde_json::to_string(&JsonData{
temperature: data.temperature_celsius(), temperature: data.temperature_celsius(),