为什么我会得到BME280传感器运行时错误:无法找到芯片ID 0x58?
我有一个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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我有类似的错误,重新启动了我的pizero,一切都很好。
另外,您为什么要硬编码地址?为什么不只是这样做:
I got a similar error, rebooted my PiZero, and all was fine.
Also why are you hard coding the address? Why not just do:
有相同的错误,因为我已经连接了BMP280而不是BME280。
Got the same error because I had connected a BMP280 instead of a BME280.
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
andenter code here
change it from '0x60' to '0x58'