无法在Raspberry Pi上使用Python访问晴雨表(BMP180)

时间:2015-06-21 12:17:34

标签: python linux io raspberry-pi raspberry-pi2

我有一个BMP180晴雨表,我想在Raspberry Pi上使用Python阅读。

我已关注Adafruit tutorial并使用sudo i2cdetect -y 1成功读取数据,但当我尝试在Adafruit Python BMP库中运行simpletest.py时出现错误。

pi@raspberrypi ~/Adafruit_Python_BMP $ sudo python examples/simpletest.py
Traceback (most recent call last):
  File "examples/simpletest.py", line 37, in <module>
    sensor = BMP085.BMP085()
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_BMP-1.5.0-py2.7.egg/Adafruit_BMP/BMP085.py", line 68, in __init__
    self._load_calibration()
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_BMP-1.5.0-py2.7.egg/Adafruit_BMP/BMP085.py", line 71, in _load_calibration
    self.cal_AC1 = self._device.readS16BE(BMP085_CAL_AC1)   # INT16
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_GPIO-0.9.3-py2.7.egg/Adafruit_GPIO/I2C.py", line 195, in readS16BE
    return self.readS16(register, little_endian=False)
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_GPIO-0.9.3-py2.7.egg/Adafruit_GPIO/I2C.py", line 172, in readS16
    result = self.readU16(register, little_endian)
  File "/usr/local/lib/python2.7/dist-packages/Adafruit_GPIO-0.9.3-py2.7.egg/Adafruit_GPIO/I2C.py", line 159, in readU16
    result = self._bus.read_word_data(self._address,register) & 0xFFFF
IOError: [Errno 5] Input/output error

我也尝试过使用Adafruit的Adafruit-Raspberry-Pi-Python-Code库,但我收到类似的I / O错误。

pi@raspberrypi ~/Adafruit-Raspberry-Pi-Python-Code/Adafruit_BMP085 $ sudo python Adafruit_BMP085_example.py
Error accessing 0x77: Check your I2C address
Error accessing 0x77: Check your I2C address

有谁知道为什么会这样?我正在使用Raspberry Pi 2 Model B.

0 个答案:

没有答案