Date: "22 - October - 2015"

1 articles found.

USB Communication between Android and Arduino

Android and Arduino USB communication test setup, Android USB host, Arduino Uno, serial communication

Hello friends! Today we will connect an Android phone to an Arduino through USB and exchange commands in both directions. This is useful when you want a wired control panel, a portable instrument display or a direct connection without configuring Bluetooth or Wi-Fi. We will start with one classic Arduino Uno and a small LED-control sketch. After that, we will revisit the original two-Arduino arrangement, which lets a computer monitor the bytes travelling through the phone connection. The second board is a debugging aid, not a requirement for Android communication. The important details are the phone's USB host support, the board's USB interface, permission to open the device and a clearly defined message format. Once these are understood, we can build a useful connection without treating USB as a mysterious pair of wires. In this arrangement, the Android device acts as the USB host and the Arduino appears as a USB device. The host discovers the connected device and manages communication. A classic Uno uses a separate USB-to-serial interface to carry the sketch's Serial data between USB and the ATmega328P UART. This is why we do not need an Arduino USB Host Shield for this tutorial. A host shield belongs to a different arrangement in which the Arduino must control a USB peripheral. Here, the phone already performs that host role. The original Uno R3 uses an ATmega16U2 interface, while compatible boards may use CH340, CP210x or another bridge. Their connectors can look similar ...