BME280 Sensor gives stuck readings

Hey there,

I have a Raspberry Pi 4, connected to a Breakout Garden (4 I2C and 2 SPI) via a IDE cable.

On the Breakout Garden, I have a MICS6814 sensor in one of the I2C slots, and a BME280 sensor in another slot.

The MICS6814 sensor works fine, no issues.

Initially, the BME280 sensor worked fine too and I got reasonable readings from the sensor. Post-reboot of the Pi, I now get consistently “stuck” readings from the BME280 using the demo Python script from the Pimoroni Github repo. (bme280-python/examples/all-values.py at main · pimoroni/bme280-python · GitHub)

22.17°C 678.38hPa 65.92%

I’ve tried:

  • Removing all components and using the BME280 alone; no success
  • Plugging the Breakout Garden into the Pi with no IDE cable; no success
  • Trying all four I2C slots moving the BME280 sensor around, alone; no success
  • Reinstalling the Python package for the BME280 (pip … pimoroni-bme280)
  • Trying all of the above with the MICS6814 sensor also in place to confirm the Breakout Garden works; BME280 doesn’t work but MICS6814 does work.

I cannot get the sensor to give me an updated/accurate reading.

Is the sensor borked, or am I losing myself to something silly?


Edit 1: Both the MICS and BME sensors “work” as in, there are no IO problems, but for the benefit of
the doubt, here is the output of i2cdetect -y 1 with both sensors plugged in.

pi@raspberrypi:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- 19 -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --

To the best of my knowledge the 76 address is correct for the BME280, and will disappear if not plugged into the Breakout Garden. So at this point: I have no idea why the sensor gives back this static/constant reading.


Edit 2: I’ve tweaked /boot/config.txt adding dtoverlay=i2c-sensor,bme280. After a reboot, reading the BME280 sensor results gives output like the following. Each of the three files can intermittantly give errors, like as seen in the humidity results.

pi@raspberrypi:/sys/bus/iio/devices/iio:device0 $ cat name
bme280
pi@raspberrypi:/sys/bus/iio/devices/iio:device0 $ cat in_temp_input
21750
pi@raspberrypi:/sys/bus/iio/devices/iio:device0 $ cat in_pressure_input
99.457207031
pi@raspberrypi:/sys/bus/iio/devices/iio:device0 $ cat in_humidityrelative_input
cat: in_humidityrelative_input: Input/output error

Edit 3: After resetting the config in /boot/config.txt the output from the sensor has defaulted back to the original “stuck” output - 22.17°C 678.38hPa 65.92%.

Is my sensor faulty?

That’s a really odd one, it is clearly working enough to respond to confirm the device address and is giving out valid data, so it is working to some degree. And you haven’t modified the software at all?

You’d have to email support (at) pimoroni.com if you want it replaced. I can’t think of much more troubleshooting to do without needing something like a logic analyser.

I haven’t tweaked the software, literally happy path installation and off we go.

I’ve emailed support with a link to this thread. It’s easier to keep this post updated and let them see what I’ve done to resolve this before asking for a replacement.

Sadly, I don’t have a logic analyser. I am not blessed with the skills needed to make that kind of magic work! :)

I would recommend GitHub - gusmanb/logicanalyzer: 24 channel, 100Msps logic analyzer hardware and software. You just need a Pico for that.

The lower pico is the device under test with an AHT20 temperature sensor, the upper device is the logic analyzer. You can see two cables connected from the I2C of the lower device to the logic analyzer (upper device). Of course in a complete setup you would need to power the lower device and attach the upper device via USB to your PC. Even that is not necessary with a Pico-W.

The software is also great and even runs under Linux.

2 Likes

Thank you for taking a moment to write a great reply. This will no doubt be helpful for someone with a skill level above mine.

For now, I think I’m going to ask for a replacement unit and assume this one was just defective.

Just an update for any future people: a return device solved the problem, so this issue was likely caused by a faulty sensor or breakout board. Hope that helps.

2 Likes

Hello, just had similar error. BME got stuck with some default values :( => 22.10°C | 644.67hPa | 65.03%. Found this tread while looking for solution…

Then i decided to run original example code: those show real values (hmmm…). I have now 2 screen running kind of similar code but one get real values, other constant as above. …
and it turned out i had bus = SMBus(1) // bme280 = BME280(i2c_dev=bus) in loop which leads to it - make sure it’s initializing once !

1 Like

Great you were able to find a root cause. I’m sure that’ll help future tinkers.

In my case, it wasn’t relevant because I got the same result from the original Pimoroni code.

But it’s great to provide solutions to future people. (Hello future people!)