为什么我会得到BME280传感器运行时错误:无法找到芯片ID 0x58?

发布于 2025-01-23 12:40:21 字数 2098 浏览 5 评论 0原文

我有一个Raspberry Pi Zero W运行Raspian Buster OS。我有一个 bme 280传感器附加到SDA和SCL销钉上。当我使用i2cdetect -y 1查找传感器时,我在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 --

我从Adafruit运行的脚本在这里:

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)

我得到以下运行时错误:

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

我是想知道为什么在0x58上寻找芯片时,它在0x76时。我必须在这里误解一些东西。 任何建议将被赞赏。

basic.py类可以在repo 这里

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

没有心的人 2025-01-30 12:40:21

我有类似的错误,重新启动了我的pizero,一切都很好。
另外,您为什么要硬编码地址?为什么不只是这样做:

bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)

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)
指尖上的星空 2025-01-30 12:40:21

有相同的错误,因为我已经连接了BMP280而不是BME280。

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

无尽的现实 2025-01-30 12:40:21

Open .. \ Python \ Lib \ lib \ site-packages \ adafruit_bme280 \ basic.py.py搜索_bme280_chipid = const const and 在此处输入代码 '0x60'至'0x58'

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文