Connect an Arduino or microcontroller to an Android device via USB and send and receive data from your app
Build an Android app that communicates with FTDI, CP210x, or CH340 USB-to-serial converter chips
Receive data from a USB serial device using event-driven mode that calls your code when new data arrives
Add support for an unlisted USB device by configuring a custom probe table with the device vendor and product IDs
Requires a physical Android device with USB host mode support and a compatible USB serial adapter or Arduino for testing, standard Android development environment needed.
usb-serial-for-android is a Java library that lets Android apps talk to physical hardware devices connected via USB. The kind of hardware it targets includes Arduinos, microcontrollers, and USB-to-serial adapter chips commonly used in electronics projects. When you plug such a device into an Android phone or tablet using an OTG cable, this library lets your app send and receive data over the connection. Android has built-in support for USB host mode, meaning it can act as the controller rather than just a peripheral. This library builds on that feature by providing drivers for the specific chips that most USB serial adapters use. Supported chips include FTDI converters, Prolific PL2303, Silicon Labs CP210x, and Qinheng CH340 series, among others. Arduino boards and other devices that follow a general USB communication standard called CDC/ACM also work. No device rooting or custom kernel changes are needed, and everything runs in standard Java. Using the library involves three steps: adding it to your Android project's build file, optionally setting up an intent filter so your app launches automatically when a matching device is plugged in, and then writing code to open the port, set speed and parity parameters, and read or write bytes. The library supports both a simple direct read/write approach and an event-driven mode where a background manager calls your code whenever new data arrives. If a device is not in the built-in list of recognized hardware, you can configure a custom probe table with the device's specific USB vendor and product identifiers to point it at the right driver. The project also links to a more complete example app called SimpleUsbTerminal that demonstrates background connection management and hardware flow control.
← mik3y on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.