Raspberry Pi 3 の I2C に接続された adafruit 圧力および温度センサー BMP180 があります。デバイスは I2C の 0x77 アドレスで検出され、i2cdump はエラーなしで実行され、正しい値が表示されます (たとえば、Bosch のドキュメントに記載されている 0xD0 のバイト 0x55)。しかし、ほとんどの場合、バイトを読み取ると入出力エラーが発生します。
pi@raspberrypi:~ $ 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
pi@raspberrypi:~/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 f 0123456789abcdef
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 ......?.........
pi@raspberrypi:~/Adafruit_Python_BMP $ i2cget -y 1 0x77 0xd0
0x55
pi@raspberrypi:~/Adafruit_Python_BMP $ i2cget -y 1 0x77 0xd0
Error: Read failed
pi@raspberrypi:~/Adafruit_Python_BMP $ i2cget -y 1 0x77 0xd0
Error: Read failed
ほとんどの場合、Adafruit (BMP180 センサー用) から例を実行すると、エラーも返されます。
pi@raspberrypi:~/Adafruit_Python_BMP $ python test.py
Temp = 23.40 *C
Pressure = 99105.00 Pa
pi@raspberrypi:~/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 pi@192.168.1.11 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 pi@192.168.1.11 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
環境に関する情報は次のとおりです。
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.4.38-v7+ #938 SMP Thu Dec 15 15:22:21 GMT 2016 armv7l GNU/Linux
pi@raspberrypi:~ $ ls -a /dev/i2c*
/dev/i2c-1
pi@raspberrypi:~ $ cat /boot/config.txt | grep i2c
dtparam=i2c_arm=on,i2c_arm_baudrate=100000
dtoverlay=i2c-sensor
pi@raspberrypi:~ $ 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 - 0x55 を返します
そして、失敗したバイト読み取りは次のとおりです: i2cget -y 1 0x77 0xd0 - エラー: 読み取りに失敗しました