2

This is about how USB ports/devices work

Lets say i have a USB port on my computer

enter image description here

If I have an arduino board or something similar, am I able to connect output to Data+ and sort of make my own USB keyboard. What I aim to achieve is send without having to receive

enter image description here

1) Would I need to connect it to both D+ and D- so it forms a circuit in order for the USB port to read the data? (or would the data simply be read and then disappears so I don't have to worry about two wires?)

If Yes: 2) If I manage to forcefully push electricity through the wire onto the Data pins, would I only need one wire?

Else: 3) is this physically impossible and the whole universe would explode if I tried?

  • There are no separate data input and output pins. So no, you can't. – gre_gor Mar 22 '17 at 3:17
  • The "B" is USB stands for Bus. It would be worth a read to understand how a bus is different to, for example, a serial port (where this sort of thing could work). – Mark Smith Mar 22 '17 at 9:58
3

D+ and D- are not send and receive. The two signals are complementary to each other and bidirectional.

They form a low voltage differential pair. When one is high the other is low and vice versa.

Both have to be connected for USB signals to get through.

The data is sent down both wires at once, but only in one direction at a time (half duplex).

There is far more data going through USB than the data you are sending. The data you see is the end result of a complex protocol negotiation between your device and the host.

  • Thanks! it's a great answer. Am I able to only transmit data without receiving? I am able to connect to both D+ and D-, but I can only output data from my board, it doesn't receive data. For example, I'll just hardcode transmit the right data at the times I know when I should transmit, so i don't need to listen to the computer? – Friedpanseller Mar 23 '17 at 4:31
  • It is up to you what data is sent over the connection and in what direction. If you don't send data between the computer and the device then there is nothing for the device to read. – Majenko Mar 23 '17 at 10:25
3

USB is a host-managed protocol. A USB device must be able to receive in order to operate, since the host notifies the device when it should send data back to the host.

The D+ and D- lines are not independent; the signaling state of the line is determined by examining both lines regardless of whether the host or the device is transmitting.

USB Made Simple

-2

Your goal is stated as "send without being able to receive" but if you change that to "send without needing to receive" then that can be accomplished. (You need both data pins for a serial connection in any case)

I do it all the time so I can have an Arduino with ADC pins to measure voltages then feed it to the USB serial port on a Raspberry Pi.

Just use the cable that you program the Arduino with. (I bought a 15 foot cable from one of the usual sources so my Arduino can be near the voltage source and the Pi can be at a distance)

Anything you Serial.println on the Arduino will go to the Pi.

You can read from it on the Pi like so:

import serial
ser=serial.Serial("/dev/TTYUSB0,9600)

then

while True :
    linein = ser.readline()
    if len(linein)<10 : continue
        /* then do stuff with the input */

I even have the Arduino IDE on the Rpi so I can change the programs of either at any time. All of this is remote from me, so I use RDP via WiFi to connect to the Pi.

Total control without leaving my chair.

: When I connect it to my Win7 computer it gets assigned a COM port - and I go to Device Manager to find out which one, initially. Then even through subsequent reboots it stays the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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