w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Receiving data from Arduino to Android Device via USB

Using the bulkTransfer method is the way to go. You will need to use the IN endpoint to receive the data. For instance, to get a byte of data from the Arduino use this:

byte[] reply = new byte[1]; // to store data from Arduino
int size = 1;               // receive at most 1 byte of data
int timeout = 100;          // try to receive data for up to 100
int count = conn.bulkTransfer(epIN, reply, size, timeout);

if(count < 0) {
    Log.d("ArduinoUSB", "Failure occurred when receiving from Arduino");
} else {
    Log.d("ArduinoUSB", "Received " + count + " bytes: " +

The data will be stored in reply.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.