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

Use correct value to compute gas resistance #56

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

patcher-ms
Copy link
Contributor

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

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:
```C
    /* 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
@tannewt tannewt requested a review from caternuson December 15, 2022 17:15
@caternuson
Copy link
Contributor

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?

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me as well after reviewing the arduino code and original bosch c code that is linked.

It seems like we may not get a response about the means of discovering this, but I'm thinking it's okay to go ahead get it merged.

@FoamyGuy FoamyGuy merged commit 19775f6 into adafruit:main Aug 7, 2023
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Aug 8, 2023
Updating https://github.com/adafruit/Adafruit_CircuitPython_BME680 to 3.6.0 from 3.5.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_BME680#56 from patcher-ms/patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad to 1.18.0 from 1.17.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#71 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_USB_Host_Descriptors

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
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

Successfully merging this pull request may close these issues.

3 participants