arduino - Android 作为 I2C 从设备

标签 arduino i2c android-things

我想通过 I2C 将运行 Android 的 Raspberry Pi 与 Arduino Nano 连接。 Android 官方文档说:

Managing the slave device connection

有没有办法让 Arduino 充当主站,让带有 Android 的 Raspberry 充当从站?

在 Arduino 端,Wire 库提供了 onRequest 或 onReceive 回调,但我在 Android 端没有使用外设 I/O API 看到任何回调。

有没有任何解决方案,或者只是在 Android 端使用一个简单的循环来从 Arduino 寄存器读取,无论是否有更改。 谢谢

最佳答案

Is there any solution or just use on Android side a simple loop to read from Arduino register regardless if there is a change or not.

您可以在两者之间设置 GPIO 连接

https://developer.android.com/things/sdk/pio/gpio.html#input-state

当有数据要读取时,让 arduino“ping”AndroidThings 板。

然后 AndroidThings 板可以使用 I2C 读取此时 https://developer.android.com/things/reference/com/google/android/things/pio/I2cDevice.html#read(byte[],%20int)

(比轮询循环更好)

关于arduino - Android 作为 I2C 从设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49574190/

相关文章:

android - 如何在 Android Things 中预览 Raspberry 中的相机?

android - 如何在 Android Studio 中或通过 ADB 获取 Android Things 设备上的应用程序的屏幕截图?

java - Android Things - 如何在命令 mLedGpio.setValue(true) 后保持 LED 不间断地开启

c++ - 前端UI应用程序(MERN堆栈)如何使用C++从工程师那里接收数据?

arduino - Serial.begin(speed, config) 没有为 Leonardo Board 编译

node.js - Arduino Socket.io 通信

python - 在Python中读取2字节的I2C事务

c - Arduino 作为 I2C 从设备与 RPi 通信

c - 隐式减速和未知类型错误

java - 如何将一系列开关的输入转换为速度和方向?