A controller module (power supply) for piece of scientific equipment in our lab uses a Windows program on a PC for a human interface via USB connection. I have a list of the "set" and "read" commands that are exchanged over USB.

I would like to monitor or sniff their communication with a RPi without interrupting it.

If it were RS-232 I'd just tap into the serial line, perhaps use a buffer amplifier then have pigpio read for several seconds at the appropriate baud rate with something like the script below.

Once read, I'd look through the chunk of data for the particular "set" and "read" commands that I'm interested in.

Alas the connection is USB which I think poses several challenges

  • data clock rate could be very high
  • there may be a lot of extra information exchanged constantly that I'd have to filter out
  • since it's a different protocol, there's a chance that pi.bb_serial_read_open(pin, baud) might not collect anything because it doesn't recognize the signal.

I don't think I can add a USB hub and use a USB to serial converter, because it would not pick up the traffic intended for a different USB device.

Question: How can I use pigpio to "sniff" or monitor an existing USB connection between two devices?

update: These suggest to me that perhaps this is just too complicated and not worth trying, but maybe I'm overreacting? I just need to capture the stream passively, and search it for a few predetermined strings.

In response to the question in comments, I got some help from someone familiar with Windows 7 in Chinese. Turning on the power supply at the far end of the USB adds USB Serial Port COM4 to the display.

USB Serial Port COM4

Partial example script outlining how pigpio can be used to collect data on a serial line. There's no reason to think that this would work when monitoring communications on a USB connection.

from binascii import hexlify
import pigpio, time

# don't forget 'sudo pidof pigpiod'

pin = 24
baud = 9600
t_collect = 3. # seconds

pi = pigpio.pi() 

try: # in case it was left open

pi.bb_serial_read_open(pin, baud)



# now read what's been collected
size, data     = pi.bb_serial_read(pin)
data_hexlified = hexlify(data)
n_hexlified    = len(data_hexlified)
  • There's no reason to think that this would work when monitoring communications on a USB connection ... why did you post the code then? ... it just clutters up the post
    – jsotola
    Sep 3, 2021 at 1:23
  • you can get a USB sniffer program for windows, but that is off topic here
    – jsotola
    Sep 3, 2021 at 1:24
  • @jsotola 1) "There's no reason to think that..." is to prevent comments like "That won't work for USB because it's for..." or future readers from trying to use it. The code snippet serves (among other things) to inform potential answer authors the type of familiarity I do (and don't) have. 2) I disagree it clutters up the post, and disagree that the primary value of an SE post in an engineering SE site is its uncluttered aesthetic. Instead more is better. Once you gain some more experience asking Stack Exchange questions you'll see that providing plenty of information is the way to go
    – uhoh
    Sep 3, 2021 at 2:26
  • @jsotola I've asked over 3,000 Stack Exchange questions. While rare, the only times I've gotten comments of the form "why don't you format your question the way I'd like to see it" is when the comment author has little or no experience asking questions and then being the recipient of comments asking for more information.
    – uhoh
    Sep 3, 2021 at 2:31
  • one of these may work for you ... duckduckgo.com/?q=windows+usb+sniffer&ia=web
    – jsotola
    Sep 3, 2021 at 4:44

1 Answer 1


pigpio can not help with sniffing data over a USB link.

There are two principal reasons.

  1. pigpio can only sniff GPIO 0 to 31. USB traffic is not connected to these GPIO.
  2. pigpio can sniff data travelling at up to 500 thousand bits per second. Modern USB traffic is several orders of magnitude faster than pigpio can handle. Even the original low speed USB 1.0 was 1.5 million bits per second.
  • joan thanks for stopping by! For point #1 I was still thinking of "tap(ping) into the (USB) line, perhaps use a buffer amplifier..." It's certainly ugly and would have to be done carefully to not upset the twisted pair transmission line inside, but in and of itself it would be interesting to try. However, point #2 confirms my fear that "data clock rate could be very high" and seems absolutely inescapable. Your answer is extremely helpful because I can now just forget about this. Thanks!
    – uhoh
    Sep 3, 2021 at 8:12

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.