[SOLVED]Example BME650 CubeCell Board BUG for value GAS


while testing the BME650 i found that the Third Party Sensor Example “BME650test” by ARND@SV-Zanshin shows every time the same value for GAS.

The same hardware testet with the Adafruit Library (Arduino Mega) shows valid values:

Temperature = 23.94 *C
Pressure = 1008.65 hPa
Humidity = 36.11 %
Gas = 134.76 KOhms
Approx. Altitude = 38.54 m

The Adarfuit Library could not be compiled with the CubeCell-Board:
error: redefinition of ‘class SPIClass’

Has sameone solved the problem?



What you see is normal if you power down the bme680 between measurements.
You have to save the baseline after the reading and restore it after repower.

You can take a look in the LoRaWAN Multisensor example for the functions used for stpring and restoring the baseline.

When i have time tomorrow i will upload a new bme680 example with baseline storing

1 Like

Hello WASN,

thank yor for the quick response! :grinning:


So, i have testet it with the Arduino core 0.0.6, there ist no change.

The example “BME_test” in the Folder Example\ Third Party Sensor Examples doesn’t work for the value gas. There ist every time the same value, and there ist no sleep during measurement.

Copyright @ 2019 Heltec Automation.All rights reserved.
Starting I2CDemo example program for BME680

  • Initializing BME680 sensor
  • Setting 16x oversampling for all sensors
  • Setting IIR filter to a value of 4 samples
  • Setting gas measurement to 320°C for 150ms

24.54°C 38.92%Hum 1010.40hPa 23.76m 8083.70mOhm
26.00°C 36.28%Hum 1010.32hPa 24.42m 8083.70mOhm
25.99°C 36.26%Hum 1010.34hPa 24.26m 8083.70mOhm
25.99°C 36.33%Hum 1010.34hPa 24.26m 8083.70mOhm
25.97°C 36.60%Hum 1010.32hPa 24.42m 8083.70mOhm
25.97°C 36.95%Hum 1010.34hPa 24.26m 8083.70mOhm
25.99°C 37.30%Hum 1010.34hPa 24.26m 8083.70mOhm
25.98°C 37.62%Hum 1010.34hPa 24.26m 8083.70mOhm
25.98°C 37.88%Hum 1010.34hPa 24.26m 8083.70mOhm



Forget my last post. Baseline us only important for the css811 sensor.
Had no time to test. Hope to find some time next week

i have uploaded a new BME680 library version to the Heltec Github repository.

the gas value read failure should be fixed by that

1 Like

Thank you very much!


perhaps you are interested in caculating the IAQ:

float CalculateIAQ(float gas, float humidity)
  float hum_weighting = 0.25; // so hum effect is 25% of the total air quality score
  float gas_weighting = 0.75; // so gas effect is 75% of the total air quality score
  float hum_score, gas_score;
  float gas_reference = gas;
  float hum_reference = 40;
  int getgasreference_count = 0;

  //Calculate humidity contribution to IAQ index

  if (humidity >= 38 && humidity <= 42)
    hum_score = 0.25 * 100; // Humidity +/-5% around optimum
  { //sub-optimal
    if (humidity < 38)
      hum_score = 0.25 / hum_reference * humidity * 100;
      hum_score = ((-0.25 / (100 - hum_reference) * humidity) + 0.416666) * 100;

  //Calculate gas contribution to IAQ index

  float gas_lower_limit = 10000;  // Bad air quality limit
  float gas_upper_limit = 100000; // Good air quality limit

  if (gas_reference > gas_upper_limit)
    gas_reference = gas_upper_limit;
  if (gas_reference < gas_lower_limit)
    gas_reference = gas_lower_limit;

  gas_score = (0.75 / (gas_upper_limit - gas_lower_limit) * gas_reference - (gas_lower_limit * (0.75 / (gas_upper_limit - gas_lower_limit)))) * 100;

  //Combine results for the final IAQ index value (0-100% where 100% is good quality air)

  float air_quality_score = hum_score + gas_score;

  return air_quality_score;

Thank you!

Great, that would have been my next task

Kind regards

Hello WASN,

i tested the code, but for me the values ar not plausible.

The IAQ-value is a number between 1 and 500, described in the datasheet BME680.

Here the result:
-13556.46 IAQ
24.28°C 32.70%Hum 1014.33hPa -9.15m 624.87mOhm
-13538.76 IAQ
24.28°C 32.67%Hum 1014.33hPa -9.15m 635.78mOhm
-13526.60 IAQ
24.29°C 32.65%Hum 1014.35hPa -8.99m 647.08mOhm
-13515.24 IAQ
24.29°C 32.62%Hum 1014.35hPa -8.99m 652.62mOhm
-13505.62 IAQ
24.29°C 32.60%Hum 1014.35hPa -8.99m 664.53mOhm
-13495.46 IAQ
24.29°C 32.57%Hum 1014.35hPa -8.99m 672.00mOhm
-13482.75 IAQ
24.29°C 32.56%Hum 1014.33hPa -8.82m 682.96mOhm
-13475.17 IAQ
24.29°C 32.54%Hum 1014.33hPa -8.99m 693.71mOhm

Kind regards

the function i posted does the calculation not like bosh do it.

it will give a range of 0-100% 100% for perfect air (see source)

but you have to change this for your usage:L

float gas_lower_limit = 10000;  // Bad air quality limit
float gas_upper_limit = 100000; // Good air quality limit

Hello WASN, thank you for the quick answer.

I will play with the values.

Kind regards