# APDE USB / OTG communication

**URL:** <https://discourse.processing.org/t/apde-usb-otg-communication/30114>\
**Category:** Processing for Android\
**Created:** [May 16, 2021, 12:13am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114 "2021-05-16T00:13:07Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 17, 2021, 8:37am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/21 "2021-05-17T08:37:30Z")

</div>

> [@jafal](#):
>
> many posted sketches the problem all was for old versions

versions of what?  
libraries?

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 17, 2021, 8:52am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/22 "2021-05-17T08:52:09Z")

</div>

> [@ZENAR57](#):
>
> versions of what?  
> libraries?

the Procedure is old

let me make simple project if it worked i am going to try APDE i need 1 or 2 days

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 17, 2021, 9:02am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/23 "2021-05-17T09:02:00Z")

</div>

> [@jafal](#):
>
> let me make simple project if it worked i am going to try APDE i need 1 or 2 days

Sure.  
That would be great.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 17, 2021, 11:15am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/24 "2021-05-17T11:15:28Z")

</div>

A working solution, with a bit of work from you, is already in your post:

> [@ZENAR57](#):
>
> Impossible to grant access to USB port through AndroidManifest · Issue #84 · Calsign/APDE · GitHub

This was my starting point and I have shared this link with you before:  
_[Impossible to grant access to USB port through AndroidManifest · Issue #84 · Calsign/APDE · GitHub](https://github.com/Calsign/APDE/issues/84)_

_Calsign_ states:

> Yes technically you can achieve what you want by modifying the manifest template, but this isn’t really a solution for most users because it means that _every_ sketch built with the modified version of APDE will have the `uses-feature` tag.

@glv steps to modify the _manifest template_:

1. Download the APDE.apk (_APDE v0.5.1 Alpha_) from:  
[GitHub - Calsign/APDE: Source code for APDE: Create and run Processing sketches on an Android device.](https://github.com/Calsign/APDE)

2. Use an APK Editor of your choice (I used APK Easy Tools on my PC) and modify this file:  
\assets\templates\AppManifest.xml.tmpl

To this:

> **Modified AppManifest.xml.tmpl**
>
> ```auto
> <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
> package=""
> android:versionCode="1"
> android:versionName="1.0"> 
> 
> <!-- Added -->
> <uses-feature android:name="android.hardware.usb.host"/>
> 					
> <uses-sdk android:minSdkVersion="@@min_sdk@@" android:targetSdkVersion="@@target_sdk@@" />
> <application android:label=""
> android:icon="@drawable/icon">
> <activity android:name=".MainActivity"
> android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
> <intent-filter>
> <action android:name="android.intent.action.MAIN" />
> <category android:name="android.intent.category.LAUNCHER" />
> </intent-filter>
> 						
> <!-- Added -->
> <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> 
> </application>
> </manifest>
> 
> ```

1. Install the modified APDE.APK on the Android phone.

2. Add this directory and file _/res/xml/device\_filter.xml_ to the sketch folder.  
This _device\_filter.xml_ (there are others) worked for me:  
_[processing-android-serial/src/main/examples/PulseSensor11574/res/xml/device\_filter.xml at master · inventit/processing-android-serial · GitHub](https://github.com/inventit/processing-android-serial/blob/master/src/main/examples/PulseSensor11574/res/xml/device_filter.xml)_

3. APDE _Preview_ mode did not work (some more modifications would be necessary) however I created an _App_ and this worked.

This works for my needs.

I have tested it and able to reproduce the results. `:)`

I wrote a very simple sketch on the Arduino to count and send to serial port and received this with my app (used the _modified_ APDE to make this) on the Android phone.

I now have serial communication between my Android Phone (Version 9) and Arduino Mega 2560 R3 (using an OTG cable) with an app created with the _modified_ APDE.

I have not worked with the APDE or an APK editor before so this was a worthwhile adventure and I now have some new tools, experience and skills for my technical resume.

Be methodical, meticulous and document while working on this.

The rest is up to you. Enjoy the journey!

_ **UPDATE** _ 2021-05-21  
I used the _AndroidSerial for Processing_ library latest release 0.2.0 available here:

> **[GitHub - inventit/processing-android-serial: Android Serial Library for...](https://github.com/inventit/processing-android-serial)**
>
> Android Serial Library for Processing. Contribute to inventit/processing-android-serial development by creating an account on GitHub.

`:)`

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 17, 2021, 11:30am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/25 "2021-05-17T11:30:55Z")

</div>

> [@glv](#):
>
> A working solution, with a bit of work from you, is already in your post:

i have said the you are able to solve it … on android mode the steps much easier and more simple

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 17, 2021, 12:46pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/26 "2021-05-17T12:46:16Z")

</div>

> [@jafal](#):
>
> Procedure

@ZENAR57 the Procedure of @glv is slimier for what i did in android mode it should work with you simply after you modify APDE make this folders inside your sketch folder /res/xml/ then add  
_device\_filter.xml_ file

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 17, 2021, 1:04pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/27 "2021-05-17T13:04:46Z")

</div>

Sure.  
That woul bi great.  
As soon as I have a free minute, I’ll do it right away.

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 17, 2021, 1:19pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/28 "2021-05-17T13:19:48Z")

</div>

This seems to be the simplest solution. now the main thing is that it would work out normally. I’ll try at home for the night.

> **+**
>
> > [@No serial library Processing for smartphone. Help](https://discourse.processing.org/t/no-serial-library-processing-for-smartphone-help/29870/175):
> >
> > I apologize to everyone present, if I cannot answer immediately, with a delay, and also do not immediately try the code, this is not disrespect towards those present. I am constantly on the road or at work, I answer immediately when there is an opportunity. And to try the code, I need even more time, I am an electrical engineer, not a professional programmer. This topic and the solution to this issue are very important to me. I am very grateful to everyone who helps and participates in finding a solution.

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 18, 2021, 1:08am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/29 "2021-05-18T01:08:43Z")

</div>

5.1alpha on my phone doesn’t want to download any zip library, even before modification. can it be done with 5.2 betta. Why only 5.1alpha?

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 18, 2021, 1:14am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/30 "2021-05-18T01:14:54Z")

</div>

@ZENAR57  
@paulgoux

I designed a temperature measurement program on the Arduino and it works on the Android over OTG

i finish Android mode now next step APDE mode

 ![Screenshot_2021-05-18-04-13-47-573](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e928264bcb997c98a7c31443b5e946c437c6a002.jpeg)

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 18, 2021, 1:24am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/31 "2021-05-18T01:24:46Z")

</div>

![Screenshot_2021-05-18-04-24-13-038](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/04a96d5bf21e3f46d2ec90bf3205022ca5afd6bd.jpeg)

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 18, 2021, 6:46am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/32 "2021-05-18T06:46:47Z")

</div>

OK.  
And what is your Arduino sensor that measures temperatures up to 400 ° C?

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 18, 2021, 6:55am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/33 "2021-05-18T06:55:14Z")

</div>

Some versions of APDE do not load compressed zip libraries, and some do well on the same smartphone.

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 18, 2021, 11:23am UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/34 "2021-05-18T11:23:27Z")

</div>

they got a new library 4 days ago. only it is not compressed, there is no zip file.

> **[Release v3.4.0 · mik3y/usb-serial-for-android](https://github.com/mik3y/usb-serial-for-android/releases/tag/v3.4.0)**
>
> //github.com/mik3y/usb-serial-for-android/releases/tag/v3.4.0

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 18, 2021, 12:10pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/35 "2021-05-18T12:10:15Z")

</div>

> [@ZENAR57](#):
>
> 5.1alpha on my phone doesn’t want to download any zip library, even before modification. can it be done with 5.2 betta. Why only 5.1alpha?

Hello @ZENAR57,

My exploration of this ended with this topic:  
_[APDE USB / OTG communication - #24 by glv](https://discourse.processing.org/t/apde-usb-otg-communication/30114/24)_

I am not using APDE and Android phone as my development environment at this time.

If I am [so inclined](https://www.merriam-webster.com/dictionary/so%20inclined) I will add to the topic.

Enjoy the exploration and the journey!

I hope you reach your destination.

`:)`

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [May 18, 2021, 12:14pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/36 "2021-05-18T12:14:08Z")

</div>

Thank you so much for your input!

---

<div class="post-metadata">

**Author:** ![ZENAR57](https://avatars.discourse-cdn.com/v4/letter/z/a698b9/32.png) [@ZENAR57](https://discourse.processing.org/u/ZENAR57)\
**Post date:** [May 18, 2021, 12:16pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/37 "2021-05-18T12:16:26Z")

</div>

Thank you.  
you have done a lot.  
your contribution was very great. Always welcome to this topic.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [May 18, 2021, 1:11pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/38 "2021-05-18T13:11:36Z")

</div>

2

[Source code(zip)](https://github.com/mik3y/usb-serial-for-android/archive/refs/tags/v3.4.0.zip)

[Source code(tar.gz)](https://github.com/mik3y/usb-serial-for-android/archive/refs/tags/v3.4.0.tar.gz)

> **[Release v3.4.0 · mik3y/usb-serial-for-android](https://github.com/mik3y/usb-serial-for-android/releases/tag/v3.4.0)**
>
> //github.com/mik3y/usb-serial-for-android/releases/tag/v3.4.0

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [May 18, 2021, 1:17pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/39 "2021-05-18T13:17:39Z")

</div>

Is there a jar version of this?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [May 18, 2021, 5:36pm UTC](https://discourse.processing.org/t/apde-usb-otg-communication/30114/40 "2021-05-18T17:36:34Z")

</div>

here it is as a jar, also the eclipse files should you wish to amend the build.

> **[paulgoux/serialAndroid](https://github.com/paulgoux/serialAndroid)**
>
> android usb serial library. Contribute to paulgoux/serialAndroid development by creating an account on GitHub.

[Previous page](https://discourse.processing.org/t/apde-usb-otg-communication/30114.md?page=1)

[Next page](https://discourse.processing.org/t/apde-usb-otg-communication/30114.md?page=3)
