6

我已成功安装 Adafruit_Gpio 包,当我尝试运行 adafruit 提供的 bme 传感器示例文件时,出现以下错误:

  Traceback (most recent call last):
  File "/home/rpi3/Adafruit_Python_BME280/example.py", line 3, in <module>
    sensor = BME280(mode=BME280_OSAMPLE_8)
  File "/home/rpi3/Adafruit_Python_BME280/Adafruit_BME280.py", line 88, in __init__
    self._device = i2c.get_i2c_device(address, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/Adafruit_GPIO-1.0.3-py3.5.egg/Adafruit_GPIO/I2C.py", line 64, in get_i2c_device
    return Device(address, busnum, i2c_interface, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/Adafruit_GPIO-1.0.3-py3.5.egg/Adafruit_GPIO/I2C.py", line 97, in __init__
    self._bus = Adafruit_PureIO.smbus.SMBus(busnum)
  File "/usr/local/lib/python3.5/dist-packages/Adafruit_PureIO/smbus.py", line 97, in __init__
    self.open(bus)
  File "/usr/local/lib/python3.5/dist-packages/Adafruit_PureIO/smbus.py", line 122, in open
    self._device = open('/dev/i2c-{0}'.format(bus), 'r+b', buffering=0)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'

我在 xubuntu 上运行 rpi-3 我已经运行了 apt-get udpate 并重新启动了机器,但都没有用。

4

1 回答 1

3

我在评论的帮助下找到了解决方案。特别是对于 xubuntu的步骤是:

sudo raspi-config

选择:

3 Interfacing Options

选择:

P4 I2C

YES

于 2017-05-25T07:15:15.500 回答