Adafruit BME680 Accuracy Questions

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
sdrocker
 
Posts: 32
Joined: Mon Apr 24, 2017 6:45 pm

Adafruit BME680 Accuracy Questions

Post by sdrocker »

Hi,

I've been evaluating the Adafruit BME680 sensor with a Raspberry Pi Pico and have been trying to compare readings to local weather data. I'm located in Southern California. I ran the sensor for well over 48 hours and also run it 30 min before I want to take measurements. I've noticed the humidity readings are a lot lower than what the local weather data (wunderground.com) reports. When I add an offset variable in the code it somewhat follows the local weather data but not always. This applies for when I take it outside or indoors.

For the temperature, I've noticed it's off 1-2 degrees Fahrenheit when comparing to a thermostat for my home's HVAC. (I suppose that would be expected)

The altitude reading is off 15-20 m at times even when I update with the local sea level pressure for my location using some online weather data.

Is this behavior to be expected or should I be getting better accuracy/performance? When I looked at the adafruit_bme680.py file it seems there is some temperature compensation for the humidity value done in software. I didn't see any compensation for the gas readings but read online that for the pimoroni users of the BME680 they had to compensate the gas reading for humidity.

Also I had read the following description on your site:

"Bosch can measure humidity with ±3% accuracy, barometric pressure with ±1 hPa absolute accuracy, and temperature with ±1.0°C accuracy. Because pressure changes with altitude, and the pressure measurements are so good, you can also use it as an altimeter with ±1 meter or better accuracy!"


For gas measurements in ohms is there anything I might be able to calibrate against easily without using an expensive device or are people typically looking at the ohms reading just for trends/events for a particular environment?

User avatar
sj_remington
 
Posts: 998
Joined: Mon Jul 27, 2020 4:51 pm

Re: Adafruit BME680 Accuracy Questions

Post by sj_remington »

The altitude reading is off 15-20 m at times even when I update with the local sea level pressure for my location using some online weather data.
Use of online data will never be as good as a local calibration.

Most people calibrate an altimeter using the correct altitude and the measured absolute pressure at location. Use those data and the standard atmosphere model to calculate the equivalent sea level pressure. That calibration should be within one meter and be valid for some hours.

User avatar
sj_remington
 
Posts: 998
Joined: Mon Jul 27, 2020 4:51 pm

Re: Adafruit BME680 Accuracy Questions

Post by sj_remington »

Potentially useful code. Assumes temperature at sea level is 15 Celsius, standard atmospheric "lapse rate".

Code: Select all

// MyAltitude
float readAltitude(float abs_Pressure, float sealevel_Pressure) {
  float altitude;  //meters, pressure in hPa
  altitude = 44330.0 * (1.0 - pow(abs_Pressure /sealevel_Pressure, 0.19029495));
  return altitude;
}

// Calculate sea level equivalent pressure
float calc_p0(float myAltitude, float abs_Pressure) {
  float p0;
  p0 = abs_Pressure / pow((1.0 - ( myAltitude / 44330.0 )), 5.255);
  return p0;
}

User avatar
sdrocker
 
Posts: 32
Joined: Mon Apr 24, 2017 6:45 pm

Re: Adafruit BME680 Accuracy Questions

Post by sdrocker »

sj_remington wrote:Potentially useful code. Assumes temperature at sea level is 15 Celsius, standard atmospheric "lapse rate".

Code: Select all

// MyAltitude
float readAltitude(float abs_Pressure, float sealevel_Pressure) {
  float altitude;  //meters, pressure in hPa
  altitude = 44330.0 * (1.0 - pow(abs_Pressure /sealevel_Pressure, 0.19029495));
  return altitude;
}

// Calculate sea level equivalent pressure
float calc_p0(float myAltitude, float abs_Pressure) {
  float p0;
  p0 = abs_Pressure / pow((1.0 - ( myAltitude / 44330.0 )), 5.255);
  return p0;
}

Awesome thank you for the code. I found an online calculator that gives the expected sea level for the pressure I measured from the bme680.pressure variable which read 1006 hPa and my known altitude of 99m. The online calculator gives sea level pressure of 1017 hPa with my altitutude and measured pressure. There is a variable called bme680.sea_level_pressure in the Adafruit example which I set to the 1017 hPa and it comes out close. I can fiddle with the value to get the bme.680.altitude to show exactly 99m. I'm not sure if that's one easy way to get the calibration? Basically fiddle with the bme680.sea_level_pressure variable without doing any calculations?

