1
\$\begingroup\$

If I take a USB cable connect it with my cellphone from 1 half and in the other end I connect VCC and GND to VCC and GND pins of the arduino and the D+ and D- pins to digital pins and use a differential to single ended signal converter (or make one using an opamp) can I actually read data sent from my cellphone to Arduino?

\$\endgroup\$
4
  • 4
    \$\begingroup\$ I’m voting to close this question because it is a usage question rather than a design question, and the various practical design questions it could potentially be edited into are all duplicates of existing questions covering those topics, eg, how USB signalling actually works, the possibilities/limitations of bit-bang USB, to what degree various phones can operate as USB hosts or devices, alternatives to USB for communication between a phone and Arduino - these all have answers already either here on EESE, on Arduino SE, Android SE, whatever iphone SE practically is, etc. \$\endgroup\$ Oct 5, 2020 at 19:10
  • \$\begingroup\$ i do not know ... can you? ... you are the one with the arduino, cable and cell phone, so give it a try \$\endgroup\$
    – jsotola
    Oct 5, 2020 at 19:24
  • \$\begingroup\$ jsotola I don't want to waste money on buying a USB cable then destroy it. \$\endgroup\$
    – Se1fie
    Oct 5, 2020 at 20:18
  • \$\begingroup\$ @Se1fie seriously, if the cost of a USB cable is the stopper here, you stand no chance. not only aren't the signalling states like you think, you stand no chance of implementing this on your first try. There will be more lost than a single USB cable.. \$\endgroup\$ Oct 5, 2020 at 20:52

2 Answers 2

3
\$\begingroup\$

No. You need to speak USB. USB is neither a "purely" differential thing, nor is it a unidirectional thing, nor is it overly relaxed in timing, nor can it be talked to with an UART, nor... in short: no, USB needs specific hardware¹ and your microcontroller (MCU) doesn't seem to have that if you're asking like this.

Either your Arduino's MCU ("arduino" doesn't tell us which that is) has a USB interface or it doesn't. If it doesn't, bad luck.

If it does: you'll just have to implement a full USB device stack on that MCU; I doubt that the arduino platform will be of extremely much help there, but I'm not an Arduino expert. (I'm assuming your phone belongs in the category of "smart phones", and will have to be the host device here. )

If it doesn't: no. Get a MCU with a USB controller built-in. I'd personally just drop Arduino on the way. Little benefit having a loop-based system if you're actually dealing with asynchronously coming in messages from a USB host.


¹ very few exceptions, where you can emulate a keyboard in software, but you can't do that with the Arduino firmware, due to timing constraints.

\$\endgroup\$
12
  • \$\begingroup\$ well, i can read a usb keyboard from a promini, but that's not otg... \$\endgroup\$
    – dandavis
    Oct 5, 2020 at 18:57
  • 2
    \$\begingroup\$ Arduino is not really an obstacle to the faking of low speed USB in software, since one can always code through to the hardware, but that's hardly a good idea anyway. The real issue is that asker's unfamiliarity with the concepts and lack of a clear sense of what "the data from the phone" even means. \$\endgroup\$ Oct 5, 2020 at 19:02
  • \$\begingroup\$ I mean, you can send data to a HID device (control endpoints and flickering caps lock and other LEDs), but that's not going to sit well at all with Android, @dandavis, and OP is asking about getting data out of the phone into their arduino. \$\endgroup\$ Oct 5, 2020 at 19:02
  • \$\begingroup\$ @ChrisStratton well, how much Arduino is there if you're really in a cycle-counting tight loop that you never leave, because that's what it takes to do USB on a non-USB Attiny/mega... \$\endgroup\$ Oct 5, 2020 at 19:04
  • 1
    \$\begingroup\$ How much "Arduino" is there anyway? And no, one is not in a cycle counting loop that is never left, otherwise nothing useful could be done. In reality the USB lines are inactive the majority of the time. I've for example done capacitance metering. It was interesting as a curiosity, but there wasn't any real point in developing it further. \$\endgroup\$ Oct 5, 2020 at 19:06
0
\$\begingroup\$

Using an Arduino compatible Teensy 3 or 4 board, it is relatively straightforward to implement USB client devices like, mice, keyboards, audio I/O and serial devices like UART and MIDI devices, also for Android OTG hosts. You can also implement custom USB clients if you modify the core files.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.