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

Temperature readings to high #11

Closed
ayeks opened this issue May 20, 2018 · 5 comments
Closed

Temperature readings to high #11

ayeks opened this issue May 20, 2018 · 5 comments
Assignees
Labels

Comments

@ayeks
Copy link
Contributor

ayeks commented May 20, 2018

Hi,

I am experiencing the issue that the temperatures from the bme680 are too high. Compared to another temperature sensor they are about 3-4 °C higher.

Changing the oversampling methods won't fix the issue. The sensors are not influenced by the heat from the raspberrypi zero w. I could just substract 4°C from the temperature, but the relative humidity is also influenced by the wrong temperature.

Does anyone know how to fix the issue?

I looked briefly into the _calc_temperature funtion in init.py but I could figure out where I should start on a fix.

I attached the output of the read-all.py.

Calibration data:
par_gh1: -30
par_gh2: -24754
par_gh3: 18
par_h1: 676
par_h2: 1029
par_h3: 0
par_h4: 45
par_h5: 20
par_h6: 120
par_h7: -100
par_p1: 36673
par_p10: 30
par_p2: -10515
par_p3: 88
par_p4: 7310
par_p5: -129
par_p6: 30
par_p7: 46
par_p8: -3177
par_p9: -2379
par_t1: 26041
par_t2: 26469
par_t3: 3
range_sw_err: 0
res_heat_range: 1
res_heat_val: 48
t_fine: 136667


Initial reading:
gas_index: 0
gas_resistance: 12946860
heat_stable: False
humidity: 42.402
meas_index: 0
pressure: 987.12
status: 32
temperature: 26.69


Polling:
Polling:
26.70 C,987.11 hPa,42.40 %RH
26.71 C,987.11 hPa,42.38 %RH,24370 Ohms
26.74 C,987.12 hPa,42.34 %RH,33347 Ohms
26.77 C,987.12 hPa,42.26 %RH,43482 Ohms
26.80 C,987.16 hPa,42.21 %RH,53233 Ohms
26.82 C,987.16 hPa,42.14 %RH,62627 Ohms
26.84 C,987.15 hPa,42.09 %RH,71260 Ohms
26.86 C,987.15 hPa,42.02 %RH,79288 Ohms
26.87 C,987.16 hPa,41.97 %RH,86583 Ohms
26.89 C,987.13 hPa,41.92 %RH,93756 Ohms
...
27.16 C,987.12 hPa,40.87 %RH,209827 Ohms
27.15 C,987.12 hPa,40.88 %RH,212672 Ohms
27.15 C,987.11 hPa,40.90 %RH,211037 Ohms
27.16 C,987.10 hPa,40.91 %RH,211988 Ohms
...
27.30 C,987.12 hPa,41.45 %RH,214333 Ohms
27.29 C,987.13 hPa,41.69 %RH,215737 Ohms
27.29 C,987.13 hPa,41.86 %RH,215879 Ohms
27.29 C,987.14 hPa,41.95 %RH,217447 Ohms
27.29 C,987.14 hPa,41.98 %RH,217878 Ohms
27.29 C,987.14 hPa,41.97 %RH,218456 Ohms
27.30 C,987.14 hPa,41.92 %RH,220062 Ohms
27.30 C,987.13 hPa,41.86 %RH,218892 Ohms

clima
I turned the gas sensor of the green raspizero1 of at 14:37 with sensor.set_gas_status(bme680.DISABLE_GAS_MEAS). But it didn't affect the temperature readings.

Can someone point me in a useful direction to fix the temperature issue?

@ferazambuja
Copy link

That's normal. The sensor is not factory calibrate for temperature. You need to add a temperature offset.
Not sure if the library supports.

Looking at a reference thermometer, we can see that our temperature is indeed a few degrees to high. Does that mean the temperature sensor inside the BME680 is inaccurate?
Actually no, it very accurately measures the temperature exactly where it is located on the board. But there also is the issue: our board as most devices contains some heat sources (e.g., MCU, WiFi chip, display, …). This means the temperature on our board is actually higher than the ambient temperature. Since the absolute amount of water in the air is approximately constant, this also causes the relative humidity to be lower on our board than elsewhere in the room.
As BSEC cannot know in which kind of device the sensor is integrated, we have provide some information to the algorithm to enable it to compensate this offset. In the simplest case, we have to deal with an embedded device with a constant workload and approximately constant self-heating. In such a case, we can simply supply a temperature offset to BSEC which will be subtracted from the temperature and will be used to correct the humidity reading as well.

from the Integration Guide - Bosch Software Environmental Cluster (BSEC)

@Gadgetoid
Copy link
Member

Humidity uses t_fine to as part of the compensation formula, which is the partially compensated temperature value before it's converted to human-readable degrees C.

BOSCH's own open-source BME680_driver does not demonstrate the method needed to alter or compensate this value during temperature compensation of other measurements.

While their BSEC software might, as far as I'm aware it's distributed only as binary blobs and is closed-source, so we can't extract the logic used from it.

If anyone can demonstrate a method of compensating temperature such that the degrees C and humidity results are accurate, then I would gladly integrate it into this library.

Looking at how t_fine is converted to degrees C:

https://github.com/BoschSensortec/BME680_driver/blob/e6b9bbade923d792d9ccd822ab5fada99bf40501/bme680.c#L887-L888

Suggests that a compensation amount given in degrees C (since we can't expect the end user to know what units t_fine is expressed in) could be converted to an offset against t_fine using the following formula:

offset_in_t_fine = ((offset_in_c << 8) - 128) / 5

Which gives you a t_fine offset of 179 for 4.0C.

To see if this corrects your results, you can subtract this value from the stored t_fine calibration value here:

https://github.com/pimoroni/bme680/blob/master/library/bme680/__init__.py#L296

Let me know how it goes!

@ferazambuja
Copy link

ferazambuja commented May 23, 2018

Yes, it looks like only the BSEC does. I wish they had a more open platform.

To achieve this, we simply provide a non-zero temperature offset as the second argument to bsec_iot_init() as shown below. Here, we subtract a 5 degrees offset, for example.

/* Call to the function which initializes the BSEC library /* Switch on ultra-low-power mode and subtract a 5 degrees temperature offset */

ret = bsec_iot_init(BSEC_SAMPLE_RATE_ULP, 5.0f, bus_write, bus_read, sleep, state_load, config_load);

@ayeks
Copy link
Contributor Author

ayeks commented May 28, 2018

Thanks a lot guys!

To convert the offset_in_c to offset_in_t_fine you have to multiply it also by 100. Source

The function is: self.offset_temp_in_t_fine = int((((offset_in_c * 100) << 8) - 128) / 5)

SET offset 0
27.88 C,982.67 hPa,46.236 %RH
SET offset 4
23.89 C,976.18 hPa,45.770 %RH
SET offset 10
17.89 C,966.54 hPa,45.071 %RH
SET offset 20
7.90 C,950.56 hPa,44.036 %RH

I will commit a merge request later.

@David-Hari
Copy link

The bme280 suffers from the same problem.

Looking at the code for each, I see they are quite different in how they calculate things. I can see the bme280 is doing some sort of compensation, but it does not allow me to plug in a corrected temperature value (or offset).

@Gadgetoid , can we get a similar offset function in the bme280?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants