The situation in a nutshell: Arduino - collects data from sensors and transmits to Android. Android accepts them and, if necessary, issues a command to the Arduino, which executes them (for example, gives a signal to start the generator), etc. Zoo and the essence of the question:

  1. There is an Arduino DUE, with an APK on board, connected by a USB software port to the laptop. Here I actually correct the code in the Arduino IDE.
  2. There is an Asus tablet that is connected to the Arduino Due native port via an OTG cable. Accepts and transmits data in Android.Connect present.
  3. I am developing for Android in Android Studio.

Actually, how can I conduct and develop and debug the program on the Android device itself, without switching the wires?

  • The solution is quite obvious - to connect Arduino via Bluetooth. - Vanyamba Electronics
  • Yes, I am aware of such a decision. But it is not applicable in my case. - Stalker1204

4 answers 4

Obviously, in this case in any way. When you connect the device to the phone, it works in USB host mode. When connected to a computer in USB-device mode.

The maximum that could be done is a USB-OTG cable that charges the phone.

Alternatively, you can assemble one of two wires with a toggle switch (or a microUSB adapter - a toggle switch - 2USB). When switching the position of the toggle switch, switch the connected wires. enter image description here

  • The controller is located in the shielded hold of the boat. 16 sensors are connected to it. Due is powered by external power. Android device via USB-OTG cable is charging. One USB cable or 16 wires ... So you have to switch during development. - Stalker1204
  • @ Stalker1204 Added adapter shemku, which had in mind. I apologize for the picture, just paint at hand. - VAndrJ

Reach the RS232 from the arduine from the hold to the place where the tablet is installed. If the distance is too large (more than 10 meters for speed 9600), use RS485.

After that, put the RS232 - bluetooth converter (based on HC05) and connect the device to the android via bluetooth.

The final Arduino -> RS232 (485) -> Bluetooh -> tablet.

    USB from Arduin to start in a laptop, on a laptop to organize a virtual bluetooth com-port, which connect with android.

    Connect two comports in a laptop using socat or its equivalent.

      Everything is easier. Installed on Android "ADB wifi no root". (free of charge) I connected the Android device via cable to the computer and executed the commands in the Android Studio terminal (in fact, they were written when ADB wifi was started):

      1. adb tctip 5555
      2. adb connect IP_ADDRESS - the network address of the android device.
      3. Disconnected cable. Everything is working.

      On my Mac os "adb" was following this path: / Users /% USER_NAME% / Library / Android / sdk / platform-tools