I am developing a project to communicate with a mobile phone app via USB and serial communication. When the phone and arduino are connected the arduino takes power from the phone, so there must be current flowing along the cable. If I then plug an external power supply into the arduino, then I would of expected a reverse current flowing back to the phone to charge it.
Can power be output from the arduino USB?
If not, can I use the UART pinouts plus power and ground to connect another usb socket to get what I need?
There are specific limits to Arduino boards and even without knowing which one you have I suspect the basic answer is NO.
You can use an OTG cable to power the Arduino but only for basic use and probably not with too many added items such as sensors etc.
I have seen an OTG splitter somewhere on the internet that would allow you to use both the phone and Arduino from a power bank but danged if I can remember where.
Thank you for the reply. As I am a newbie I should have been more precise.
I am using a Uno, with an android mobile phone connected to it via the USB cable. The Uno communicates with the phone using serial over the USB cable. The Uno also has a 12v input into the power socket, so no problems powering the extra sensors, and I don't need to supply power to it from the phone. All of this works fine, apart from the phone not receiving any charge, and after a while turning off.
On googling a USBA connection it simply has 4 pins: 5v, Tx, Rx and Gnd. Looking further at the Uno schematic there is no 5v going to the USBA socket, so that rules out the phone receiving power from there.
My second question is asking whether the Tx and Rx (pins 0 and 1) on the Uno are the same as the Tx and Rx on the USBA plug. If so, I should be able to cobble together a USB cable which has 5v, Gnd, Tx and Rx taken from the Uno pin-outs, rather than use the existing USBA socket.
You are using an OTG cable already so that aspect is fine but as I mentioned there is another variation that has the splitter for power and you would maybe be better off searching for one of those.
However I am more concerned over the 12 volts to the board and would prefer to see 7-10 volts especially if you are using the power socket. 12 volts is a lot of waste heat for the regulator to get rid of.
They have been known to blow with 12 volts.
As for your last Q. the answer is both yes and no.
The UNO uses those pins to upload a sketch so if they are already in use you probably will not be able to upload to it.
USB serial enumeration is not quite the same as a real serial port but acts in a similar manner.
You may also want to draw up a schematic of what you have and its power systems so people can get to grips with any of your layout.