Android+arduino+USB OTG

 

UsbSerial

https://github.com/felHR85/UsbSerial/releases

 

Android Studio

File>New>New Module>Import JAR,AAR Package

usbserial-release.aar

 

File >Project Structure > app > Depemdencies > file dependency >:usbserial-release

 

AndroidManifest.xml

<uses-feature android:name="android.hardware.usb.host" />
<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
    </intent-filter>

    <meta-data
        android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
        android:resource="@xml/device_filter" />
</activity>

 

res/xml/device_filter

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <usb-device vendor-id="9025" />
    <!-- Vendor ID of Arduino -->
</resources>

 

 

Leave a Reply