trvrnrth / esphome-bsec-bme680

ESPHome component for the Bosch BME680 sensor via BSEC providing temperature, humidity, pressure and indoor air quality measurements.
85 stars 17 forks source link

bme688 fails #50

Closed michaelm-github closed 2 years ago

michaelm-github commented 2 years ago

With a bme688, gas resistance stays at 12946860, the initialization value.

gretel commented 2 years ago

same issue here.

image

@trvrnrth be cool if we could work this out! maybe also work on https://github.com/esphome/feature-requests/issues/1332? regards

awstanley commented 2 years ago

Not sure if this is of any help/use to anyone, but in programming it away from the ESPHome environment I run self-test from the standard API as part of the initalisation. The self-test soft resets the system and the gas resistance works; without the self-test the gas resistance can get stuck on both the common Arduino library and using the BME68x driver BoschSensorTec's github provides.

The bigger issue to consider with the BME688 is t_fine needs to be set in most instances as even sensors from the same batch are different (beyond what the specifications sheet might indicate). This becomes more important if you're looking to support custom gas resistance values (without using BSEC) as self-heating in different enclosures can create issues. It's unlikely that this is the underlying cause of the gas resistance freezing, and it's more likely something weird going on with soft resets or calibration data needing to be reset under certain circumstances.

Edit: The t_fine offset won't impact you if you're using the stock library, you can just apply the offset later. Calibrating for that is its own fun, but a single point calibration is probably enough.

awstanley commented 2 years ago

Quick update on the above: the self-test fixes missing bits related to the BME688 instead of the BME680 (which for some reason I wrote in my self-test but not in the core; the same seems to fix a 'stuck' Arduino install though, so I'm not sure what's happening). It's possible there's something similar happening here. The most likely issue is run_gas is set to 1 (as per the BME680) insetad of 2 (as per the BME688).

https://github.com/trvrnrth/esphome-bsec-bme680/blob/master/components/bme680_bsec/bme680_bsec.cpp#L194

My second guess would be the BSEC version being used doesn't support BME688, as the BME68X library calls bme68x_init and internally this code is using bme680_init. (Not using BSEC due to using ESP32-C3s I'm not sure.) Hopefully that helps.

I've just finished patching the normal BME680 component as an external to run more tests on, and these were the bits I nailed down. (My ESP-IDF code works, but getting it into ESPHome was the aim.)

Edit: The self-test using the standard library, and even my code, fixes the issue of a 'stuck' sensor (which is temporarily stuck but a long/full power cycle fixes). The soft reset seems to be insufficient to fix that (for whatever reason). I'm probably still missing something.

trvrnrth commented 2 years ago

I'm going to close this out in favour of the discussion/work over at https://github.com/esphome/feature-requests/issues/1332. I'm afraid I have neither the devices (nor really the time) to provide any useful input myself at this point.