BME280 reads 4C high

Hi,

I’m getting erratic sensor readings from a black Pimori BME280 sensor (not the blue Adafruit). The temperature sometimes reads 4C high. This is a software issue NOT sensor picking up heat from the cpu. See below for details. Should I follow this up in this forum, or take it up with the developers on github?

Please see below for details.

DETAILS

Software installed from https://github.com/pimoroni/bme280-python with a pi zero

Using the example code all-values.py, I get output like this:

	...
	# Initialise the BME280
	bus = SMBus(1)
	bme280 = BME280(i2c_dev=bus)
	while True:
		temperature = bme280.get_temperature()
		pressure = bme280.get_pressure()
		humidity = bme280.get_humidity()
		print('{:05.2f}*C {:05.2f}hPa {:05.2f}%'.format(temperature, pressure, humidity))
		time.sleep(1)

pi@raspberrypi:~/bme280 $ python all-values.py 
all-values.py - Read temperature, pressure, and humidity
Press Ctrl+C to exit!

20.10*C 733.97hPa 60.06%
24.01*C 1008.09hPa 40.92%
24.01*C 1008.11hPa 40.94%
24.00*C 1008.11hPa 40.92%
24.00*C 1008.12hPa 40.92%

The first temperatue reading (20.10C) looks correct, the other readings are about 4 degrees too high.

If I now move the constructor for the bme280 inside the loop I get the following:

	# Initialise the BME280
	bus = SMBus(1)

	while True:
		bme280 = BME280(i2c_dev=bus)
		temperature = bme280.get_temperature()
		pressure = bme280.get_pressure()
		humidity = bme280.get_humidity()
		print('{:05.2f}*C {:05.2f}hPa {:05.2f}%'.format(temperature, pressure, humidity))
		time.sleep(1)

pi@raspberrypi:~/bme280 $ python all-values.py 
all-values.py - Read temperature, pressure, and humidity
Press Ctrl+C to exit!

20.10*C 733.97hPa 60.06%
20.10*C 733.97hPa 60.06%
20.10*C 733.97hPa 60.06%
20.10*C 733.97hPa 60.06%
20.10*C 733.97hPa 60.06%
20.10*C 733.97hPa 60.06%
24.01*C 1008.09hPa 40.90%
24.00*C 1008.10hPa 40.87%
20.10*C 733.97hPa 60.06%
20.10*C 733.97hPa 60.06%

Most of the time the temperature looks correct, but occasionally I get an incorrect result (again, its the same error). I suspect it may be some form of timing issue or something to do with the initialisation of the bus, but have no real knowledege of the hardware side of things.

Has anyone seen anything similar or got any ideas how to follow this up?

Those pressure values don’t look right, apparently the world record low pressure is 870 mb /hPa, which makes me wonder about the accompanying temperature and humidity values. EDIT: Those are sea level values obviously, which is important.

I wonder if it is something to do with the startup time of the sensor? Does it need left for a few seconds to stabilise after initialisation before getting a reading from it?

Loking into the code on the driver, both pressure and humidity have corrections based on temperature values, hence I was focusing on getting the temperature correct first. I will continue to poker around in the code tomorow when my brain is a bit clearer.

Thanks for quick reply.

I have made a bit more progress. The chip includes an IIR filter and the BoschSensortec reference code for the driver allows a delay between initialising the registers and taking the first reading. This is done by the function bme280_cal_meas_delay(const struct bme280_settings *settings) in file https://github.com/BoschSensortec/BME280_driver/blob/master/bme280.c.

Using your values and the formula:
BME280_MEAS_OFFSET = 1250
BME280_MEAS_DUR = 2300
BME280_PRES_HUM_MEAS_OFFSET = 575
BME280_MEAS_SCALING_FACTOR = 575
temp_osr = 16
pres_osr = 16
hum_osr = 16

max_delay =((BME280_MEAS_OFFSET + (BME280_MEAS_DUR * temp_osr) + ((BME280_MEAS_DUR * pres_osr) + BME280_PRES_HUM_MEAS_OFFSET) + ((BME280_MEAS_DUR * hum_osr) + BME280_PRES_HUM_MEAS_OFFSET)) / BME280_MEAS_SCALING_FACTOR)

which gives a delay of 196 mS.

Your code does not appear to have any similar delay (although it should probably be included in your drivers). This explains why the first reading from all-samples.py is anomalous, but does not explain the 4 degree error in temperature. At the moment I’m not ready to accept that it is the CPU heating the sensor since they are well seperated. I think the next step is to try to compile the example in the official BoschSensortec drivers and see what they report.

Regards
Rob

Your code

So to be clear, I don’t work at Pimoroni. Most of the people on the forum don’t, we’re just other users.

How certain are you that 20°C is correct and 24°C is wrong?

This is what the Bosch datasheet on BME280 says basically - “It is unreliable unless you compensate for PCB temp and sensor element self heating”

Note points 7-8
7-Temperature measured by the internal temperature sensor. This temperature value depends on the PCB temperature, sensor element self-heating and ambient temperature and is typically above ambient temperature.
8 Target values & not guaranteed
9 Target values & not guaranteed