Your code uses the equation in some form in this page where I got the 1017 hpA?
https://keisan.casio.com/exec/system/1224575267

It looks like in the comments section someone wrote out the equation a little more code friendly and it seems to have a variable for temperature:
float p0 = ((pres/100) * pow(1 - (0.0065 * h / (temp + 0.0065 * h + 273.15)), -5.257));

User avatar
sj_remington
 
Posts: 998
Joined: Mon Jul 27, 2020 4:51 pm

Re: Adafruit BME680 Accuracy Questions

Post by sj_remington »

As stated, in the code I posted, the sea level air temperature is assumed to be 15 C. The code you posted above allows you to enter a different sea level air temperature in C, but what value would you use, and does using a different value make a significant difference?
Basically fiddle with the bme680.sea_level_pressure variable without doing any calculations?
The second function posted calculates the calibration constant p0, or bme680.sea_level_pressure, which I find to be quicker and more accurate than "fiddling".
a little more code friendly
What does that mean? The two lines of code are equivalent and correct, as long as "pres" is a float variable. If it is an integer, then integer division errors will ensue from the expression (pres/100).

More on the standard atmosphere formulas here: https://www.mide.com/air-pressure-at-al ... calculator

User avatar
sdrocker
 
Posts: 32
Joined: Mon Apr 24, 2017 6:45 pm

Re: Adafruit BME680 Accuracy Questions

Post by sdrocker »

sj_remington wrote:As stated, in the code I posted, the sea level air temperature is assumed to be 15 C. The code you posted above allows you to enter a different sea level air temperature in C, but what value would you use, and does using a different value make a significant difference?
Basically fiddle with the bme680.sea_level_pressure variable without doing any calculations?
The second function posted calculates the calibration constant p0, or bme680.sea_level_pressure, which I find to be quicker and more accurate than "fiddling".
a little more code friendly
What does that mean? The two lines of code are equivalent and correct, as long as "pres" is a float variable. If it is an integer, then integer division errors will ensue from the expression (pres/100).

More on the standard atmosphere formulas here: https://www.mide.com/air-pressure-at-al ... calculator

Thanks. That does make sense regarding the calibration constant p0. The online calculator I shared shows the input values entered at "present location" including the pressure, altitude, and temperature.

I guess I have to think about how useful this sensor is for anything I would be doing. For monitoring pressure you actually want to calculate p0 and use that to get your variations in sea level pressure due to weather changing (ie, pressure changes from high or low system passing through)? Calculating the p0 value to correct the altitude value would be useful if you were going to put this on a drone or something and record the altitude of the drone?

Regarding my comment about the more code friendly.. I mean the person in the comments wrote out the equation in arduino code based on the equation a little bit above in the same page which obviously would need to be written out differently in code syntax.

User avatar
sj_remington
 
Posts: 998
Joined: Mon Jul 27, 2020 4:51 pm

Re: Adafruit BME680 Accuracy Questions

Post by sj_remington »

You don't need to calibrate a barometer for predicting weather. Just calculate pressure change over time. Rapid drops suggest that a storm front is moving in.

A barometer used as an altimeter must calibrated frequently, sometimes hourly if the weather is changing.

User avatar
sdrocker
 
Posts: 32
Joined: Mon Apr 24, 2017 6:45 pm

Re: Adafruit BME680 Accuracy Questions

Post by sdrocker »

sj_remington wrote:You don't need to calibrate a barometer for predicting weather. Just calculate pressure change over time. Rapid drops suggest that a storm front is moving in.

A barometer used as an altimeter must calibrated frequently, sometimes hourly if the weather is changing.
Thanks. Have you used the BME680 much? I'm struggling with the humidity reading. It seems quite off from what online weather says for my zip code even if I'm inside or outside. I'm noticing the humidity isn't always off my a set amount it seems to vary more during the day. For instance at night it seems to be off by a larger amount than in the morning.

I'm wondering if for air quality I would be better off with the sgp30 and a different humidity, pressure, temp sensor. I was trying to keep the cost in the $18 or under range which is why the BME680 was attractive.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit BME680 Accuracy Questions

Post by adafruit_support_bill »

It seems quite off from what online weather says for my zip code
Relative humidity can vary quite a bit over small distances depending on things like temperature and localized sources of water vapor. For example a bathroom will likely measure higher than other rooms. Outdoors, a shady lawn or lakeside will typically measure higher than a parking lot.

User avatar
sj_remington
 
Posts: 998
Joined: Mon Jul 27, 2020 4:51 pm

Re: Adafruit BME680 Accuracy Questions

