I need to connect arduino and android device via USB and send data via serial port with Unity.
My Problem is to find the USB port name in android, in PC you can see the name of the USB port (COM5 for example) but in Android i don't know how i can see these.
When I call these: SerialPort serial = new SerialPort("COM5",9600); the game works on PC but not in android because I dont know what is the name port. I try everything COM0, COM1, COM2 tty/USB "/dev/bus/usb/001/005"
I need to find this. :(
I am in the exact same situation as you. But as far as I can see the problem is a bit more complex than finding the right port name.
If I use the function: string[] ports = SerialPort.GetPortNames(); on PC it works fine and I can get all the CO$$anonymous$$-ports. But this won't run on android.
Please let me know find a solution.
Answer by Hogosha77 · Feb 01, 2016 at 01:09 AM
Has anyone a solution for this problem? Got exactly the same. With a Serial Monitor App, i can communicate with the serial device but not within unity..
Answer by fenomeno69 · Nov 25, 2016 at 11:16 AM
I have the same problem... I made the game in Unity and I want to connect an Android Device with Arduino to play the game via USB connection!!!
Answer by andor734 · Jan 18, 2017 at 12:40 PM
Download a terminal app from Google Play then type the following command into it:
ls /dev
Repeat with the device plugged in, and look for a file that appears in your '/dev' folder when you connect the device. That's your device name: '/dev/'
BTW, There may be a problem with unity in this respect, as the dll's necessary for SerialPort don't get loaded with the android version for some reason. Trying to figure this out.
Your answer
Follow this Question
Related Questions
send string to serial port on android 0 Answers
HELP: Arduino Genuino 101 to Unity3D. Serial Communication 0 Answers
Read Arduino Sensors using bluetooth in Unity 0 Answers
App - device connection in Android 0 Answers
Read Arduino Stream with Js or C# 0 Answers