Android Things I2C驱动程序PioException:I / O错误

时间:2017-12-06 13:42:45

标签: java android iot android-things adafruit

你好亲爱的Android事先锋!

我正在呼唤你的帮助,因为我在过去几个月一直在为Adafruit SI7021温度和湿度传感器构建一个Android东西驱动程序。 Here is the link to the github repository主持项目。 连接和获取readRegByte的芯片ID工作正常。 但是,我在尝试使用PioException: I/O error检索温度或湿度数据时得到readRegBuffer

int address = 0xE5; // from datasheet
byte[] buffer = new byte[3];

device.readRegBuffer(address, buffer, 3); // throws PioException

我不知道我可以提供哪些其他线索以便清楚地了解问题,所以不要犹豫提问。

请不要让我买一个arduino并重新开始;)

非常感谢你!

PS:使用简单的词语我是IoT和Android的初学者。

1 个答案:

答案 0 :(得分:0)

readRegBuffer不符合我的预期。从[API文档](https://developer.android.com/things/reference/com/google/android/things/pio/I2cDevice.html#readRegBuffer(int,byte [],int)):

  

从给定寄存器中读取多个字节。

如果要读取的寄存器长度为3个字节(24位),则使用此方法。查看the part's datasheet(第21页),注册0xE5相对湿度似乎是一个2位字。

期望3个字节会产生问题,因为您的设备将需要返回3个字节​​。但是,如果只返回两个字节,则实际结果将不一致。