adafruit / Adafruit_CircuitPython_BME680

CircuitPython driver for BME680
MIT License
57 stars 40 forks source link

Pressure value wrong #13

Closed robert-hh closed 5 years ago

robert-hh commented 5 years ago

The pressure values are slightly wrong. They are about 10hPa too high, compared against calibrated device and other implementations. The reason is a wrong code. Lines 192-194 should be:

        var1 = (((((var1 / 4) * (var1 / 4)) / 8192) *
                (self._pressure_calibration[2] * 32) / 8) +
                ((self._pressure_calibration[1] * var1) / 2))

Compared against the Bosch reference code. After the change, the result matches the reference pressure value substantially better and also matches other implementations. P.S.: I should note that the humidity reading of my Adafruit sensor are completely wrong, 83.3% instead of 75.5% over a saturated NaCl solution, and that with every driver I tried. I had that with a BME280 too. After re-conditioning, the situation improved.

caternuson commented 5 years ago

Bosch API for ref: https://github.com/BoschSensortec/BME680_driver/blob/e6b9bbade923d792d9ccd822ab5fada99bf40501/bme680.c#L908

Looks like the problem is due to splitting the computation into two lines. https://github.com/adafruit/Adafruit_CircuitPython_BME680/blob/master/adafruit_bme680.py#L192 which will use an updated var1 for the second part of the computation.

What is the "re-conditioning" you mention for the humidity reading?

robert-hh commented 5 years ago

Yes, this updated var1 was the problem. Reconditioning is documented by Bosch as:

  1. Dry-baking at 125 °C and <5% r.H. for 6 hours
  2. Re-hydration at 25 °C and 80% r.H. for 24 hours
  3. Rest period for one hour at room temperature or alternatively
  4. Do not perform Dry-Baking
  5. Ambient Re-Hydration: 25 °C at >50% rH for >5d See also: https://ae-bst.resource.bosch.com/media/_tech/media/application_notes/BST-BME680-HS000-05.pdf, Section 5. The alternative method never worked for me. The first one can easily achieved with an electric kitchen oven (no gas) for step 1 and the air above a saturated sodium chloride solution for step 2, which gives 75.5%, if you take stuff right at hand. If you need exactly 80%, look here: https://nvlpubs.nist.gov/nistpubs/jres/81A/jresv81An1p89_A1b.pdf
robert-hh commented 5 years ago

For convenience, I made a PR for that. https://github.com/adafruit/Adafruit_CircuitPython_BME680/pull/14 P.S.: The re-conditioning worked. Humidity readings are now withing the specs.