2017-10-29 198 views
0

我正在使用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. 

image of wiring and error

回答

0

錯誤該傳感器不在樹莓派上得到很好的支持。這是因爲它使用了I2C時鐘擴展,Pi不能在不顯着降低I2C速度的情況下進行擴展。支持CircuitPython和Arduino。

引用自:

https://learn.adafruit.com/adafruit-ccs811-air-quality-sensor/overview

AMS建議運行該傳感器48小時時,首先接收到「在它燒」,然後在所希望的模式,每次20分鐘傳感器正在使用中。這是因爲傳感器的靈敏度在早期使用時會發生變化。

引用自:

https://learn.adafruit.com/adafruit-ccs811-air-quality-sensor/overview

+0

感謝您的幫助!看起來我會在我的arduino上做這個項目! – Mike

+0

ARDUINO FTW !!!! –

+0

PS - Orange Pi電路板(AllWinner SoC)也可以在沒有I2C錯誤的情況下正常讀取該傳感器。你也可以試試我的C代碼 - https://github.com/bitbank2/CCS811 – BitBank