我正在使用CCS811氣體傳感器與Pi 3模型b。我按照https://learn.adafruit.com/adafruit-ccs811-air-quality-sensor/raspberry-pi-wiring-and-test這個頁面上的步驟操作,並且在刻錄期間運行沒有問題。現在我得到下面的錯誤。Raspberry Pi停止與i2c傳感器通信
我知道傳感器的工作原理,因爲我使用Arduino Uno進行了測試,我可以獲得讀數。在我的Pi上,它顯示了當我運行sudo i2cdetect -y 1時傳感器的正確地址。
我已經擦掉了SD卡3次,然後在乾淨的平板上重新開始,每次都會出現此錯誤。任何幫助將不勝感激!
這裏是我使用從傳感器讀取數據的代碼:
ccs = Adafruit_CCS811()
while not ccs.available():
pass
temp = ccs.calculateTemperature()
ccs.tempOffset = temp - 25.0
while(1):
if ccs.available():
temp = ccs.calculateTemperature()
if not ccs.readData():
print "CO2: ", ccs.geteCO2(), "ppm, TVOC: ", ccs.getTVOC(), "temp: ", temp
else:
print "ERROR!"
while(1):
pass
sleep(2)
這裏是我得到
[email protected]:~/Adafruit_CCS811_python/examples$ sudo python CCS811_example.py
Traceback (most recent call last):
File "CCS811_example.py", line 6, in <module>
ccs = Adafruit_CCS811()
File "/usr/local/lib/python2.7/dist-packages/Adafruit_CCS811/Adafruit_CCS811.py", line 84, in __init__
raise Exception("Device ID returned is not correct! Please check your wiring.")
Exception: Device ID returned is not correct! Please check your wiring.
感謝您的幫助!看起來我會在我的arduino上做這個項目! – Mike
ARDUINO FTW !!!! –
PS - Orange Pi電路板(AllWinner SoC)也可以在沒有I2C錯誤的情況下正常讀取該傳感器。你也可以試試我的C代碼 - https://github.com/bitbank2/CCS811 – BitBank