Post by sj_remington »

I'm struggling with the humidity reading.
I have never found humidity readings to be very useful, and inexpensive sensors are notorious for inaccuracy and misbehaving.

Keep in mind that relative humidity depends extremely strongly on air temperature.

User avatar
sdrocker
 
Posts: 32
Joined: Mon Apr 24, 2017 6:45 pm

Re: Adafruit BME680 Accuracy Questions

Post by sdrocker »

sj_remington wrote:
I'm struggling with the humidity reading.
I have never found humidity readings to be very useful, and inexpensive sensors are notorious for inaccuracy and misbehaving.

Keep in mind that relative humidity depends extremely strongly on air temperature.
Thanks I'll keep that in mind!

User avatar
sdrocker
 
Posts: 32
Joined: Mon Apr 24, 2017 6:45 pm

Re: Adafruit BME680 Accuracy Questions

Post by sdrocker »

adafruit_support_bill wrote:
It seems quite off from what online weather says for my zip code
Relative humidity can vary quite a bit over small distances depending on things like temperature and localized sources of water vapor. For example a bathroom will likely measure higher than other rooms. Outdoors, a shady lawn or lakeside will typically measure higher than a parking lot.
Thanks. Does Adafruit have much experience using this and comparing to other sensors? I guess I just wanted something to compare to but didn't anticipate needing to buy an expensive sensor to calibrate against.

Another question, I noticed Bosch has the BSEC library to get something useful out of the gas sensor, ie they have a way to translate that to IAQ. I wanted to use this setup in CircuitPython so it's not going to be very useful for me it looks like. I noticed the Adafruit BME library doesn't use humidity compensation for the Gas sensor whereas I had read the BSEC library does. Do you know if that will be implemented in the future? Has anyone at Adafruit used the BME680 and compared to any more expensive sensors to judge the performance?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit BME680 Accuracy Questions

Post by adafruit_support_bill »

We have not done any formal head-to-head comparison testing. But I've had good results with both Bosch and Sensirion. Once calibrated, the temperature and pressure compare well against reference sensors.
https://learn.adafruit.com/calibrating-sensors

Humidity and gas sensing technology is more complex and harder to miniaturize. Small low-cost sensors such as the BME680 have been steadily improving. But they are still not in the same league as industrial-grade sensors costing two orders of magnitude more.

As for CircuitPython support, you may want to post your question over on the CircuitPython forum. The CircuitPython development team monitors that pretty closely: viewforum.php?f=60

User avatar
sdrocker
 
Posts: 32
Joined: Mon Apr 24, 2017 6:45 pm

Re: Adafruit BME680 Accuracy Questions

Post by sdrocker »

adafruit_support_bill wrote:We have not done any formal head-to-head comparison testing. But I've had good results with both Bosch and Sensirion. Once calibrated, the temperature and pressure compare well against reference sensors.
https://learn.adafruit.com/calibrating-sensors

Humidity and gas sensing technology is more complex and harder to miniaturize. Small low-cost sensors such as the BME680 have been steadily improving. But they are still not in the same league as industrial-grade sensors costing two orders of magnitude more.

As for CircuitPython support, you may want to post your question over on the CircuitPython forum. The CircuitPython development team monitors that pretty closely: viewforum.php?f=60

Got it, thanks I'll keep that in mind regarding the temperature and pressure. One thing I noticed using the example CircuitPython script is the sleep (1) in the while loop. If I use that I can see the ohms reading goes up when I start up the device after it's been sitting overnight until it reaches somewhere around 108,000 ohms after maybe 10 minutes. When I change the 1 second delay in the loop to 180, eventually the humidity reading rises and the temperature reading goes down a bit but the ohms value drops down to 7500 or so.

I wonder if it would make sense to sample with 1 second delay when taking gas measurements (after the 10 minute reading stabilization) and then switch to 180 seconds for temp/humidity.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit BME680 Accuracy Questions

Post by adafruit_support_bill »

The gas measurement uses a heater internal to the sensor. The sensor will sequence the readings so that the heater doesn't start until after the temperature, pressure and humidity readings are complete. However, with a fast sample rate, it is possible that residual heat from the previous read sequence could affect the humidity and temperature readings. I'd try increasing the delay between samples and see if your results improve.
I wonder if it would make sense to sample with 1 second delay when taking gas measurements (after the 10 minute reading stabilization) and then switch to 180 seconds for temp/humidity.
Reading any single parameter will still trigger the full internal sequence for reading all 4 sensors.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”