[英]Why am I getting a BME280 sensor Runtime Error: Failed to find Chip ID 0x58?
我有一個運行 Raspian Buster OS 的 Raspberry Pi Zero W。 我有一個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
我想知道為什么它在0x76
時尋找0x58
的芯片。 我一定是在這里誤解了什么。 任何建議表示贊賞。
basic.py
class 可以在此處的 repo 中找到。
因為我連接的是 BMP280 而不是 BME280,所以出現了同樣的錯誤。
我遇到了類似的錯誤,重新啟動了我的 PiZero,一切正常。 另外,為什么要對地址進行硬編碼? 為什么不這樣做:
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
打開..\Python\Lib\site-packages\adafruit_bme280\basic.py
搜索_BME280_CHIPID = const
並enter code here
將其從“0x60”更改為“0x58”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.