This question already has an answer here:
- Can I control voltage of USB data pins? 2 answers
I asked a similar question on a different website, DreamInCode, for assistance programming on an Android. I've also come on to this site for a different question but I can see that the folk that use this forum may also have a different set of expertise that may be able to assist me [specifically the USB tag]
Here's the link to the alternate question, but I'll rephrase it for additional clarity below: http://www.dreamincode.net/forums/topic/408284-can-i-drive-a-voltage-output-on-the-dd-lines-of-usb-communication/page__pid__2347827__st__0&#entry2347827
I'm using a SAMSUNG Galaxy S7 (although I don't believe the phone itself should matter, suffice to assume it's a modern android) and I've built my own modified USB OTG(OnTheGo) cable so that the phone can deliver power to an external device. For example, let's say I'm powering an LED in some external circuitry (I'm an electrical engineer). What I am trying to do is use the phone to enable/disable the external device(LED), preferably via an app on the phone. For my purposes, the circuitry must be enabled or disabled via user input on the phone.
I've tried googling how USB Serial communication works, and I have learned that the D+/D- wires are often pulled to specific voltage levels for certain chargers. Compatible phones will recognise these specific voltage levels and negotiate to receive higher voltage or current than normal to enable fast charging. What I haven't been able to determine if you can set the D+/D- wires as an output from the phone to certain voltage levels (e.g. digital HIGH or LOW), and use them as a DC control signal to connected to an electrical switch.
It is also important to me that this occurs through Serial communication; not wirelessly, bluetooth or via the audio jack, but I haven't been able to determine if I can set the phone to deliver a DC voltage from the D+/D- wires continuously (for a few seconds) to enable the device whilst it performs a measurement. The device itself will be powered by the USB OTG from the phone (5V) and draws very low current (milliamps).
If anyone could please help and identify a way to set a DC output on either of the D+/D- USB communication wires (or confirm if this is possible), I would greatly appreciate it :)
Sadly I do not understand enough about USB communication and all my research has returned is the protocol and sequence of various USB packets, not how the communication actually operates or if I can manipulate the D+/D- wires into a DC voltage source (low current is fine). I also believe the maximum voltage of the D+/D- wires is TTL Voltage (3.3V), commonly interpreted as a HIGH at 2.8V.
EDIT: If it were possible, the DC output on the D-/D+ wire would not drive any significant load, it would be used as a control signal to place an electrical switch (BJT,MOSFET) into saturation. Typically the base current of a BJT or gate current of a MOSFET is micro-amps.
Edit2: There is a much better explanation on Using D+ and D- from USB as power source?, by DrFriedParts. Ali Chen also comments on DrFriedParts that sending a stream of uninterrupted 1s may be possible, using a test mode.