Why am I getting a BME280 sensor Runtime Error: Failed to find Chip ID 0x58?

1.1k Views Asked by At

I have a Raspberry Pi Zero W running Raspian Buster OS. I have a BME 280 sensor attached to the SDA and SCL pins. When I look for the sensor using i2cdetect -y 1 I find it at 0x76:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --

The script I am running from AdaFruit is here:

import time
import board
from adafruit_bme280 import basic as adafruit_bme280

i2c = board.I2C()  # uses board.SCL and board.SDA
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, address=0x76)

bme280.sea_level_pressure = 1013.25

while True:
    print("\nTemperature: %0.1f C" % bme280.temperature)
    print("Humidity: %0.1f %%" % bme280.relative_humidity)
    print("Pressure: %0.1f hPa" % bme280.pressure)
    print("Altitude = %0.2f meters" % bme280.altitude)
    time.sleep(2)

I get the following runtime error:

Traceback (most recent call last):
  File "bme280_simpletest.py", line 10, in <module>
    bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, address=0x76)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_bme280/basic.py", line 371, in __init__
    super().__init__()
  File "/usr/local/lib/python3.7/dist-packages/adafruit_bme280/basic.py", line 96, in __init__
    raise RuntimeError("Failed to find BME280! Chip ID 0x%x" % chip_id)
RuntimeError: Failed to find BME280! Chip ID 0x58

I am wondering why it is looking for the chip at 0x58 when it is at 0x76. I must be misunderstanding something here. Any suggestions are appreciated.

The basic.py class may be found in the repo here.

3

There are 3 best solutions below

0
On

I got a similar error, rebooted my PiZero, and all was fine. Also why are you hard coding the address? Why not just do:

bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
0
On

open ..\Python\Lib\site-packages\adafruit_bme280\basic.py search for _BME280_CHIPID = const and enter code herechange it from '0x60' to '0x58'

1
On

Got the same error because I had connected a BMP280 instead of a BME280.