2
votes

I would like to connect Raspberry Pi running Android things with Arduino Nano by I2C. The official Android documentation says:

Managing the slave device connection

Is there a way to act Arduino as a master and Raspberry with Android things to act as a slave?

On Arduino side there is onRequest or onReceive callbacks available with Wire library but I don't se any callbacks with Peripherial I/O API on Android side.

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. Thanks

2

2 Answers

2
votes

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.

You could setup a GPIO connection between the two

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

Have the arduino "ping" the AndroidThings board when it has data to read.

Then the AndroidThings board can use I2C to read at that point https://developer.android.com/things/reference/com/google/android/things/pio/I2cDevice.html#read(byte[],%20int)

(better than having a polling loop)

0
votes

Seems there is no way o use Raspberry Pi with Android Things as I2C slave, but you can use various workarounds:

1) connect Arduino-master to Raspberry Pi via other interface (UART or SPI) for get register data exchange;

2) use other Arduino-slave connected to target Arduino-master via I2C and to Raspberry Pi via UART/SPI;

3) implement custom bit-by-bit data transfer via GPIO;

etc.