我无法在 Raspberry Pi 3 上的 Android Things 中通过 I2C 总线获取数据。
我在 RPi 和 DS18B20(温度传感器)上连接 Android Things。 连接到树莓派
并运行 I2C 地址扫描应用程序(https://github.com/dennisg/i2c-address-scanner),但找不到可用地址。
for (int address = 0; address < 256; address++) {
//auto-close the devices
try (final I2cDevice device = peripheralManagerService.openI2cDevice(BoardDefaults.getI2cBus(), address)) {
try {
device.readRegByte(TEST_REGISTER);
Log.i(TAG, String.format(Locale.US, "Trying: 0x%02X - SUCCESS", address));
} catch (final IOException e) {
Log.i(TAG, String.format(Locale.US, "Trying: 0x%02X - FAIL", address));
}
} catch (final IOException e) {
//in case the openI2cDevice(name, address) fails
}
}
如何通过 I2C 获取数据?