adafruit / Adafruit_CircuitPython_BME680

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

Use correct value to compute gas resistance #56

Closed patcher-ms closed 1 year ago

patcher-ms commented 1 year ago

This code is supposed to be a 1:1 translation from Bosch C library https://github.com/boschsensortec/BME68x-Sensor-API/blob/6dab330cb5727006d5046f9eebf357f8909c0ef6/bme68x.c#L971.

There they do:

    /* multiplying 10000 then dividing then multiplying by 100 instead of multiplying by 1000000 to prevent overflow */
    calc_gas_res = (UINT32_C(10000) * var1) / (uint32_t)var2;
    calc_gas_res = calc_gas_res * 100;

With the current code resistance is off by a factor of 10

caternuson commented 1 year ago

Agree that sure looks like a typo. And 10000 is being used in the Arduino library as well: https://github.com/adafruit/Adafruit_BME680/blob/29897a675e3102ae8e5a329e58377a4efdb36c3b/bme68x.c#L971

Not seeing the factor of 10 being accounted for elsewhere.

Was this discovered by just code inspection? Or did you notice bad values when using the library?