2016-12-31 116 views
0

我有adafruit壓力和溫度傳感器BMP180連接到Raspberry Pi的I2C 3.設備在I2C的0x77地址處檢測到,i2cdump運行時沒有錯誤並顯示正確的值(例如Bosch文檔中所述的0xD0中的字節0x55)。但是在大多數情況下讀取一個字節會導致輸入/輸出錯誤。Raspberry Pi 3上的讀取字節失敗:[errno 5]輸入/輸出錯誤

[email protected]:~ $ i2cdetect -y 1 
    0 1 2 3 4 5 6 7 8 9 a b c d e f 
00:   -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- 29 -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- 77      

[email protected]:~/Adafruit_Python_BMP $ i2cdump -y 1 0x77 
No size specified (using byte-data access) 
    0 1 2 3 4 5 6 7 8 9 a b c d e fabcdef 
00: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX 
10: XX XX XX 00 00 00 00 00 00 00 00 00 00 00 00 00 XXX............. 
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 
80: a5 94 46 29 82 27 75 20 c8 0b 22 91 fb 57 c7 11 ??F)?'u ??"??W?? 
90: 85 ca 61 f6 45 8a 19 73 00 30 80 00 d1 f6 0a d4 ??a?E??s.0?.???? 
a0: a5 94 46 29 82 27 75 20 c8 0b 22 91 fb 57 c7 11 ??F)?'u ??"??W?? 
b0: 85 ca 61 f6 45 8a 19 73 00 30 80 00 d1 f6 0a d4 ??a?E??s.0?.???? 
c0: 00 00 bc 33 00 00 00 00 00 00 00 10 00 00 00 03 ..?3.......?...? 
d0: 55 02 06 00 00 00 00 00 00 00 00 00 00 00 00 00 U??............. 
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 
f0: 00 00 00 00 00 00 80 00 00 00 00 00 00 00 00 00 ......?......... 

[email protected]:~/Adafruit_Python_BMP $ i2cget -y 1 0x77 0xd0 
0x55 
[email protected]:~/Adafruit_Python_BMP $ i2cget -y 1 0x77 0xd0 
Error: Read failed 
[email protected]:~/Adafruit_Python_BMP $ i2cget -y 1 0x77 0xd0 
Error: Read failed 

執行例如從Adafruit的(對於BMP180傳感器)在大多數情況下也將返回錯誤:

[email protected]:~/Adafruit_Python_BMP $ python test.py 
Temp = 23.40 *C 
Pressure = 99105.00 Pa 
[email protected]:~/Adafruit_Python_BMP $ python test.py 
Traceback (most recent call last): 
    File "test.py", line 3, in <module> 
    sensor = BMP085.BMP085() 
    File "/home/pi/Adafruit_Python_BMP/Adafruit_BMP/BMP085.py", line 69, in __init__ 
    self._load_calibration() 
    File "/home/pi/Adafruit_Python_BMP/Adafruit_BMP/BMP085.py", line 72, in _load_calibration 
    self.cal_AC1 = self._device.readS16BE(BMP085_CAL_AC1) # INT16 
    File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 200, in readS16BE 
    File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 177, in readS16 
    File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 164, in readU16 
    File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 173, in read_word_data 
IOError: [Errno 5] Input/output error 

我也寫腳本以從該傳感器讀取的字節,即使用smbus2或SMBus-CFFI。其結果是一樣的:很少有字節讀取,在大多數情況下,我得到的錯誤:

➜ birdwatcher git:(master) ✗ cat bmp180.py | ssh [email protected] sudo python - 
2016-12-30 19:30:40,608 __main__      DEBUG AC1 = -29482 [-0x732a] 
2016-12-30 19:30:40,609 __main__      DEBUG AC2 = 22523 [0x57fb] 
2016-12-30 19:30:40,609 __main__      DEBUG AC3 = 4551 [0x11c7] 
2016-12-30 19:30:40,610 __main__      DEBUG AC4 = 51845 [0xca85] 
2016-12-30 19:30:40,610 __main__      DEBUG AC5 = 63073 [0xf661] 
2016-12-30 19:30:40,610 __main__      DEBUG AC6 = 35397 [0x8a45] 
➜ birdwatcher git:(master) ✗ cat bmp180.py | ssh [email protected] sudo python - 
Traceback (most recent call last): 
    File "<stdin>", line 101, in <module> 
    File "<stdin>", line 68, in __init__ 
    File "<stdin>", line 49, in read_uint8 
IOError: [Errno 5] Input/output error 

下面是關於環境的一些信息:

[email protected]:~ $ uname -a 
Linux raspberrypi 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux 
[email protected]:~ $ ls -a /dev/i2c* 
/dev/i2c-1 
[email protected]:~ $ cat /boot/config.txt | grep i2c 
dtparam=i2c_arm=on,i2c_arm_baudrate=100000 
dtoverlay=i2c-sensor 
[email protected]:~ $ lsmod 
Module     Size Used by 
bnep     10340 2 
hci_uart    17943 1 
btbcm     5929 1 hci_uart 
bluetooth    326105 22 bnep,btbcm,hci_uart 
brcmfmac    186403 0 
brcmutil    5661 1 brcmfmac 
cfg80211    428431 1 brcmfmac 
rfkill     16037 4 cfg80211,bluetooth 
snd_bcm2835   20447 0 
snd_pcm    75762 1 snd_bcm2835 
snd_timer    19288 1 snd_pcm 
snd     51908 3 snd_bcm2835,snd_timer,snd_pcm 
bcm2835_wdt    3225 0 
bcm2835_gpiomem   3040 0 
uio_pdrv_genirq   3164 0 
uio      8000 1 uio_pdrv_genirq 
i2c_bcm2708    4834 0 
i2c_dev     5859 0 
fuse     84037 1 
ipv6     347594 30 

摘要: i2cdump從傳感器讀取所有字節,但在大多數情況下通過i2cget讀取失敗。行爲是隨機的並且不一致(在大多數情況下,它會導致錯誤)。

我也收集了有關使用piscope的電線信號的數據。 這是一個成功的i2cget: i2cget -y 1 0x77 0xd0 - returns 0x55

這裏是讀取失敗字節: i2cget -y 1 0x77 0xd0 - Error: Read failed

+0

檢查硬件連接 – eyllanesc

+0

@eyllanesc硬件連接是穩定的,如果我跑i2cdump我總是得到正確的數據(i2cdump後沒有錯誤,i2cdetect總是顯示當前傳感器)。 – Alexei

+0

[相關](http://stackoverflow.com/q/38815505/1699210) – bummi

回答

0

解決。 我在GND總線上連接錯誤。

相關問題