I'm trying to get Rx from USB via GPIO for reverse engineering. I'll use it for such as keyboard, mouse, USB fax modem etc... I want to get data from USB device and sending data to my another computer. If it's impossible at least give me an idea or alternative way for doing this.

I tried to get keyboard's key presses but I failed at it.

Edit: in Python I already know how to key press or normal input set up but I think i'm lookin for digital input

I need a code block for doing this in Python for ex.

import RPi.GPIO as GPIO
GPIO.setup(18, GPIO.IN)
while True:

I connected a keyboard to USB Female and its always returning 1

enter image description here


  • 1
    Please edit in the entire program.
    – goldilocks
    Jan 8, 2016 at 14:31
  • 1
    Hello and welcome. Please note that your question is very broad and therefore hard to answer. Please be more specific.
    – Ghanima
    Jan 8, 2016 at 14:32
  • I'll edit ASAP. Thanks for warnings and informations
    – ahmetertem
    Jan 8, 2016 at 14:40
  • have you considered using a USB monitor/analyzer netcat can do this. Jan 8, 2016 at 18:58
  • related: raspberrypi.stackexchange.com/questions/32197/…
    – Ghanima
    Jan 8, 2016 at 19:41

3 Answers 3


All apologies for my (deleted) answer about USB using 5V logic. I had assumed this was the case, but when I went to check that I found this, which says high is <=3.6V and low is >=0.3V. I think this should be okay.

However, it also reads:

A USB device pulls one of the data lines high with a 1.5kO resistor. This overpowers one of the pull-down resistors in the host and leaves the data lines in an idle state called "J". The choice of data line indicates a device's speed support; full-speed devices pull D+ high, while low-speed devices pull D- high. In fact the data is transmitted by toggling the data lines between the J state and the opposite K state.

Source: http://www.eeherald.com/section/design-guide/esmod14.html

I am sure USB is a more complicated protocol than your code implements. Some initialization must take place. The keyboard is not simply a dumb serial device, but you have presumed plugging it in that way and hitting a key will cause the levels to shift. You will need to go through the specification to determine what is actually going to happen.

I would guess if the proper initialization does not occur, the device may simply leave the line high and not transmit keystrokes, etc. Notice if you plug a keyboard into a computer, it immediately recognizes it as a keyboard before you hit any keys. How does that happen? How does it know it is not a data stick or camera, etc? It's via the USB protocol, and you have not implemented it.

  • Thank you for your detailed reply. I assume it's hard for me because i do not have electronic information yet. I'll do more research about this but if i be success, i'll write down here... Thanks and regards
    – ahmetertem
    Jan 8, 2016 at 16:59

Um, you need more than what you have got, to connect directly to a USB device as you have tried.

For starters, USB data is carried differentially over a pair of data leads (D+ and D-) and whilst most of the time one is the inverse of the other the voltage levels (Wikipedia link) are 0.0-0.3V (low) and 2.8-3.6 (high) for low- (1.5Mbs) and full-speed (12Mbs) rates - and those are relative to each other - not to ground; high-speed uses ±0.10V (low) 0.36-0.44V (high) but again that is relative to each other NOT to ground so it is quite possible for the individual voltages to be over the 3.3 Voltmax for the GPIO pins!

You have also only connected the Data+ line and not the Data- one but this is largely academic as your current circuit cannot IMHO work.

A close up picture of part of the Qustioner's picture of their hardware - showing the connections made to a USB A connector plugged into a breadboard

Don't give up hope yet, though: for your stated aim - to send/share USB with another computer - you may want to look for the usbip package and/or packages containing the phrase "usbredir"...

  • Thanks for informations and usbip mm.. it look interesting project thanks
    – ahmetertem
    Jan 9, 2016 at 19:42
  • USB is not a truly differential protocol, it cannot work without GND. D+ and D- signals in USB have maximum and minimum voltage levels defined (with GND as a reference), and it's safe to connect them to 3.3V devices. May 19, 2017 at 12:55

Above all, there's no such thing as "USB RX". USB is a strictly "Request-Response" protocol, you will never receive a reply without sending a request first. It's also quite complex: each device expects to be configured before it can be used. Even if you managed to generate correct D- and D+ signals, you'd have to implement a USB host controller driver for your approach to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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