Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BME688 gives constant humidity and gas readings #42

Open
mihai-dinculescu opened this issue Jan 12, 2022 · 2 comments
Open

BME688 gives constant humidity and gas readings #42

mihai-dinculescu opened this issue Jan 12, 2022 · 2 comments

Comments

@mihai-dinculescu
Copy link

Using an Adafruit BME688 with version 0.6.0 of this lib and the example code, I always get constant readings for humidity and gas.
Temperature and Pressure do slightly change and seem to be correct.

FieldData { status: 176, gas_index: 0, meas_index: 0, temperature: 2222, pressure: 103645, humidity: 100000, gas_resistance: 12917167 }
@mihai-dinculescu mihai-dinculescu changed the title BME688 100% humidity and constant gas reading BME688 gives constant humidity and gas readings Jan 12, 2022
@mihai-dinculescu
Copy link
Author

Getting the same behavior with an Adafruit BME680 as well.

Here's my code.

fn main() -> anyhow::Result<()> {
    esp_idf_sys::link_patches();

    log::set_logger(&LOGGER).map(|()| LOGGER.initialize())?;
    LOGGER.set_target_level("", log::LevelFilter::Debug);

    let peripherals = Peripherals::take().context("failed to get peripherals")?;
    let pins = peripherals.pins;

    let mut delayer = delay::FreeRtos;

    let i2c_config = <i2c::config::MasterConfig as Default>::default();

    let i2c_master = i2c::Master::<i2c::I2C0, _, _>::new(
        peripherals.i2c0,
        i2c::MasterPins {
            sda: pins.gpio23,
            scl: pins.gpio22,
        },
        i2c_config,
    )?;

    let mut sensor: Bme680<_, FreeRtos> =
        Bme680::init(i2c_master, &mut delayer, I2CAddress::Secondary).unwrap();

    let settings = SettingsBuilder::new()
        .with_humidity_oversampling(OversamplingSetting::OS16x)
        .with_pressure_oversampling(OversamplingSetting::OS4x)
        .with_temperature_oversampling(OversamplingSetting::OS8x)
        .with_temperature_filter(IIRFilterSize::Size3)
        .with_gas_measurement(Duration::from_millis(1500), 320, 25)
        .with_temperature_offset(-2.2)
        .with_run_gas(true)
        .build();

    let profile_dur = sensor.get_profile_dur(&settings.0).unwrap();
    info!("Profile duration {:?}", profile_dur);

    info!("Setting sensor settings");
    sensor.set_sensor_settings(&mut delayer, settings).unwrap();

    let sensor_settings = sensor.get_sensor_settings(settings.1);
    info!("Sensor settings: {:?}", sensor_settings);

    loop {
        delayer.delay_ms(5 * 1000u32);

        let power_mode = sensor.get_sensor_mode();
        info!("Sensor power mode: {:?}", power_mode);

        info!("Setting forced power modes");
        sensor
            .set_sensor_mode(&mut delayer, PowerMode::ForcedMode)
            .unwrap();

        // Something I've tried
        // delayer.delay_ms(profile_dur.as_millis() as u32);

        // Something else I've tried
        // while sensor.get_sensor_mode().unwrap() == PowerMode::SleepMode {
        //     sensor
        //         .set_sensor_mode(&mut delayer, PowerMode::ForcedMode)
        //         .unwrap();
        // }

        let (data, _state) = sensor.get_sensor_data(&mut delayer).unwrap();
        info!("Sensor Data {:?}", data);
        info!("Temperature {}°C", data.temperature_celsius());
        info!("Pressure {}hPa", data.pressure_hpa());
        info!("Humidity {}%", data.humidity_percent());
        info!("Gas Resistence {}Ω", data.gas_resistance_ohm());
    }
}

fenax added a commit to fenax/bme680 that referenced this issue Feb 2, 2022
@haflinger
Copy link

haflinger commented Apr 14, 2023

Same behavior with and without #43 😭

Humidity seems to be correct when I remove :

.with_temperature_oversampling(OversamplingSetting::OS8x)
.with_temperature_filter(IIRFilterSize::Size3)

Any ideas ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants