【问题标题】:RaspberryPi 3 temperature sensor remote I/O error (python)RaspberryPi 3 温度传感器远程 I/O 错误(python)
【发布时间】:2018-01-31 10:12:58
【问题描述】:

我有一个温度和湿度传感器通过 3.3v 电源、GNDSDASCL 连接到我的 RPi强>。我正在尝试从中获取温度读数,但我一直在获取

“操作系统错误:[Errno 121] 远程 I/O 错误”。

i2c 接口已启用,一切都是最新的。我可以使用sudo i2cdetect -y 1 查看设备的地址。有没有可能我应该先向它发送一些数据,以便传感器“知道”我即将从中读取数据并且它应该发送数据?

这是我的代码

import smbus
TEMP = 0x40
bus = smbus.SMbus(1)
state = 1

while (state):
      print("1.Read temperature")
      print("2.Exit")

      choice = input("")

      if choice =='1':
            Ctemp = bus.read_byte(TEMP)
            print ("%d" %Ctemp)

      elif choice == '2':
            state = 0

【问题讨论】:

    标签: python raspberry-pi3 i2c temperature


    【解决方案1】:

    是的,您可能需要配置您的 I2C 设备(您没有提及您使用的设备,因此我无法为您查找),但此错误可能意味着其他问题。 您可以尝试i2cdump -y 1 0x40 以查看可用的数据,但同样,您应该阅读传感器芯片的数据表以了解如何使用。

    【讨论】:

      猜你喜欢
      • 2018-04-16
      • 1970-01-01
      • 1970-01-01
      • 2022-06-14
      • 1970-01-01
      • 2014-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多